public static void PlayerRemoveBoulderBoulderCommandReceived(int fromClient, Packet packet) { Vector3Int cellToRemoveBoulderFrom = packet.ReadVector3Int(); int sequenceNumber = packet.ReadInt(); RemoveBoulderCommand removeBoulderCommand = new RemoveBoulderCommand(sequenceNumber, cellToRemoveBoulderFrom); Server.clients[fromClient].serverMasterController.AccumulateRemoveBoulderCommandsToBePlayedOnServerFromClient(removeBoulderCommand); }
public static void RemoveBoulderCommand(RemoveBoulderCommand removeBoulderCommand) { using (Packet packet = new Packet((int)ClientPackets.playerRemoveBoulderCommand)) { packet.Write(removeBoulderCommand.removalCellPos); packet.Write(removeBoulderCommand.sequenceNumber); SendTCPData(packet); } }
public void AccumulateRemoveBoulderCommandsToBePlayedOnServerFromClient(RemoveBoulderCommand removeBoulderCommand) { if (removeBoulderCommand.sequenceNumber > playerSequenceNumberProcessed) { RemoveBoulderCommand dataPackage; if (removeBoulderCommandFromClientToServerDic.TryGetValue(removeBoulderCommand.sequenceNumber, out dataPackage)) { Debug.Log("<color=orange>AccumulateRemoveBoulderCommandsToBePlayedOnServerFromClient dataPackage already exists for sequence no. </color>" + removeBoulderCommand.sequenceNumber); } else { Debug.Log("<color=green>AccumulateRemoveBoulderCommandsToBePlayedOnServerFromClient Added successfully to processing buffer dic </color>" + removeBoulderCommand.sequenceNumber); removeBoulderCommandFromClientToServerDic.Add(removeBoulderCommand.sequenceNumber, removeBoulderCommand); } } else { Debug.Log("<color=red>AccumulateRemoveBoulderCommandsToBePlayedOnServerFromClient Already processed this sequence no </color>" + removeBoulderCommand.sequenceNumber); } }
public void ProcessEventsInputs(bool[] inputs, bool[] previousInputs) { if (isPushed) { return; } if (isPetrified) { return; } if (!isInFlyingState) { if (inputs[(int)EnumData.Inputs.Shoot]) { if (IsHeroAbleToFireProjectiles()) { if (!waitingActionForPrimaryMove.Perform()) { isFiringPrimaryProjectile = true; waitingActionForPrimaryMove.ReInitialiseTimerToBegin(primaryMoveAttackRateTickRate); } else { isFiringPrimaryProjectile = false; } } } else if (!inputs[(int)EnumData.Inputs.Shoot] && previousInputs[(int)EnumData.Inputs.Shoot] != inputs[(int)EnumData.Inputs.Shoot]) { isFiringPrimaryProjectile = false; waitingActionForPrimaryMove.ReInitialiseTimerToBegin(primaryMoveAttackRateTickRate); } if (isClient() && hasAuthority()) { if (completedMotionToMovePoint) { if (!inputs[(int)EnumData.Inputs.Push] && previousInputs[(int)EnumData.Inputs.Push] != inputs[(int)EnumData.Inputs.Push]) { Vector3Int cellPos = currentMovePointCellPosition + GridManager.instance.grid.WorldToCell(GridManager.instance.GetFacingDirectionOffsetVector3(Facing)); Actor actorToPush = GridManager.instance.GetActorOnPos(cellPos); if (actorToPush != null) { if (IsActorAbleToPush(Facing) && IsActorPushableInDirection(actorToPush, Facing)) { //Send reliable request of push to server here PushCommand pushCommand = new PushCommand(GetLocalSequenceNo(), (int)Facing, actorToPush.ownerId); ClientSend.PushPlayerCommand(pushCommand); } } } else if (inputs[(int)EnumData.Inputs.PlaceRemovalBoulder]) { Vector3Int cellToCheckFor = GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing)); if (!GridManager.instance.IsCellBlockedForBoulderPlacementAtPos(cellToCheckFor)) { //send command to server of placement PlaceBoulderCommand placeBoulderCommand = new PlaceBoulderCommand(GetLocalSequenceNo(), cellToCheckFor); ClientSend.PlaceBoulderCommand(placeBoulderCommand); } else if (GridManager.instance.HasTileAtCellPoint(cellToCheckFor, EnumData.TileType.Boulder) && !GridManager.instance.HasTileAtCellPoint(cellToCheckFor, EnumData.TileType.BoulderDisappearing)) { RemoveBoulderCommand removeBoulderCommand = new RemoveBoulderCommand(GetLocalSequenceNo(), cellToCheckFor); ClientSend.RemoveBoulderCommand(removeBoulderCommand); } } } } } }