Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public Particle(int index, Vector2 position, int ttl, Emitter e)
            : base(e.Entity.StateRef)
        {
            Body = new Body(this, position, e.TileSize);
            Components.Add(Body);

            _tr = new TileRender(this, e.Texture, e.TileSize);
            Render = _tr;
            Components.Add(Render);
            Index = index;

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

            Emitter = e;
            TimeToLive = ttl;
            MaxTimeToLive = TimeToLive;
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 public ExplosionParticle(int index, Vector2 position, int ttl, Emitter e)
     : base(index,position,10,ttl,e)
 {
 }
Ejemplo n.º 5
0
 public FadeParticle(int index, Vector2 position, int fadeage, int ttl, Emitter e)
     : base(index, position, ttl, e)
 {
     FadeAge = fadeage;
 }