c视觉工作室滚动游戏老板级别给老板一个健康条



制作一个滚动游戏,并将其分解成更小的部分,直到我解决了新添加的内容,然后将其添加到游戏中。我想好了如何为玩家创建一个健康条,这样当他被敌人击中时,健康条的级别就会降低。我似乎无法为敌人的老板扭转局面。现在我有一个名为healthbar的玩家进度条,设置为100%,每次玩家被击中时减少10。我还有一个名为bosshhealth的老板进度条,它也设置为100%,每次被击中时也会减少10。现在,当老板用激光击中玩家时,玩家会受到伤害,但当玩家向老板射击时,他不会受到任何伤害。

void HitorMiss()
{
if(Player.Bounds.IntersectsWith(powerarmour.Bounds) || Player.Bounds.IntersectsWith(e1laser.Bounds))
{
if (healthbar.Value <= 0)
{
healthbar.Value = 100;
}
else if (healthbar.Value == 0)
Dead();
else
healthbar.Value -= 10;
}
else if(powerarmour.Bounds.IntersectsWith(shoot.Bounds))
{
if (bosshealth.Value <= 0)
{
bosshealth.Value = 100;
}
else if (bosshealth.Value == 0)
{
//code to make boss explode and then disappear
}
else
bosshealth.Value -= 10;
}
}

这是一段非常令人困惑的代码,但我喜欢这个方法的名称哈哈。

我建议做一些类似的事情:

void HitorMiss(){
if(Player.Bounds.IntersectsWith(powerarmour.Bounds) || Player.Bounds.IntersectsWith(e1laser.Bounds))
{
healthbar.Value = 100;
if (healthbar.Value == 0) Dead();
else healthbar.Value -= 10;
}
if(powerarmour.Bounds.IntersectsWith(shoot.Bounds))
{
bosshealth.Value = 100; 
if (bosshealth.Value == 0) BossDead();

else bosshealth.Value -= 10; 
}}

但我强烈建议你在命中法之外设置hp和死亡逻辑。

相关内容

最新更新