Exemplo n.º 1
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.º 2
0
        public Asteroid(Texture2D asteroidtexture, EntityState es)
            : base(es)
        {
            Body = new Body(this, new Vector2(Rand.Next(0, es.GameRef.Viewport.Right), Rand.Next(0, es.GameRef.Viewport.Bottom)), new Vector2(asteroidtexture.Width, asteroidtexture.Height));
            Components.Add(Body);

            Render = new Render(this, asteroidtexture) { Scale = .75f };
            Components.Add(Render);

            Physics = new Physics(this) { Velocity = new Vector2((float)Rand.NextDouble() * Rand.Next(-2, 3) + .5f, (float)Rand.NextDouble() * Rand.Next(-2, 3) + .5f), Drag = 1.0f };
            Components.Add(Physics);

            Health = new Health(this, 3);
            Components.Add(Health);
            Health.HurtEvent += EmitEventHandler;
            Health.HurtEvent += SplitAsteroid;
            Health.DiedEvent += Destroy;

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

            _emitter = new HurtEmitter(this, StateRef.GameRef.Game.Content.Load<Texture2D>(@"particles/thrustparticle"));
            Components.Add(_emitter);

            _hitemitter = new AsteroidHitEmitter(this, StateRef.GameRef.Game.Content.Load<Texture2D>(@"particles/thrustparticle"));
            Components.Add(_hitemitter);
        }
Exemplo n.º 3
0
        public Image(EntityState es, Texture2D texture, Vector2 position)
            : base(es)
        {
            Body = new Body(this, position, new Vector2(texture.Width, texture.Height));
            Components.Add(Body);

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

            Render = new Render(this, texture);
            Components.Add(Render);
        }
Exemplo n.º 4
0
        public Ship(Texture2D shiptexture, Texture2D bullettexture, EntityState es)
            : base(es)
        {
            Body = new Body(this, new Vector2(es.GameRef.Viewport.Width / 2.0f, es.GameRef.Viewport.Height / 2.0f),
                            new Vector2(shiptexture.Width, shiptexture.Height));
            Components.Add(Body);

            Physics = new Physics(this) { Drag = 0.9f };
            Components.Add(Physics);

            Render = new Render(this, shiptexture) { Scale = .5f };
            Components.Add(Render);

            Weapon = new Gun(this, bullettexture);
            Components.Add(Weapon);

            Health = new Health(this, 5);
            Health.DiedEvent += Destroy;
            Health.DiedEvent += EmitEventHandler;
            Components.Add(Health);

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

            ThrustEmitter = new ThrustEmitter(this, StateRef.GameRef.Game.Content.Load<Texture2D>(@"particles/thrustparticle"));
            Components.Add(ThrustEmitter);

            DeathEmitter = new DeathEmitter(this, StateRef.GameRef.Game.Content.Load<Texture2D>(@"particles/shipdeathparticle123"));
            Components.Add(DeathEmitter);

            _attackkey = new KeyboardInput(Keys.Enter);
            _upkey = new KeyboardInput(Keys.W);
            _downkey = new KeyboardInput(Keys.S);
            _leftkey = new KeyboardInput(Keys.A);
            _rightkey = new KeyboardInput(Keys.D);
            _debugkey = new KeyboardInput(Keys.L);
        }
Exemplo n.º 5
0
        public Cursor(EntityState es, Town town)
            : base(es)
        {
            Town = town;

            _aimleftkey = new DoubleInput(Keys.A, Buttons.DPadLeft, PlayerIndex.One);
            _aimrightkey = new DoubleInput(Keys.D, Buttons.DPadRight, PlayerIndex.One);
            _quickaimkey = new DoubleInput(Keys.LeftShift, Buttons.RightShoulder, PlayerIndex.One);

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

            Render = new Render(this, StateRef.GameRef.Game.Content.Load<Texture2D>(@"game/cursor"))
                {
                    Layer = 1f,
                    Scale = 6f
                };
            Components.Add(Render);

            Body = new Body(this, town.Body.Position + (town.Render.Origin - Vector2.UnitY * 40 - Render.Origin) * Render.Scale, Vector2.One * 5);
            Components.Add(Body);

            Town.Health.DiedEvent += Destroy;
        }