Exemplo n.º 1
0
 public void ReleaseUserControl()
 {
     foreach (var obj in OwnedObjects)
     {
         InputReceiverSwitch.SetReceiveInput(obj.gameObject, false);
     }
 }
Exemplo n.º 2
0
    public void TransferControlToNextPlayer()
    {
        if (PauseHealthChangesDuringTurn)
        {
            HealthComponent.PauseChangesForAll();
        }

        if (TurningPlayer.Entity != null)
        {
            TurningPlayer.Entity.ReleaseUserControl();
        }

        Player firstPickedPlayer = null;
        Player currentPlayer;
        bool   firstRound = true;

        do
        {
            currentPlayer = TurningPlayer.Entity = GetNextPlayerInTurnQueue(out TurningPlayer.TurnIndex);

            if (currentPlayer == null)
            {
                return;
            }

            if (firstPickedPlayer == null)
            {
                firstPickedPlayer = currentPlayer;
            }
            else
            {
                firstRound = false;
            }

            TurningUnitInfo turningUnit;

            if (!turningUnitsByPlayer.TryGetValue(currentPlayer, out turningUnit))
            {
                turningUnit = new TurningUnitInfo();
                turningUnitsByPlayer [currentPlayer] = turningUnit;
            }

            var currentUnit = turningUnit.Entity = GetNextUnitInTurnQueue(turningUnit, out turningUnit.TurnIndex);

            if (currentUnit != null)
            {
                InputReceiverSwitch.SetReceiveInput(currentUnit.gameObject, true);
                currentUnit.BroadcastMessage(OnPrepareToStartTurnMessagName, SendMessageOptions.DontRequireReceiver);

                return;
            }
        } while (firstRound || currentPlayer != firstPickedPlayer);

        // If this line was reached then there were no "turnable" units.
    }