Exemplo n.º 1
0
    public void RecieveAction(int lockStepTurn, int playerID, byte[] actionAsBytes)
    {
        //Debug.Log("Recieved Player " + playerID + "'s action for turn " + lockStepTurn + " on turn " + _lockStepTurnID);
        Action action = BinarySerialization.DeserializeObject <Action>(actionAsBytes);

        if (action == null)
        {
            Debug.Log("Sending action failed");
            //TODO: Error handle invalid actions recieve
        }
        else
        {
            _pendingActions.AddAction(action, Convert.ToInt32(playerID), _lockStepTurnID, lockStepTurn);

            //send confirmation
            if (_confirmedActions.IsConfirmedActionsEnabled())
            {
                if (Network.isServer)
                {
                    //we don't need an rpc call if we are the server
                    ConfirmActionServer(lockStepTurn, _localPlayerIndex, playerID);
                }
                else
                {
                    _networkInterface.CallConfirmActionServer(lockStepTurn, _localPlayerIndex, playerID);
                }
            }
        }
    }