private void SendPendingAction() { Action action = null; if (actionsToSend.Count > 0) { action = actionsToSend.Dequeue(); } //if no action for this turn, send the NoAction action if (action == null) { action = new NoAction(); } //action.NetworkAverage = Network.GetLastPing (Network.connections[0/*host player*/]); if (LockStepTurnID > FirstLockStepTurnID + 1) { action.NetworkAverage = confirmedActions.GetPriorTime(); } else { action.NetworkAverage = initialLockStepTurnLength; } action.RuntimeAverage = Convert.ToInt32(currentGameFrameRuntime); //clear the current runtime average currentGameFrameRuntime = 0; //add action to our own list of actions to process pendingActions.AddAction(action, Convert.ToInt32(Network.player.ToString()), LockStepTurnID, LockStepTurnID); //start the confirmed action timer for network average confirmedActions.StartTimer(); //confirm our own action confirmedActions.ConfirmAction(Convert.ToInt32(Network.player.ToString()), LockStepTurnID, LockStepTurnID); //send action to all other players //nv.RPC("RecieveAction", RPCMode.Others, LockStepTurnID, Network.player.ToString(), BinarySerialization.SerializeObjectToByteArray(action)); RecieveActionMessage recieveActionMessage = new RecieveActionMessage(); recieveActionMessage.LockStepTurnID = LockStepTurnID; recieveActionMessage.value = BinarySerialization.SerializeObjectToByteArray(action); manager.client.Send(LockstepMsgType.RecieveAction, recieveActionMessage); UnityEngine.Debug.Log("Sent " + (action.GetType().Name) + " action for turn " + LockStepTurnID); }
private void SendPendingAction() { if (_isDedicateServer) { return; } Action action = null; if (_actionsToSend.Count > 0) { action = _actionsToSend.Dequeue(); } //if no action for this turn, send the NoAction action if (action == null) { action = new NoAction(); } //action.networkLagTime = Network.GetLastPing (Network.connections[0/*host player*/]); if (_lockStepTurnID > firstLockStepTurnID + 1) { action.networkLagTime = _confirmedActions.GetPriorTime(); } else { action.networkLagTime = _initialLockStepTurnLength; } action.gameLagTime = Convert.ToInt32(_currentGameFrameRuntime); //clear the current runtime average _currentGameFrameRuntime = 0; //add action to our own list of actions to process // _pendingActions.AddAction(action, Convert.ToInt32(_localPlayerIndex), _lockStepTurnID, _lockStepTurnID); //start the confirmed action timer for network average _confirmedActions.StartTimer(); //confirm our own action _confirmedActions.ConfirmAction(_localPlayerIndex, _lockStepTurnID, _lockStepTurnID); // _confirmedActions.AddCurrentConfirmed(Network.player); //send action to all other players _networkInterface.CallSendAction(_lockStepTurnID, _localPlayerIndex, BinarySerialization.SerializeObjectToByteArray(action)); // Debug.Log("Sent " + (action.GetType().Name) + " action for turn " + _lockStepTurnID); }