Exemplo n.º 1
0
        public Town(EntityState es)
            : base(es)
        {
            Body = new Body(this, Vector2.Zero, new Vector2(20,15));
            Components.Add(Body);

            TileRender = new TileRender(this, es.GameRef.Game.Content.Load<Texture2D>(@"game/town"), new Vector2(20, 15));
            Render = TileRender;
            Render.Scale = 6f;
            Render.Layer = 1f;
            Components.Add(Render);

            Body.Position = new Vector2(StateRef.GameRef.Viewport.Width/2 - Render.DrawRect.Width / 2, 450);
            DeadCityAnim = new Animation(this, es.GameRef.Game.Content.Load<Texture2D>(@"game/deadcity"), new Vector2(20, 15), 4, "deadtown");
            DeadCityAnim.Layer = 1f;
            DeadCityAnim.Scale = 6.0f;

            Health = new Health(this, 100);
            Health.HurtEvent += ChangeColor;

            TileRender.Index = 2;
            Components.Add(Health);

            Gun = new Gun(this);
            Components.Add(Gun);

            Cursor = new Cursor(StateRef, this);
            StateRef.AddEntity(Cursor);

            Collision = new Collision(this);
            Components.Add(Collision);

            _fire = new Sound(this, es.GameRef.Game.Content.Load<SoundEffect>(@"game/sounds/bombfire"));
            Components.Add(_fire);
        }
Exemplo n.º 2
0
        public Bomb(EntityState es, Vector2 position, float angle, float thrust)
            : base(es)
        {
            Body = new Body(this, position) {Angle = angle};
            Components.Add(Body);

            Physics = new Physics(this);
            Physics.Thrust(thrust);
            Components.Add(Physics);

            _explodeanim = new Animation(this, es.GameRef.Game.Content.Load<Texture2D>(@"game/explosion"),
                new Vector2(16,16), 30, "explode");
            _explodeanim.Layer = 0.2f;
            _explodeanim.Scale = 2.5f;
            _explodeanim.LastFrameEvent += Destroy;

            Render = new Render(this, es.GameRef.Game.Content.Load<Texture2D>(@"game/bomb"));
            Render.Layer = 0.1f;
            Render.Scale = 1.5f;
            Components.Add(Render);

            Collision = new Collision(this);
            Collision.CollideEvent += CollisionHandler;
            Components.Add(Collision);

            _ee = new ExplosionEmitter(this);
            Components.Add(_ee);

            _se = new SmokeEmitter(this);
            Components.Add(_se);

            _explodesound = new Sound(this, StateRef.GameRef.Game.Content.Load<SoundEffect>(@"game/sounds/explosion"));
            _explodesound.Volume = .5f;
            Components.Add(_explodesound);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public Helicopter(EntityState es)
            : base(es)
        {
            Points = 50;

            Body = new Body(this, Vector2.Zero);
            Components.Add(Body);

            _helicopteranim = new Animation(this, es.GameRef.Game.Content.Load<Texture2D>(@"game/helicopter"), new Vector2(20, 16), 30,
                                   "helicopter");
            Render = _helicopteranim;
            Render.Flip = (_rand.RandomBool()) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
            Render.Layer = .5f;
            _helicopteranim.Start();
            Components.Add(Render);

            Body.Position.Y = 300 - _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) ? -.4f : .4f;
            Components.Add(Physics);

            Health = new Health(this, 1);
            Health.DiedEvent += OnDeath;
            Components.Add(Health);

            _hge = new HeliGibEmitter(this);
            Components.Add(_hge);

            _explodeanim = new Animation(this, es.GameRef.Game.Content.Load<Texture2D>(@"game/explosion"),
                new Vector2(16, 16), 30, "explode");
            _explodeanim.Layer = 0.2f;
            _explodeanim.Scale = 1.5f;
            _explodeanim.LastFrameEvent += Destroy;
        }
Exemplo n.º 5
0
 public void ShowAnimation(string key)
 {
     if (CurrentAnimation == null || CurrentAnimation.Key != key)
         CurrentAnimation = Animations[key];
 }
Exemplo n.º 6
0
 public void ShowAnimation(Animation a)
 {
     if (CurrentAnimation == null || CurrentAnimation.Key != a.Key)
         CurrentAnimation = Animations[a.Key];
 }
Exemplo n.º 7
0
 public void RemoveAnimation(Animation a)
 {
     Animations.Remove(a.Key);
 }
Exemplo n.º 8
0
 public void AddAnimation(Animation a)
 {
     Animations.Add(a.Key, a);
 }