VB.NET游戏冷却时间

时间:2013-11-07 03:45:27

标签: vb.net

我正在尝试制作游戏,但我遇到了一个问题:我不知道如何将冷却时间用于技能。 例: “鲍勃对一名目标造成25点伤害,并在使用新的友方技能之前击晕他们的进攻技能。” 好吧,现在是Bab转身。 Bab使用友好技能并结束转弯。 鲍勃每回合可以攻击25点伤害并且惊人,让Bab的进攻技能变得昏暗。

那么,我怎么能对鲍勃的25次伤害攻击进行1回合冷却?

有代码:

Public Class Form1

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wparam As Integer, ByVal lParam As Integer) As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Timer1.Start()
    Dim n As New Random
    If n.Next(100) <= 50 Then
        KyuubiChakra.Visible = 0
        KyuubiRasengan.Visible = 0
    Else
        DarkGenjutsu.Visible = 0
        WaterControl.Visible = 0
    End If
End Sub

Private Sub RESET_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RESET.Click
    ProgressBar1.Value = 100
    ProgressBar2.Value = 100
    Label1.Text = ""
    Label2.Text = ""
    Label3.Text = ""
    Label4.Text = ""
    Label5.Text = ""
    Label6.Text = ""

    KyuubiChakra.Visible = 1
    KyuubiRasengan.Visible = 1
    DarkGenjutsu.Visible = 1
    WaterControl.Visible = 1

    Dim t As New Random
    If t.Next(100) <= 50 Then
        KyuubiChakra.Visible = 0
        KyuubiRasengan.Visible = 0
    Else
        DarkGenjutsu.Visible = 0
        WaterControl.Visible = 0
    End If
End Sub

Private Sub NidaimeHokage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NidaimeHokage.Click
    Label1.ForeColor = Color.Blue
    Label1.Text = "Nidaime Hokage"
    Label2.Text = "The second Hokage from Konoha."
    Label3.Text = ""
End Sub

Private Sub KyuubiNaruto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KyuubiNaruto.Click
    Label4.ForeColor = Color.Blue
    Label4.Text = "Kyuubi Naruto"
    Label5.Text = "Enraged Naruto."
    Label6.Text = ""
End Sub

Private Sub DarkGenjutsu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DarkGenjutsu.Click
    Label1.ForeColor = Color.Black
    Label1.Text = "Dark Genjutsu"
    Label2.Text = "Nidaime Hokage steals 35 health points from a target."
    Label3.Text = "This skill can only be used when Nidaime has 35 or less health."
End Sub

Private Sub WaterControl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WaterControl.Click
    Label1.ForeColor = Color.Black
    Label1.Text = "Water Control"
    Label2.Text = "Nidaime Hokage deals 25 damage to a target and"
    Label3.Text = "stun offensive skills until that target use a friendly skill."
End Sub

Private Sub KyuubiChakra_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KyuubiChakra.Click
    Label4.ForeColor = Color.Black
    Label4.Text = "Rage Chakra"
    Label5.Text = "Kyuubi Naruto deals 10 damage to"
    Label6.Text = "a target and heals 15 health points."
End Sub

Private Sub KyuubiRasengan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KyuubiRasengan.Click
    Label4.ForeColor = Color.Black
    Label4.Text = "Kyuubi Rasengan"
    Label5.Text = "Kyuubi Naruto deals 55 damage to"
    Label6.Text = "a target and loses 20 health points."
End Sub

Private Sub DarkGenjutsu_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DarkGenjutsu.DoubleClick
    If ProgressBar1.Value <= 35 Then
        DarkGenjutsu.Visible = 0
        WaterControl.Visible = 0
        KyuubiChakra.Visible = 1
        KyuubiRasengan.Visible = 1
    End If
    If ProgressBar2.Value - 35 < ProgressBar2.Minimum And ProgressBar1.Value <= 35 Then
        ProgressBar2.Value = ProgressBar2.Minimum
    ElseIf ProgressBar1.Value <= 35 Then
        ProgressBar2.Value = ProgressBar2.Value - 35
    End If
    If ProgressBar1.Value <= 35 Then
        ProgressBar1.Value = ProgressBar1.Value + 35
    End If
    If ProgressBar2.Value = ProgressBar2.Minimum Then
        MessageBox.Show("Nidaime Wins!")
    End If
