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); }
private void DoCycleStep() { totalTimeElapsed = clock.ElapsedTime.AsSeconds(); deltaTime = totalTimeElapsed - previousTimeElapsed; previousTimeElapsed = totalTimeElapsed; totalTimeBeforeUpdate += deltaTime; if (totalTimeBeforeUpdate >= Constants.TIME_UNTIL_UPDATE) { time = clock.ElapsedTime.AsMicroseconds(); clock.Restart(); time /= 800; window.Clear(Color.White); window.DispatchEvents(); updatableObjects.Update(direction, updatableObjects.GetFood(), updatableObjects.GetBots(), (float)time, updatableObjects.GetPlayer()); Fabric.Instance.RemoveCachedObjectsAndCreateNew(updatableObjects, drawableObjects); drawableObjects.Draw(window); window.Display(); } }