BOSS类和Enemy差不多,其实貌似因该继承自GameEnemy才对??
public class GameBoss : GameObject
{
protected Box[] SubBoxCollider = null; // BoxCollider用作大范围的检测,SubBoxCollider是细节检测
protected GameBarrage mBarrage = null; // 弹幕生成器
protected int BossWidth;
protected int BossHeight;
protected int HalfBossWidth;
protected int HalfBossHeight;
protected Vector2 Speed;
protected int Life; // 当前生命值
protected int MaxLife; // 最大生命值
public bool IsLive; // 是否存活
protected float ShowLife; // 用于显示血条
protected Rectangle HpRect = new Rectangle(10, 5, Config.ScreenWidth - 20, 8); // 血条显示位置
protected int State = 0; // BOSS状态,也可理解为当前应该发射的弹幕状态
public GameBoss(GameBarrage barrage)
{
this.mBarrage = barrage;
this.Life = 1;
this.MaxLife = 1;
this.ShowLife = 1;
this.IsLive = true;
}
public bool Collide(Box box)
{
// 先用大范围的碰撞盒检测
if ( BoxCollider.Collide(box) == false )
{
return false;
}
foreach ( Box subBox in SubBoxCollider )
{
if ( subBox.Collide(box) == true )
{
return true;
}
}
return false;
}
public void DecLife(int decLife)
{
Life -= decLife;
if ( Life <= 0 )
{
IsLive = false;
GameBombManager.AddBomb(Position, true, 1.0f);
}
}
protected virtual void MoveLogic(float elapsedTime)
{
}
protected virtual void ShootLogic(float elapsedTime)
{
}
public override void Update(float elapsedTime)
{
float diff = Life -