有了弹幕,有了主角,敌人当然就该上场了。
其实敌人和主角类似,也是一架飞机,不同点在于敌人的飞机是AI控制的,而玩家的飞机是自己控制而已~
public class GameEnemy : GameObject
{
protected int Life;
public bool IsLive;
protected int Type;
protected Vector2 Speed;
protected Vector2 Accel;
/// <summary>
/// 敌机的位图大小盒子
/// </summary>
public Box SourceBox
{
get
{
return new Box((int)Position.X, (int)Position.Y, EnemyWidth, EnemyHeight);
}
}
/// <summary>
/// 敌人发射子弹的类型
/// </summary>
public enum ShootType
{
None, // 不发射子弹
Line, // 直线子弹
Trace, // 追踪子弹
Fan_3, // 成扇形发射3颗子弹
Fan_5
}
protected ShootType mShootType;
protected int EnemyWidth;
protected int EnemyHeight;
protected int HalfEnemyWidth;
protected int HalfEnemyHeight;
public GameEnemy(Vector2 position, int life, int type, ShootType shootType)
{
this.IsLive = true;
base.Position = position;
this.Speed = new Vector2(0, 0);
this.Accel = new Vector2(0, 0);
base.BoxCollider = new Box(0, 0, Data.EnemyBoxColliderRectangle[type].Width, Data.EnemyBoxColliderRectangle[type].Height);
this.Life = life;
this.Type = type;
this.mShootType = shootType;
this.EnemyWidth = Data.EnemySourceRectangle[type].Width;
this.EnemyHeight = Data.EnemySourceRectangle[type].Height;
this.HalfEnemyWidth = this.EnemyWidth / 2;
this.HalfEnemyHeight = this.EnemyHeight / 2;
}
public void DecLife(int decLife)
{
Life -= decLife;
if ( Life <= 0 )
{
IsLive = false;
GameBombMana