Example #1
0
    public void ChangePlayerTurnPosition(int newIndex)
    {
        List <Turn> turnList = TurnStack.ToList();

        Turn playerTurn = GetPlayerTurn();

        turnList.Remove(playerTurn);

        Stack <Turn> newTurnStack = new Stack <Turn>();

        for (int i = 0; i < newIndex; i++)
        {
            Turn turn = turnList[i];
            if (turn.IsPlayerTurn())
            {
                continue;
            }

            newTurnStack.Push(turn);
        }

        newTurnStack.Push(playerTurn);

        for (int i = newIndex; i < turnList.Count; i++)
        {
            Turn turn = turnList[i];
            if (turn.IsPlayerTurn())
            {
                continue;
            }

            newTurnStack.Push(turn);
        }

        TurnStack = new Stack <Turn>(newTurnStack);
        energyManager.UpdateProjectedEnergyGain(newIndex);
        OnTurnStackUpdate(TurnStack.ToList <Turn>());
    }