// when all units have either do nothing or are unable to do something public void LaunchTurn() { Debug.Log("new turn"); if (allPlayingObjects.Count > 0) { foreach (var playingObject in allPlayingObjects) { playingObject.mainObject.SetBudget(playingObject.mainObject.GetBudget() + playingObject.mainObject.GetIncrement()); playingObject.shouldPlay = true; } currentPlayingObject = allPlayingObjects [0]; currentPlayingObject.BeginTurn(); } else { Debug.Log("no unit"); } }
private void OnTurnEnded() { int previouslyPlayingObjectIndex = allPlayingObjects.FindIndex(x => currentPlayingObject == x); int nbObjects = allPlayingObjects.Count; if (previouslyPlayingObjectIndex == nbObjects - 1 && ShouldLaunchTurn()) { //begin the next turn LaunchTurn(); } else { currentPlayingObject = allPlayingObjects [(previouslyPlayingObjectIndex + 1) % nbObjects]; if (currentPlayingObject.shouldPlay) { currentPlayingObject.BeginTurn(); } else { OnTurnEnded(); } } }