コード例 #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);
     }
 }
コード例 #3
0
        public override void ProcessEventsInputs(bool[] inputs, bool[] previousInputs)
        {
            if (!isInFlyingState)
            {
                if (inputs[(int)EnumData.MedusaInputs.Shoot])
                {
                    if (IsHeroAbleToFireProjectiles())
                    {
                        if (!waitingActionForPrimaryMove.Perform())
                        {
                            isFiringPrimaryProjectile = true;
                            waitingActionForPrimaryMove.ReInitialiseTimerToBegin(primaryMoveAttackRateTickRate);
                        }
                        else
                        {
                            isFiringPrimaryProjectile = false;
                        }
                    }
                }
                else if (!inputs[(int)EnumData.MedusaInputs.Shoot] && previousInputs[(int)EnumData.MedusaInputs.Shoot] != inputs[(int)EnumData.MedusaInputs.Shoot])
                {
                    isFiringPrimaryProjectile = false;
                    waitingActionForPrimaryMove.ReInitialiseTimerToEnd(primaryMoveAttackRateTickRate);
                }
                else if (itemToCast != null && itemToCast.castableItemType == EnumData.CastItemTypes.ClientProjectiles)
                {
                    if (itemToCast.itemCount > 0 && inputs[(int)EnumData.MedusaInputs.UseItem])
                    {
                        SpawnClientProjectiles();
                    }
                    else if (itemToCast.itemCount <= 0 || (!inputs[(int)EnumData.MedusaInputs.UseItem] && previousInputs[(int)EnumData.MedusaInputs.UseItem] != inputs[(int)EnumData.MedusaInputs.UseItem]))
                    {
                        ResetClientProjectilesVars();
                    }
                }
            }


            if (!MultiplayerManager.instance.isServer && hasAuthority())
            {
                if (completedMotionToMovePoint)
                {
                    if (isInFlyingState)
                    {
                        if (inputs[(int)EnumData.MedusaInputs.LandPlayer] && previousInputs[(int)EnumData.MedusaInputs.LandPlayer] != inputs[(int)EnumData.MedusaInputs.LandPlayer])
                        {
                            if (isInFlyingState)
                            {
                                //land here
                                flyingTickCountTemp = 0;
                                LandPlayerCommand landPlayerCommand = new LandPlayerCommand(GetLocalSequenceNo());
                                ClientSend.LandPlayer(landPlayerCommand);
                            }
                        }
                    }
                    else
                    {
                        if (inputs[(int)EnumData.MedusaInputs.RespawnPlayer] && previousInputs[(int)EnumData.MedusaInputs.RespawnPlayer] != inputs[(int)EnumData.MedusaInputs.RespawnPlayer])
                        {
                            Vector3Int cellToCheckFor = GridManager.instance.grid.WorldToCell(actorTransform.position);
                            if (IsPlayerSpawnable(cellToCheckFor))
                            {
                                //Respawn player command
                                RespawnPlayerCommand respawnPlayerCommand = new RespawnPlayerCommand(GetLocalSequenceNo());
                                ClientSend.RespawnPlayer(respawnPlayerCommand);
                            }
                            else
                            {
                                Debug.LogError("Invalid location to spawn player");
                            }
                        }
                        else if (inputs[(int)EnumData.MedusaInputs.Push] && previousInputs[(int)EnumData.MedusaInputs.Push] != inputs[(int)EnumData.MedusaInputs.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);
                                }
                            }

                            ClientEnemyManager clientEnemy = GridManager.instance.GetClientEnemyOnPos(cellPos);

                            if (clientEnemy != null)
                            {
                                if (IsClientEnemyPushable(Facing))
                                {
                                    PushCommand pushCommand = new PushCommand(GetLocalSequenceNo(), (int)Facing, clientEnemy.id);
                                    ClientSend.PushPlayerCommand(pushCommand);
                                }
                            }
                        }
                        else if (inputs[(int)EnumData.MedusaInputs.PlaceRemovalBoulder] && previousInputs[(int)EnumData.MedusaInputs.PlaceRemovalBoulder] != inputs[(int)EnumData.MedusaInputs.PlaceRemovalBoulder])
                        {
                            Vector3Int cellToCheckFor = GridManager.instance.grid.WorldToCell(actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(Facing));
                            if (!GridManager.instance.IsCellBlockedForSpawnObjectPlacementAtPos(cellToCheckFor) && !GridManager.instance.HasTileAtCellPoint(cellToCheckFor, EnumData.TileType.NoBoulder) && !GridManager.instance.HasTileAtCellPoint(cellToCheckFor, EnumData.GameObjectEnums.BoulderAppearing))
                            {
                                //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.NoBoulder) && !GridManager.instance.HasTileAtCellPoint(cellToCheckFor, EnumData.GameObjectEnums.BoulderDisappearing))
                            {
                                RemoveBoulderCommand removeBoulderCommand = new RemoveBoulderCommand(GetLocalSequenceNo(), cellToCheckFor);
                                ClientSend.RemoveBoulderCommand(removeBoulderCommand);
                            }
                        }
                        else if (itemToCast != null && itemToCast.itemCount > 0 && itemToCast.castableItemType == EnumData.CastItemTypes.SpawnnableItems)
                        {
                            if (inputs[(int)EnumData.MedusaInputs.UseItem] && previousInputs[(int)EnumData.MedusaInputs.UseItem] != inputs[(int)EnumData.MedusaInputs.UseItem])
                            {
                                SpawnItem();
                            }
                        }
                    }
                }

                bubbleShieldAttackReady = !waitingActionForBubbleShieldItemMove.Perform();

                if (!isInFlyingState)
                {
                    if (itemToCast != null && itemToCast.itemCount > 0 && itemToCast.castableItemType == EnumData.CastItemTypes.ServerProjectiles)
                    {
                        if (inputs[(int)EnumData.MedusaInputs.UseItem] && previousInputs[(int)EnumData.MedusaInputs.UseItem] != inputs[(int)EnumData.MedusaInputs.UseItem])
                        {
                            SpawnServerProjectiles();
                        }
                    }
                }
            }
        }