开发者社区> 问答> 正文

Visual Basics-如果if语句完成,似乎自己重复一遍,并说其他玩家赢了。这会使其他玩家的健

我是编码新手,有一个我无法解决的问题。我正在制作口袋妖怪的战斗场景,在击败其他玩家之后,游戏将重置。由于某种原因,如果对手拥有59点生命,并且使用了30点生命值的移动,则表示您赢了,因为现在的值是30以下。

这是我的代码的一部分

`lblComputerHealth.Text = prgcomputer.Value & "/ " & prgcomputer.Maximum
        If btnPlayerChoice.Text = "blastoise" Then
            If prgPlayer.Value <= 262 And prgPlayer.Value >= 183 Then
                prgPlayer.ForeColor = Color.Green
            ElseIf prgPlayer.Value <= 182 And prgPlayer.Value >= 131 Then
                prgPlayer.ForeColor = Color.Yellow
            ElseIf prgPlayer.Value <= 130 And prgPlayer.Value >= 66 Then
                prgPlayer.ForeColor = Color.Orange
            ElseIf prgPlayer.Value <= 65 Then
                prgPlayer.ForeColor = Color.Red
            End If

            If frmSplash.btnComputer.Text = "blastoise" Then
                If prgcomputer.Value <= 262 And prgcomputer.Value >= 183 Then
                    prgcomputer.ForeColor = Color.Green
                ElseIf prgcomputer.Value <= 182 And prgcomputer.Value >= 131 Then
                    prgcomputer.ForeColor = Color.Yellow
                ElseIf prgcomputer.Value <= 130 And prgcomputer.Value >= 66 Then
                    prgcomputer.ForeColor = Color.Orange
                ElseIf prgcomputer.Value <= 65 Then
                    prgcomputer.ForeColor = Color.Red
                End If
            End If

            If prgcomputer.Value <= 30 Then
                'ADD A DO YOU WISH TO PLAY AGAIN BUTTON
                MessageBox.Show("YOU WON")
                intWins += 1
                frmSplash.btnPlayerChoiceone.Text = ""
                intwhy = 1
                strplayerchoice = ""
                intCompAttack = 0
                intwhyone = 0
                strcool = ""
                frmSplash.btnComputer.Text = ""
                frmSplash.btnPlayerChoiceone.Text = ""
                picPlayer.Image = Nothing
                picComputer.Image = Nothing
                btnChoosePlayer.Visible = True
                btnMoveOne.Visible = False
                btnMoveTwo.Visible = False
                btnMoveThree.Visible = False
                btnMoveFour.Visible = False
                prgPlayer.Value = 262
                prgcomputer.Value = 262
                lblWins.Text = intWins
                prgcomputer.ForeColor = Color.ForestGreen
                prgPlayer.ForeColor = Color.Green
            Else
                prgcomputer.Value = prgcomputer.Value - 30
            End If

        End If
            If frmSplash.btnComputer.Text = "blastoise" Then
                MessageBox.Show("Oponent thinking of move")

                Threading.Thread.Sleep(1000)

                intCompAttack = rand.Next(2) 'you will have to make this 3 some day
                Select Case intCompAttack
                    Case 0
                        prgPlayer.Value -= 20
                        lblPlayerHealth.Text = prgPlayer.Value & "/ " & prgPlayer.Maximum
                        MessageBox.Show("Opponent used Tackle and delt 20 damage")
                            'use a loop in the animation
                    Case 1
                        prgPlayer.Value -= 30
                        lblPlayerHealth.Text = prgPlayer.Value & "/ " & prgPlayer.Maximum
                        MessageBox.Show("opponent used Water Gun and delt 30 damage")
                End Select

            End If'

这是我认为不起作用的部分

'If prgcomputer.Value <= 30 Then
                'ADD A DO YOU WISH TO PLAY AGAIN BUTTON
                MessageBox.Show("YOU WON")
                intWins += 1
                frmSplash.btnPlayerChoiceone.Text = ""
                intwhy = 1
                strplayerchoice = ""
                intCompAttack = 0
                intwhyone = 0
                strcool = ""
                frmSplash.btnComputer.Text = ""
                frmSplash.btnPlayerChoiceone.Text = ""
                picPlayer.Image = Nothing
                picComputer.Image = Nothing
                btnChoosePlayer.Visible = True
                btnMoveOne.Visible = False
                btnMoveTwo.Visible = False
                btnMoveThree.Visible = False
                btnMoveFour.Visible = False
                prgPlayer.Value = 262
                prgcomputer.Value = 262
                lblWins.Text = intWins
                prgcomputer.ForeColor = Color.ForestGreen
                prgPlayer.ForeColor = Color.Green
            Else
                prgcomputer.Value = prgcomputer.Value - 30
            End If    `

展开
收起
几许相思几点泪 2019-12-08 22:31:07 300 0
0 条回答
写回答
取消 提交回答
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载