0

一種の小さな RPG スタイルのゲームを作成しています。この時点で、3 つのスキルを作成しようとしました。テストとして、ヒール、ストライク、フィニッシャー。ヒールは+15HPを与え、ストライクは15ダメージを与え、フィニッシャーは15リコイルダメージで25ダメージを与えます。これらのスキルをすべて個別にコーディングしました。後で、「クラス」を使用して、スキルが持つべきものとそのプロパティの親を作成できると言われましたが、私の場合、これをどのように使用するかわかりません。クラスで丸一日検索しましたが、自分の状況に当てはまるものが見つかりませんでした. 必要な MAna、与えられたダメージ、HP の再生、クリティカル レート ボーナス、必要なレベルなどのパラメータを保持するクラスを作成する方法について、助けていただければ幸いです。どのように見えるべきかを理解したら、自分でできるはずです。それが助けになれば、スキルのコードの一部を送ることができます。

Public Class Skill

Private Sub btnSHeal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSHeal.Click
    SkillSelected = 1
End Sub

Private Sub btnSStrike_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSStrike.Click
    SkillSelected = 2
End Sub

Private Sub btnSFinisher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSFinisher.Click
    'attack += 25
    'recoil = 15
    SkillSelected = 3
End Sub

Private Sub Skill_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If lvl >= 1 Then
        btnSStrike.Enabled = True
    Else
        btnSStrike.Enabled = False
    End If
    If lvl >= 1 Then
        btnSFinisher.Enabled = True
    Else
        btnSFinisher.Enabled = False
    End If
End Sub
Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    ' not sure what the old code was doing

    Timer2.Stop() ' stop the attacks

    Battle.MonsterAttacks(health, mattack, CritRate, Defence)
    Battle.HPBarsAlter(mhealth, health)
    Battle.MobDeath(mhealth, MobNumber)

End Sub

Sub Heal(ByRef Mana As Integer, ByRef health As Integer)
    If Mana > 0 And lvl >= 1 Then
        health += 25
        Mana -= 15
        Call Battle.HPBarsAlter(mhealth, health)
        Call Battle.textShiftUp(numlines)

        Timer2.Interval = 1500
        Timer2.Start()
    Else
        Battle.TextBox.Text = Battle.TextBox.Text & vbNewLine & "You Do NOT have enough Mana for this Skill!"
    End If
End Sub
Sub Strike(ByRef Mana As Integer, ByRef attack As Integer)
    If Mana > 0 And lvl >= 2 Then
        attack = Sattack
        Mana -= 15
        Call Battle.PlayerAttacks(mhealth, Sattack)
        Call Battle.HPBarsAlter(mhealth, health)
        Call Battle.textShiftUp(numlines)

        Timer2.Interval = 1500
        Timer2.Start()
    ElseIf Mana > 0 Then
        Battle.TextBox.Text = Battle.TextBox.Text & vbNewLine & "You Do NOT have enough Mana for this Skill!"
    ElseIf lvl < 2 Then
        Battle.TextBox.Text = Battle.TextBox.Text & vbNewLine & "You Are not level 2!"
    End If
End Sub
Sub Finisher(ByRef Mana As Integer, ByRef attack As Integer, ByRef recoil As Integer)
    If Mana > 0 And lvl >= 4 Then
        Sattack = attack + 25
        Mana -= 30
        recoil = 15

        Call Battle.PlayerAttacks(mhealth, Sattack)
        Call Battle.HPBarsAlter(mhealth, health)
        Call Battle.textShiftUp(numlines)
        health -= recoil
        Battle.TextBox.Text = Battle.TextBox.Text & vbNewLine & "You Do Took " & recoil & " recoil Damage"
        Timer2.Interval = 1500
        Timer2.Start()
    ElseIf Mana > 0 Then
        Battle.TextBox.Text = Battle.TextBox.Text & vbNewLine & "You Do NOT have enough Mana for this Skill!"
    ElseIf lvl < 2 Then
        Battle.TextBox.Text = Battle.TextBox.Text & vbNewLine & "You Are not level 4!"
    End If
End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
    Using SkillForm As New HotKeyAdd()
        SkillForm.ShowDialog()
    End Using
End Sub
End Class
4

0 に答える 0