Beispiel #1
0
    // 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");
        }
    }
Beispiel #2
0
    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();
            }
        }
    }