Example #1
0
 public void CreatePlayers(UpdatableObjects updatableObjects, DrawableObjects drawableObjects, bool isPlayer, int quantity)
 {
     for (int i = 0; i < quantity; i++)
     {
         CreatePlayer(updatableObjects, drawableObjects, isPlayer);
     }
 }
Example #2
0
 public void CreateFood(UpdatableObjects updatableObjects, DrawableObjects drawableObjects, int quantity)
 {
     for (int i = 0; i < quantity; i++)
     {
         Food food = new Food();
         RegisterObject(updatableObjects, drawableObjects, food);
     }
 }
Example #3
0
        public void CreatePlayer(UpdatableObjects updatableObjects, DrawableObjects drawableObjects, bool isPlayer)
        {
            Player newPlayer = new Player();

            newPlayer.Init();
            newPlayer.SetIsPlayer(isPlayer);
            RegisterObject(updatableObjects, drawableObjects, newPlayer);
        }
Example #4
0
 public void UnregisterObject(UpdatableObjects updatableObjects, DrawableObjects drawableObjects, IUpdatable updatable)
 {
     if (updatable is IUpdatable)
     {
         updatableObjects.Remove(updatable);
     }
     if (updatable is IDrawable)
     {
         drawableObjects.Remove(updatable as IDrawable);
     }
 }
Example #5
0
 public void RegisterObject(UpdatableObjects updatableObjects, DrawableObjects drawableObjects, IUpdatable updatable)
 {
     if (updatable is IUpdatable)
     {
         updatableObjects.Add(updatable);
     }
     if (updatable is IDrawable)
     {
         drawableObjects.Add(updatable as IDrawable);
     }
 }
Example #6
0
        public void RemoveCachedObjectsAndCreateNew(UpdatableObjects updatableObjects, DrawableObjects drawable)
        {
            foreach (IUpdatable updatable in objectsToRemove)
            {
                UnregisterObject(updatableObjects, drawable, updatable);
                if (updatable is Player)
                {
                    CreatePlayer(updatableObjects, drawable, false);
                }
                if (updatable is Food)
                {
                    RegisterObject(updatableObjects, drawable, new Food());
                }
            }

            objectsToRemove = new List <IUpdatable>();
        }