Exemple #1
0
    IEnumerator RunTurns()
    {
        //Skip first frame to give time to register
        yield return(new WaitForSeconds(0.1f));

        SortListByTime();

        Current = GetNext();

        while (Current != null && !GameEndListener.GameEnded)
        {
            OnListUpdated.AttemptCall(Turnables);
            Current.TurnTimeUpdated += OnTurnPreview;
            Current.StartTurn();
            OnStartTurn.AttemptCall(Current);

            yield return(StartCoroutine(WaitForTurn(Current)));

            if (Current != null && !Current.Equals(null))
            {
                Current.TurnTimeUpdated -= OnTurnPreview;
                Current.EndTurn();
            }

            Current = null;

            currentTurn++;

            GlobalTurn(currentTurn);

            yield return(new WaitForSeconds(0.5f));

            NormalizeList();
            SortListByTime();

            Current = GetNext();

            forceNext = false;
        }
    }