我编写了 Levels 类来存储每个级别的敌人数量。Levels 类在开始一个新的关卡之前被调用一次。例如,如果玩家在游戏菜单中选择 1 级,则应绘制 5 个僵尸、3 个蜘蛛和 1 个狼人(在另一个类中)。但是目前,我总是收到此错误消息:方法必须具有返回类型。
怎么了 ?
public class Levels
{
int currentLevel, Zombies, Spiders, Werewolfs;
public Levels(int Level)
{
this.currentLevel = Level;
}
public Level1()
{
Zombies = 5;
Spiders = 3;
Werewolfs = 1;
}
public Level2()
{
Zombies = 8;
Spiders = 4;
Werewolfs = 2;
}
public Level3()
{
Zombies = 12;
Spiders = 4;
Werewolfs = 3;
}
public void Load(ContentManager content)
{
if (currentLevel == 1)
Level1();
if (currentLevel == 2)
Level2();
if (currentLevel == 3)
Level3();
}
}