public static void PlayerCastingBubbleShieldCommandReceived(int fromClient, Packet packet)
        {
            Vector3Int predictedCell  = packet.ReadVector3Int();
            int        sequenceNumber = packet.ReadInt();
            CastBubbleShieldCommand castBubbleShieldCommand = new CastBubbleShieldCommand(sequenceNumber, predictedCell);

            Server.clients[fromClient].serverMasterController.AccumulateCastingBubbleShieldRequestToBePlayedOnServerFromClient(castBubbleShieldCommand);
        }
Ejemplo n.º 2
0
        public static void CastBubbleShield(CastBubbleShieldCommand castBubbleShieldCommand)
        {
            using (Packet packet = new Packet((int)ClientPackets.castingBubbleShieldCommand))
            {
                packet.Write(castBubbleShieldCommand.predictedCell);
                packet.Write(castBubbleShieldCommand.sequenceNoForCastingBubbleShield);

                SendTCPData(packet);
            }
        }
Ejemplo n.º 3
0
        public override void ProcessEventsInputs(bool[] inputs, bool[] previousInputs)
        {
            if (!isInFlyingState)
            {
                if (itemToCast != null && itemToCast.castableItemType == EnumData.CastItemTypes.ClientProjectiles)
                {
                    if (itemToCast.itemCount > 0 && inputs[(int)EnumData.PosidannaInputs.UseItem])
                    {
                        SpawnClientProjectiles();
                    }
                    else if (itemToCast.itemCount <= 0 || (!inputs[(int)EnumData.PosidannaInputs.UseItem] && previousInputs[(int)EnumData.PosidannaInputs.UseItem] != inputs[(int)EnumData.PosidannaInputs.UseItem]))
                    {
                        ResetClientProjectilesVars();
                    }
                }
            }

            bool secondaryAttackReady = !waitingActionForSecondaryMove.Perform();

            if (!MultiplayerManager.instance.isServer && hasAuthority())
            {
                if (completedMotionToMovePoint)
                {
                    if (isInFlyingState)
                    {
                        if (inputs[(int)EnumData.PosidannaInputs.LandPlayer] && previousInputs[(int)EnumData.PosidannaInputs.LandPlayer] != inputs[(int)EnumData.PosidannaInputs.LandPlayer])
                        {
                            if (isInFlyingState)
                            {
                                //land here
                                flyingTickCountTemp = 0;

                                LandPlayerCommand landPlayerCommand = new LandPlayerCommand(GetLocalSequenceNo());
                                ClientSend.LandPlayer(landPlayerCommand);
                            }
                        }
                    }
                    else
                    {
                        if (inputs[(int)EnumData.PosidannaInputs.RespawnPlayer] && previousInputs[(int)EnumData.PosidannaInputs.RespawnPlayer] != inputs[(int)EnumData.PosidannaInputs.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 (itemToCast != null && itemToCast.itemCount > 0 && itemToCast.castableItemType == EnumData.CastItemTypes.SpawnnableItems)
                        {
                            if (inputs[(int)EnumData.PosidannaInputs.UseItem] && previousInputs[(int)EnumData.PosidannaInputs.UseItem] != inputs[(int)EnumData.PosidannaInputs.UseItem])
                            {
                                SpawnItem();
                            }
                        }
                    }
                }
                bubbleShieldAttackReady = !waitingActionForBubbleShieldItemMove.Perform();

                if (!isInFlyingState)
                {
                    if (inputs[(int)EnumData.PosidannaInputs.ShootTidalWave] && previousInputs[(int)EnumData.PosidannaInputs.ShootTidalWave] != inputs[(int)EnumData.PosidannaInputs.ShootTidalWave])
                    {
                        FireTidalWaveCommand fireTidalWaveCommand = new FireTidalWaveCommand(GetLocalSequenceNo(), GridManager.instance.grid.WorldToCell(actorTransform.position));
                        ClientSend.FireTidalWave(fireTidalWaveCommand);
                        isFiringServerProjectiles = true;
                        onCompletedMotionToPoint  = () => { isFiringServerProjectiles = false; onCompletedMotionToPoint = null; };
                    }
                    else if (inputs[(int)EnumData.PosidannaInputs.CastBubbleShield] && previousInputs[(int)EnumData.PosidannaInputs.CastBubbleShield] != inputs[(int)EnumData.PosidannaInputs.CastBubbleShield] && secondaryAttackReady)
                    {
                        waitingActionForSecondaryMove.ReInitialiseTimerToBegin(secondaryMoveAttackRateTickRate);
                        CastBubbleShieldCommand castBubbleShieldCommand = new CastBubbleShieldCommand(GetLocalSequenceNo(), GridManager.instance.grid.WorldToCell(actorTransform.position));
                        ClientSend.CastBubbleShield(castBubbleShieldCommand);

                        isFiringServerProjectiles = true;
                        onCompletedMotionToPoint  = () => { isFiringServerProjectiles = false; onCompletedMotionToPoint = null; };
                    }
                    else if (itemToCast != null && itemToCast.itemCount > 0 && itemToCast.castableItemType == EnumData.CastItemTypes.ServerProjectiles)
                    {
                        if (inputs[(int)EnumData.PosidannaInputs.UseItem] && previousInputs[(int)EnumData.PosidannaInputs.UseItem] != inputs[(int)EnumData.PosidannaInputs.UseItem])
                        {
                            SpawnServerProjectiles();
                        }
                    }
                }
            }
        }