public Soldier(EntityState es, string name, XmlParser xp) : base(es, name) { Name = name + ID; Body = new Body(this, "Body"); AddComponent(Body); Physics = new Physics(this, "Physics"); AddComponent(Physics); Animation = new Animation(this, "Animation"); Animation.Start(); AddComponent(Animation); Collision = new Collision(this, "Collision"); AddComponent(Collision); Health = new Health(this, "Health"); Health.DiedEvent += OnDeath; AddComponent(Health); _attacktimer = new Timer(this, "AttackTimer"); _attacktimer.LastEvent += OnAttackTimer; AddComponent(_attacktimer); _attacksound = new Sound(this, "AttackSound"); AddComponent(_attacksound); _hitsound = new Sound(this, "HitSound"); AddComponent(_hitsound); _ge = new GibEmitter(this, "GibEmitter"); AddComponent(_ge); string path = es.Name + "->" + "Soldier"; ParseXml(xp, path); Animation.Flip = (_rand.RandomBool()) ? SpriteEffects.None : SpriteEffects.FlipHorizontally; Physics.Velocity.X = (Animation.Flip == SpriteEffects.None) ? -_speed : _speed; Body.Position.X = (Animation.Flip == SpriteEffects.None) ? es.GameRef.Viewport.Right + 10 : -10; Body.Position.Y = 520 - _rand.Next(-10, 10); //TODO: Set origin //TODO: Set Health.DiedEvent to emit blood particles and Destroy }
public EnemySpawner(EntityState es, XmlParser xp) : base(es, "EnemySpawner") { Enemies = new List<Entity>(); Targets = new List<Entity>(); _xp = xp; SoldierTimer = new Timer(this, "SoldierTimer"); SoldierTimer.LastEvent += AddSoldier; AddComponent(SoldierTimer); HelicopterTimer = new Timer(this, "HelicopterTimer"); HelicopterTimer.LastEvent += AddHelicopter; AddComponent(HelicopterTimer); ParseXml(xp, "GameState->" + Name); }