End Sub

Private Sub WaterControl_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles WaterControl.DoubleClick
    If ProgressBar2.Value - 25 < ProgressBar2.Minimum Then
        ProgressBar2.Value = ProgressBar2.Minimum
    Else
        ProgressBar2.Value = ProgressBar2.Value - 25
        DarkGenjutsu.Visible = 0
        WaterControl.Visible = 0
        KyuubiChakra.Visible = 1
        KyuubiRasengan.Visible = 0
    End If
    If ProgressBar2.Value = 0 Then
        MessageBox.Show("Nidaime Wins!")
    End If
End Sub

Private Sub KyuubiChakra_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles KyuubiChakra.DoubleClick
    If ProgressBar1.Value - 10 < ProgressBar1.Minimum Then
        ProgressBar1.Value = ProgressBar1.Minimum
    Else
        ProgressBar1.Value = ProgressBar1.Value - 10
        KyuubiChakra.Visible = 0
        KyuubiRasengan.Visible = 0
        DarkGenjutsu.Visible = 1
        WaterControl.Visible = 1
    End If
    If ProgressBar1.Value = 0 Then
        MessageBox.Show("Naruto Wins!")
    End If
    If ProgressBar2.Value + 15 > ProgressBar2.Maximum Then
        ProgressBar2.Value = ProgressBar2.Maximum
    Else
        ProgressBar2.Value = ProgressBar2.Value + 15
    End If
End Sub

Private Sub KyuubiRasengan_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles KyuubiRasengan.DoubleClick
    If ProgressBar1.Value - 55 < ProgressBar1.Minimum Then
        ProgressBar1.Value = ProgressBar1.Minimum
    Else
        ProgressBar1.Value = ProgressBar1.Value - 55
        KyuubiChakra.Visible = 0
        KyuubiRasengan.Visible = 0
        DarkGenjutsu.Visible = 1
        WaterControl.Visible = 1
    End If
    If ProgressBar2.Value - 20 < ProgressBar2.Minimum Then
        ProgressBar2.Value = ProgressBar2.Minimum
    Else
        ProgressBar2.Value = ProgressBar2.Value - 20
    End If
    If ProgressBar1.Value = ProgressBar1.Minimum Then
        MessageBox.Show("Naruto Wins!")
    ElseIf ProgressBar2.Value <= ProgressBar2.Minimum Then
        MessageBox.Show("Nidaime Wins!")
    End If
End Sub

Private Sub DarkGenjutsuSTUN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DarkGenjutsuSTUN.Click
    Label1.ForeColor = Color.Black
    Label1.Text = "Dark Genjutsu"
    Label2.Text = "Nidaime Hokage steals 35 health points from a target."
    Label3.Text = "This skill only can be used when Nidaime has 35 or less health."
End Sub

Private Sub WaterControlSTUN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WaterControlSTUN.Click
    Label1.ForeColor = Color.Black
    Label1.Text = "Water Control"
    Label2.Text = "Nidaime Hokage deals 25 damage to a target and"
    Label3.Text = "stun offensive skills until that target use a friendly skill."
End Sub

Private Sub KyuubiChakraSTUN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KyuubiChakraSTUN.Click
    Label4.ForeColor = Color.Black
    Label4.Text = "Rage Chakra"
    Label5.Text = "Kyuubi Naruto deals 10 damage to"
    Label6.Text = "a target and heals 15 health points."
End Sub

Private Sub KyuubiRasenganSTUN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KyuubiRasenganSTUN.Click
    Label4.ForeColor = Color.Black
    Label4.Text = "Kyuubi Rasengan"
    Label5.Text = "Kyuubi Naruto deals 55 damage to"
    Label6.Text = "a target and loses 20 health points."
