예제 #1
0
    public static void PlayerPlaceBoulderBoulderCommandReceived(int fromClient, Packet packet)
    {
        Vector3Int cellPosToSpawnBoulder = packet.ReadVector3Int();
        int        sequenceNumber        = packet.ReadInt();

        PlaceBoulderCommand placeBoulderCommand = new PlaceBoulderCommand(sequenceNumber, cellPosToSpawnBoulder);

        Server.clients[fromClient].serverMasterController.AccumulatePlaceBoulderCommandsToBePlayedOnServerFromClient(placeBoulderCommand);
    }
예제 #2
0
 public static void PlaceBoulderCommand(PlaceBoulderCommand placeBoulderCommand)
 {
     using (Packet packet = new Packet((int)ClientPackets.playerPlaceBoulderCommand))
     {
         packet.Write(placeBoulderCommand.boulderCellPos);
         packet.Write(placeBoulderCommand.sequenceNumber);
         SendTCPData(packet);
     }
 }
 public void AccumulatePlaceBoulderCommandsToBePlayedOnServerFromClient(PlaceBoulderCommand placeBoulderCommand)
 {
     if (placeBoulderCommand.sequenceNumber > playerSequenceNumberProcessed)
     {
         PlaceBoulderCommand dataPackage;
         if (placeBoulderCommandFromClientToServerDic.TryGetValue(placeBoulderCommand.sequenceNumber, out dataPackage))
         {
             Debug.Log("<color=orange>AccumulatePlaceBoulderCommandsToBePlayedOnServerFromClient dataPackage already exists for sequence no. </color>" + placeBoulderCommand.sequenceNumber);
         }
         else
         {
             Debug.Log("<color=green>AccumulatePlaceBoulderCommandsToBePlayedOnServerFromClient Added successfully to processing buffer dic </color>" + placeBoulderCommand.sequenceNumber);
             placeBoulderCommandFromClientToServerDic.Add(placeBoulderCommand.sequenceNumber, placeBoulderCommand);
         }
     }
     else
     {
         Debug.Log("<color=red>AccumulatePlaceBoulderCommandsToBePlayedOnServerFromClient Already processed this sequence no </color>" + placeBoulderCommand.sequenceNumber);
     }
 }
예제 #4
0
    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);
                        }
                    }
                }
            }
        }
    }