public void CreatePlayers(UpdatableObjects updatableObjects, DrawableObjects drawableObjects, bool isPlayer, int quantity) { for (int i = 0; i < quantity; i++) { CreatePlayer(updatableObjects, drawableObjects, isPlayer); } }
public void CreateFood(UpdatableObjects updatableObjects, DrawableObjects drawableObjects, int quantity) { for (int i = 0; i < quantity; i++) { Food food = new Food(); RegisterObject(updatableObjects, drawableObjects, food); } }
public void CreatePlayer(UpdatableObjects updatableObjects, DrawableObjects drawableObjects, bool isPlayer) { Player newPlayer = new Player(); newPlayer.Init(); newPlayer.SetIsPlayer(isPlayer); RegisterObject(updatableObjects, drawableObjects, newPlayer); }
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); } }
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); } }
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>(); }
public void ChangePlayerAndReplaceBots(UpdatableObjects updatableObjects) { Player player = null; Player currentPlayer = updatableObjects.GetPlayer(); Random rand = new Random(); int r = rand.Next(0, updatableObjects.GetBots().Count); int i = 0; foreach (Player bot in updatableObjects.GetBots()) { if (i == r) { player = bot; } i++; } ReplaceBotAndChangeStatus(currentPlayer, player); }