public Town(EntityState es, XmlParser xp) : base(es, "Town") { Body = new Body(this, "Body"); AddComponent(Body); TileRender = new TileRender(this, "TileRender"); AddComponent(TileRender); DeadCityAnim = new Animation(this, "DeadCityAnim"); AddComponent(DeadCityAnim); Collision = new Collision(this, "Collision"); AddComponent(Collision); Health = new Health(this, "Health"); AddComponent(Health); Gun = new Gun(this, "Gun"); AddComponent(Gun); Targets = new Targets(this, "Targets"); AddComponent(Targets); _firebombsound = new Sound(this, "FireBombSound"); AddComponent(_firebombsound); _firekey = new DoubleInput(this, "FireKey", Keys.Enter, Buttons.A, PlayerIndex.One); AddComponent(_firekey); _debugkey = new DoubleInput(this, "DebugKey", Keys.Tab, Buttons.B, PlayerIndex.One); AddComponent(_debugkey); ParseXml(xp, "GameState->" + Name); //Add our custom data here. Body.Position.X = StateRef.GameRef.Viewport.Width / 2 - TileRender.DrawRect.Width / 2; //Set our rotation origins TileRender.Origin = new Vector2(TileRender.TileSize.X / 2f, TileRender.TileSize.Y / 2f); DeadCityAnim.Origin = TileRender.Origin; //TODO: Health.Hurtevent changes color Cursor = new Cursor(es, this, xp); es.AddEntity(Cursor); }
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 Helicopter(EntityState es, string name, XmlParser xp) : base(es, name) { Name = name + ID; _xp = xp; Body = new Body(this, "Body"); AddComponent(Body); Physics = new Physics(this, "Physics"); AddComponent(Physics); Animation = new Animation(this, "Animation"); AddComponent(Animation); Collision = new Collision(this, "Collision"); AddComponent(Collision); Health = new Health(this, "Health"); Health.DiedEvent += OnDeath; AddComponent(Health); _ge = new GibEmitter(this, "GibEmitter"); AddComponent(_ge); _explodeanim = new Animation(this, "ExplodeAnim"); _explodeanim.LastFrameEvent += Destroy; AddComponent(_explodeanim); _hitsound = new Sound(this, "HitSound"); AddComponent(_hitsound); string path = es.Name + "->Helicopter"; ParseXml(xp, path); Animation.Flip = (_rand.RandomBool()) ? SpriteEffects.None : SpriteEffects.FlipHorizontally; Physics.Velocity.X = (Animation.Flip == SpriteEffects.None) ? -.4f : .4f; Body.Position.Y = 300 - _rand.Next(-10, 10); Body.Position.X = (Animation.Flip == SpriteEffects.None) ? es.GameRef.Viewport.Right + 10 : -10; }
public Bomb(EntityState es, string name, XmlParser xp) : base(es, name) { string path = es.Name + "->" + "Bomb"; Name = Name + ID; Body = new Body(this, "Body"); AddComponent(Body); Physics = new Physics(this, "Physics"); AddComponent(Physics); Collision = new Collision(this, "Collision"); Collision.CollideEvent += CollisionHandler; AddComponent(Collision); ImageRender = new ImageRender(this, "ImageRender"); AddComponent(ImageRender); _explodeanim = new Animation(this, "ExplodeAnim"); _explodeanim.LastFrameEvent += Destroy; AddComponent(_explodeanim); _explodesound = new Sound(this, "ExplodeSound"); AddComponent(_explodesound); _explosionemitter = new ExplosionEmitter(this); AddComponent(_explosionemitter); _smokeemitter = new SmokeEmitter(this); AddComponent(_smokeemitter); ParseXml(xp, path); //TODO: Hook up Collision.CollideEvent to a handler _explodeanim.Origin = new Vector2(_explodeanim.TileSize.X / 2.0f, _explodeanim.TileSize.Y / 2.0f); ImageRender.Origin = new Vector2(ImageRender.Texture.Width / 2f, ImageRender.Texture.Height / 2f); }