我正在编写一个游戏,我的所有代码都可以工作,但是我正在寻找更有效的方法来编写我的代码。
有没有更有效的方法来编写这段特定的代码
Select Case (N)
Case 1
If Player1HandGroup(14).QuantityInteger > 0 Or Player1HandGroup(17).QuantityInteger > 0 Or (Player1HandGroup(16).QuantityInteger > 0 And (IDbuster = 8 Or IDbuster = 9 Or _
IDbuster = 10 Or IDbuster = 11)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.Cancel Or DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
Case 2
If Player1HandGroup(14).QuantityInteger2 > 0 Or Player1HandGroup(17).QuantityInteger2 > 0 Or (Player1HandGroup(16).QuantityInteger2 > 0 And (IDbuster = 8 Or IDbuster = 9 Or _
IDbuster = 10 Or IDbuster = 11)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.Cancel Or DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
Case 3
If Player1HandGroup(14).QuantityInteger3 > 0 Or Player1HandGroup(17).QuantityInteger3 > 0 Or (Player1HandGroup(16).QuantityInteger3 > 0 And (IDbuster = 8 Or IDbuster = 9 Or _
IDbuster = 10 Or IDbuster = 11)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.Cancel Or DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
Case 4
If Player1HandGroup(14).QuantityInteger4 > 0 Or Player1HandGroup(17).QuantityInteger4 > 0 Or (Player1HandGroup(16).QuantityInteger4 > 0 And (IDbuster = 8 Or IDbuster = 9 Or _
IDbuster = 10 Or IDbuster = 11)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.Cancel Or DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
Case 5
If Player1HandGroup(14).QuantityInteger5 > 0 Or Player1HandGroup(17).QuantityInteger5 > 0 Or (Player1HandGroup(16).QuantityInteger5 > 0 And (IDbuster = 8 Or IDbuster = 9 Or _
IDbuster = 10 Or IDbuster = 11)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.Cancel Or DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
End Select
每种情况之间的唯一区别是:N 代表选择了哪个玩家,然后使用特定数量的 NI 决定要查看我的 Structure 组中的哪个 Quantity 整数。
如果有办法以某种方式将其减少到仅 1 个实例并在数量整数上动态添加“数字”,我觉得它真的会在整个项目中释放大量代码。