是否可以在 Visual Basic 中创建对象数组?
我正在制作一个战斗系统,每当战斗开始时,我希望能够从数组中随机选择一个 Monster 对象。
如果可能的话,有人可以告诉我如何存储Public Spider as New Monster(50, 20, 5)
到数组中吗?
谢谢你。
怪物等级:
Public Class Monster
Private hp As Integer
Private xp As Integer
Private dmg As Integer
Sub New(ByVal hitpoints As Integer, ByVal exp As Integer, ByVal damage As Integer)
hp = hitpoints
xp = exp
dmg = damage
End Sub
End Class
表格类:
Imports Monster
Public Class Form
Public Spider As New Monster(50, 20, 5)
End Class