public Animation(Entity e) : base(e) { Origin = new Vector2(TileSize.X / 2.0f, TileSize.Y / 2.0f); FrameTimer = new Timer(e); FrameTimer.Milliseconds = MillisecondsPerFrame; FrameTimer.LastEvent += AdvanceNextFrame; }
public Animation(Entity e, Texture2D texture, Vector2 tileSize, int framesPerSecond, string key) : base(e, texture) { TileSize = tileSize; FramesPerSecond = framesPerSecond; Key = key; Origin = new Vector2(TileSize.X / 2.0f, TileSize.Y / 2.0f); FrameTimer = new Timer(e); FrameTimer.Milliseconds = MillisecondsPerFrame; FrameTimer.LastEvent += AdvanceNextFrame; }
public EnemySpawner(EntityState es) : base(es) { Enemies = new List<Entity>(); Targets = new List<Entity>(); SoldierTimer = new Timer(this); SoldierTimer.Milliseconds = 4500; SoldierTimer.LastEvent += AddSoldier; SoldierTimer.Start(); Components.Add(SoldierTimer); HelicopterTimer = new Timer(this); HelicopterTimer.Milliseconds = 5000; HelicopterTimer.LastEvent += AddHelicopter; HelicopterTimer.Start(); Components.Add(HelicopterTimer); }
public Soldier(EntityState es) : base(es) { Points = 10; Body = new Body(this, Vector2.Zero); Components.Add(Body); _soldieranim = new Animation(this, es.GameRef.Game.Content.Load<Texture2D>(@"game/soldier"), new Vector2(5, 10), 4, "soldier"); Render = _soldieranim; Render.Flip = (_rand.RandomBool()) ? SpriteEffects.None : SpriteEffects.FlipHorizontally; Render.Layer = .5f; _soldieranim.Start(); Components.Add(Render); Body.Position.Y = 520 - _rand.Next(-10,10); Body.Position.X = (Render.Flip == SpriteEffects.None) ? es.GameRef.Viewport.Right + 10 : -10; Collision = new Collision(this); Components.Add(Collision); Physics = new Physics(this); Physics.Velocity.X = (Render.Flip == SpriteEffects.None) ? -.25f : .25f; Components.Add(Physics); Health = new Health(this, 1); Health.DiedEvent += OnDeath; Components.Add(Health); _attacktimer = new Timer(this); _attacktimer.Milliseconds = 500; _attacktimer.LastEvent += OnAttackTimer; Components.Add(_attacktimer); _ge = new GibEmitter(this); Components.Add(_ge); _hitsound = new Sound(this, StateRef.GameRef.Game.Content.Load<SoundEffect>(@"game/sounds/hit")); Components.Add(_hitsound); _attacksound = new Sound(this, StateRef.GameRef.Game.Content.Load<SoundEffect>(@"game/sounds/shoot")); _attacksound.Volume = .3f; Components.Add(_attacksound); }