Ejemplo n.º 1
0
        public void DivideAsteroid(Asteroid a, Shot s)
        {
            switch (a.size)
            {
                case Size.SMALL:
                    GameplayState.score += 100;
                    break;
                case Size.LARGE:
                    asteroids.Add(new Asteroid(smallAsteroidTexture, a.Position, new Vector2(
                        rand.Next(-(int)topSpeed, (int)topSpeed), rand.Next(-(int)topSpeed, (int)topSpeed)),
                        (float)(rand.NextDouble() * MathHelper.PiOver2), Size.SMALL));
                    asteroids.Add(new Asteroid(smallAsteroidTexture, a.Position, new Vector2(
                        rand.Next(-(int)topSpeed, (int)topSpeed), rand.Next(-(int)topSpeed, (int)topSpeed)),
                        (float)(rand.NextDouble() * MathHelper.PiOver2), Size.SMALL));
                    GameplayState.score += 200;
                    break;
            }

            asteroids.Remove(a);
            s.liveTime = 0;
            GameplayState.shots.Remove(s);
        }
Ejemplo n.º 2
0
        private void SplitAsteroid(Entity e = null)
        {
            if (!Health.Alive) return; // Stop it from adding new asteroids if it is already dead!

            Render.Scale *= 0.75f;

            var a = new Asteroid(Render.Texture, StateRef)
                {
                    Body = {Position = Body.Position},
                    Render = {Scale = Render.Scale},
                    Health = {HitPoints = Health.HitPoints}
                };

            foreach (var partner in Collision.Partners)
            {
                a.Collision.AddPartner(partner);
            }

            Physics.Velocity = new Vector2((float)Rand.NextDouble() * Rand.Next(-2, 3) + .5f,
                                   (float)Rand.NextDouble() * Rand.Next(-2, 3) + .5f);

            foreach (var t in Collision.Partners)
                t.Collision.AddPartner(a);

            AddEntity(a);
        }