-1

ゲームを作ろうとしているのですが、問題がありました。スキルにクールダウンを設定する方法がわかりません。例: 「ボブはターゲットに 25 ダメージを与え、新しい味方スキルが使用されるまで攻撃スキルをスタンさせます。」さて、バブのターンです。バブは友好的なスキルを使用してターンを終了します。ボブは毎ターン 25 ダメージと気絶を攻撃し、バブの攻撃スキルを気絶させます。

では、ボブの25ダメージ攻撃に1ターンのクールダウンを持たせるにはどうすればよいですか?

コードがあります:

パブリック クラス 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

クラス終了

見てください --> http://i.stack.imgur.com/sbT4F.png

4

1 に答える 1

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

クラスとプロパティの作成方法を知っていることを前提としています。そうでない場合は、申し訳ありませんがお手伝いできません。

于 2013-11-07T04:21:37.143 に答える