0

我正在创建一种小型 RPG 风格的游戏。在这一点上,我试图创造 3 个技能。治疗,罢工和终结者,作为测试。治疗提供 +15 生命值,打击造成 15 伤害,终结者造成 25 伤害和 15 后坐力伤害。我已经分别对这些技能进行了编码。后来有人告诉我,使用“课程”我可以创建一个技能应该具备的属性及其属性,但我不确定如何在我的情况下使用它。我已经搜索了一整天的课程,但还没有找到适用于我的情况的内容。任何帮助我如何创建一个持有参数的类,如所需的 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