创建一个类来为RPG创建技能

时间:2013-09-29 22:07:17

标签: vb.net class parameters

我正在创造一种小型RPG风格的游戏。在这一点上,我试图创造3种技能。治愈,罢工和终结者,作为一种考验。治疗给予+15 HP,攻击交易15dmg,终结者造成25dmg,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

0 个答案:

没有答案