End Sub

Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
    ProgressBar1.Increment(0)
    ProgressBar2.Increment(0)
    Label7.Text = ProgressBar1.Value
    Label8.Text = ProgressBar2.Value
    If ProgressBar1.Value >= 65 Then
        SendMessage(ProgressBar1.Handle, 1040, 1, 0)
        Label7.ForeColor = Color.Green
    End If
    If ProgressBar1.Value < 65 And ProgressBar1.Value >= 35 Then
        SendMessage(ProgressBar1.Handle, 1040, 3, 0)
        Label7.ForeColor = Color.Yellow
    End If
    If ProgressBar1.Value < 35 Then
        SendMessage(ProgressBar1.Handle, 1040, 2, 0)
        Label7.ForeColor = Color.Red
    End If

    If ProgressBar2.Value >= 65 Then
        SendMessage(ProgressBar2.Handle, 1040, 1, 0)
        Label8.ForeColor = Color.Green
    End If
    If ProgressBar2.Value < 65 And ProgressBar1.Value >= 35 Then
        SendMessage(ProgressBar2.Handle, 1040, 3, 0)
        Label8.ForeColor = Color.Yellow
    End If
    If ProgressBar2.Value < 35 Then
        SendMessage(ProgressBar2.Handle, 1040, 2, 0)
        Label8.ForeColor = Color.Red
    End If
End Sub

Private Sub Pass1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Pass1.Click
    DarkGenjutsu.Visible = 0
    WaterControl.Visible = 0
    KyuubiRasengan.Visible = 1
    KyuubiChakra.Visible = 1
End Sub

Private Sub Pass2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Pass2.Click
    DarkGenjutsu.Visible = 1
    WaterControl.Visible = 1
    KyuubiRasengan.Visible = 0
    KyuubiChakra.Visible = 0
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    ProgressBar1.Increment(0)
    ProgressBar2.Increment(0)
    Label7.Text = ProgressBar1.Value
    Label8.Text = ProgressBar2.Value
    If ProgressBar1.Value >= 65 Then
        SendMessage(ProgressBar1.Handle, 1040, 1, 0)
        Label7.ForeColor = Color.Green
    End If
    If ProgressBar1.Value < 65 And ProgressBar1.Value >= 35 Then
        SendMessage(ProgressBar1.Handle, 1040, 3, 0)
        Label7.ForeColor = Color.Yellow
    End If
    If ProgressBar1.Value < 35 Then
        SendMessage(ProgressBar1.Handle, 1040, 2, 0)
        Label7.ForeColor = Color.Red
    End If

    If ProgressBar2.Value >= 65 Then
        SendMessage(ProgressBar2.Handle, 1040, 1, 0)
        Label8.ForeColor = Color.Green
    End If
    If ProgressBar2.Value < 65 And ProgressBar1.Value >= 35 Then
        SendMessage(ProgressBar2.Handle, 1040, 3, 0)
        Label8.ForeColor = Color.Yellow
    End If
    If ProgressBar2.Value < 35 Then
        SendMessage(ProgressBar2.Handle, 1040, 2, 0)
        Label8.ForeColor = Color.Red
    End If
End Sub

结束班

看 - &gt; http://i.stack.imgur.com/sbT4F.png

1 个答案:

答案 0 :(得分:2)

创建一个每回合递增的游戏转弯变量。例如TurnCounter
为您的技能创建一个类,其中包含一个指示下次可用时间的属性。例如Power.CooldownUntil
禁用时设置属性,并在尝试使用时检查它。

例如:

' to disable a power for 2 turns the code might look like  
Player1.SpecialPower.CooldownUntil = TurnCounter + 2


' to test a power to see if it can be used:
If Player1.SpecialPower.CooldownUntil < TurnCounter Then
    ' use the power
Else
    ' don't use the power
End If

我假设您知道如何创建类和属性。如果你不这样做,我很抱歉,但我无法帮助你。