Example #1
0
        public void SpawnShip()
        {
            var map  = Match.GetInstance().Map;
            var ship = new Ship(PlayerNumber)
            {
                X = map.Width / 2 - 1,
                Y = PlayerNumber == 1 ? map.Height - 3 : 2
            };

            ship.OnDestroyedEvent += OnShipKilled;

            try
            {
                if (Match.GetInstance().GetRoundNumber() > 0)
                {
                    Lives--;
                }
                map.AddEntity(ship);
                Ship = ship;
            }
            catch (CollisionException e)
            {
                if (e.Entity.GetType() == typeof(Missile))
                {
                    ((Missile)e.Entity).ScoreKill(ship);
                    e.Entity.Destroy();
                    ship.Destroy();
                }
                else if (e.Entity.GetType() == typeof(Alien) || e.Entity.GetType() == typeof(Bullet))
                {
                    e.Entity.Destroy();
                    ship.Destroy();
                }
            }
        }
Example #2
0
 protected Map GetMap()
 {
     return(Match.GetInstance().Map);
 }
Example #3
0
 protected Player GetPlayer()
 {
     return(Match.GetInstance().GetPlayer(PlayerNumber));
 }