Пример #1
0
        public override void OnDestroy()
        {
            float subsize = Size / 2;

            if (subsize > MinimumSize)
            {
                Vector2 ecc = Fmath.Rotate(new Vector2(Size / 4, Size / 4), Angle);

                // Hack to pull the pending forces out of the collision system and applying them immediately.
                Velocity += (CollisionBody.Force / 60f) * CollisionBody.InvMass;

                for (int i = 0; i < 4; i++)
                {
                    ecc = Fmath.RotatePos(ecc);

                    Asteroid subasteroid = new Asteroid(
                        Position + ecc,
                        Velocity + ecc * EjectionVelocity / Size,
                        subsize,
                        Angle,
                        AngularVelocity + EjectionRotation - Fmath.RandF(2 * EjectionRotation)
                        );

                    Context.AddEntity(subasteroid);
                }
            }
            else
            {
                Context.AddEvent(new Explosion(Position, Size * 1.5f, 1f, Color.White));
            }

            base.OnDestroy();
        }
Пример #2
0
 private Ship NewPlayer(Color color)
 {
     return(new Ship(
                Fmath.RandomVector(Boundary / 2) + (Boundary / 4),
                Fmath.CosSin(Fmath.RandAngle(), Fmath.RandF(50)),
                color,
                Fmath.RandAngle(),
                Fmath.RandF(1f)
                ));
 }
Пример #3
0
 private Asteroid NewAsteroid(float scale)
 {
     return(new Asteroid(
                Fmath.RandomVector(Boundary),
                Fmath.CosSin(Fmath.RandAngle(), Fmath.RandF(50)),
                scale / 2 + Fmath.RandF(scale / 2),
                Fmath.RandAngle(),
                Fmath.RandF(1f)
                ));
 }