示例#1
0
        private void DeathListener(GameObject go)
        {
            var points = go as IPointsValue;

            if (points != null)
            {
                ScoreManager.AddScore(points);
            }

            var respawnable = go as IRespawnable;

            if (respawnable != null)
            {
                var newGo = Activator.CreateInstance(respawnable.GetType());

                do
                {
                    SpawnManager.Spawn((GameObject)newGo, LevelManager.Width, LevelManager.Height);
                } while (!(CollisionManager.CheckRespawnCollision((GameObject)newGo, LevelManager.Collidables)));

                if (points != null)
                {
                    ((IPointsValue)newGo).Points = ((IPointsValue)go).Points;
                }

                LevelManager.AddGameObject((GameObject)newGo);
            }
            LevelManager.Remove(go);
        }
示例#2
0
        private void DeathListener(GameObject go)
        {
            LevelManager.Remove(go);

            if (go is IRespawnable)
            {
                var newGo = Activator.CreateInstance(go.GetType());

                do
                {
                    SpawnManager.Spawn((GameObject)newGo, LevelManager.Width, LevelManager.Height);
                } while (!(CollisionManager.CheckRespawnCollision((GameObject)newGo, LevelManager.Collidables)));

                LevelManager.AddGameObject((GameObject)newGo);
            }
        }
示例#3
0
 // helper for constructor
 private void CheckValidStartPositions()
 {
     foreach (var c in LevelManager.Collidables)
     {
         // parses out player objects
         if (c is IPlayer)
         {
             continue;
         }
         // parses out level object
         if (!(c is IRenderable))
         {
             continue;
         }
         do
         {
             SpawnManager.Spawn((GameObject)c, LevelManager.Width, LevelManager.Height);
         } while (!(CollisionManager.CheckRespawnCollision((GameObject)c, LevelManager.Collidables)));
     }
 }