Example #1
0
 public void CharacterDrawInterrupt()
 {
     logger.Info("[Tmp]Interrupt");
     PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, entity.gamePlay);
     RelatedCharState.InterruptAction();
     RelatedCharState.ForceFinishGrenadeThrow();
     Owner.AudioController().StopPullBoltAudio();
 }
Example #2
0
 public void StartAutoMove()
 {
     if (null != _playerMove)
     {
         _playerMove.IsAutoRun = true;
     }
     if (null != _gamePlay)
     {
         PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, _gamePlay);
     }
 }
 public void CharacterInterrupt()
 {
     RelatedCharState.State.InterruptAction();
     RelatedCharState.State.InterruptSwitchWeapon();
     PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, entity.gamePlay);
     RelatedCharState.State.ForceBreakSpecialReload(null);
     RelatedCharState.State.ForceFinishGrenadeThrow();
     if (entity.hasThrowingAction)
     {
         RelatedThrowAction.ActionInfo.ClearState();
     }
 }
Example #4
0
        private void PretreatCmd(PlayerEntity player, IUserCmd cmd)
        {
            var actionState      = player.stateInterface.State.GetActionState();
            var curPostureState  = player.stateInterface.State.GetCurrentPostureState();
            var nextPostureState = player.stateInterface.State.GetNextPostureState();

            if (cmd.MoveHorizontal != 0 ||
                cmd.MoveVertical != 0)
            {
                player.playerMove.InterruptAutoRun();
            }
            else if ((cmd.IsPeekRight || cmd.IsPeekLeft) &&
                     curPostureState != PostureInConfig.Prone &&
                     curPostureState != PostureInConfig.Swim &&
                     curPostureState != PostureInConfig.Dive)
            {
                player.playerMove.InterruptAutoRun();
            }
            else if (curPostureState != nextPostureState &&
                     nextPostureState != PostureInConfig.Dive &&
                     nextPostureState != PostureInConfig.Swim &&
                     nextPostureState != PostureInConfig.Land &&
                     nextPostureState != PostureInConfig.Jump &&
                     nextPostureState != PostureInConfig.Stand)
            {
                player.playerMove.InterruptAutoRun();
            }
            else
            {
                switch (actionState)
                {
                case ActionInConfig.MeleeAttack:
                case ActionInConfig.SwitchWeapon:
                case ActionInConfig.PickUp:
                case ActionInConfig.Reload:
                case ActionInConfig.SpecialReload:
                    player.playerMove.InterruptAutoRun();
                    break;

                default: break;
                }
            }

            if (cmd.IsSwitchAutoRun)
            {
                player.playerMove.IsAutoRun = !player.playerMove.IsAutoRun;
                if (player.playerMove.IsAutoRun)
                {
                    PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, player.gamePlay);
                }
            }
        }
Example #5
0
 public void CharacterState_Interrupt()
 {
     Core.CharacterState.ICharacterState state = entity.stateInterface.State;
     state.InterruptAction();
     state.InterruptSwitchWeapon();
     PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, entity.gamePlay);
     state.ForceBreakSpecialReload(null);
     state.ForceFinishGrenadeThrow();
     if (entity.hasThrowingAction)
     {
         entity.throwingAction.ActionInfo.ClearState();
     }
 }
Example #6
0
        private void handleToGround(string from, string to, ServerRoom room, FreeData fd)
        {
            PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
            FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, ChickenConstant.BagGround);

            SimpleProto sp = FreePool.Allocate();

            sp.Key = FreeMessageConstant.PlaySound;
            sp.Ks.Add(2);
            sp.Ins.Add(5017);
            sp.Bs.Add(false);
            FreeMessageSender.SendMessage(fd.Player, sp);
        }
Example #7
0
        private void UpdatePlayerState(PlayerEntity player)
        {
            // 窒息状态
            var oxygen = player.oxygenEnergyInterface.Oxygen;

            if (oxygen.InDivingDeffState && !PlayerStateUtil.HasPlayerState(EPlayerGameState.DivingChok, player.gamePlay))
            {
                PlayerStateUtil.AddPlayerState(EPlayerGameState.DivingChok, player.gamePlay);
            }
            else if (PlayerStateUtil.HasPlayerState(EPlayerGameState.DivingChok, player.gamePlay))
            {
                PlayerStateUtil.RemoveGameState(EPlayerGameState.DivingChok, player.gamePlay);
            }
        }
Example #8
0
        public void ExecuteUserCmd(IPlayerUserCmdGetter getter, IUserCmd cmd)
        {
            var player = (PlayerEntity)getter.OwnerEntity;

            CheckPlayerLifeState(player);
            InterruptAutoRun(player, cmd);
            if (cmd.IsSwitchAutoRun && CanAutoRun(player))
            {
                player.playerMove.IsAutoRun = !player.playerMove.IsAutoRun;
                if (player.playerMove.IsAutoRun)
                {
                    player.stateInterface.State.InterruptAction();
                    PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, player.gamePlay);
                }
            }
        }
        public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd)
        {
            var player = (PlayerEntity)owner.OwnerEntity;

            CheckPlayerLifeState(player);
            InterruptAutoRun(player, cmd);

            if (cmd.IsSwitchAutoRun)
            {
                player.playerMove.IsAutoRun = !player.playerMove.IsAutoRun;
                if (player.playerMove.IsAutoRun)
                {
                    PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, player.gamePlay);
                }
            }
        }
Example #10
0
        public void StartUseItem(IEventArgs args, FreeData fd, ItemPosition ip, int sing, int sound)
        {
            PlayerStateUtil.RemoveGameState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
            fd.Player.autoMoveInterface.PlayerAutoMove.StopAutoMove();

            SkillTimeTrigger trigger = (SkillTimeTrigger)itemSkill.trigger;

            trigger.SetTime(sing * 1000);
            trigger.Reset();

            itemSkill.inter       = null;
            itemSkill.interAction = null;
            if (ip.key.GetClickSkill() != null)
            {
                PlayerActionSkill skill = ip.key.GetClickSkill() as PlayerActionSkill;
                if (skill != null && skill.inter != null)
                {
                    itemSkill.inter       = skill.inter;
                    itemSkill.interAction = skill.interAction;
                }
            }

            UsingItemAction interAction = (UsingItemAction)trigger.interAction;

            interAction.fd = fd;
            interAction.ip = ip;

            UsingItemAction action = (UsingItemAction)itemSkill.GetEffect();

            action.fd = fd;
            action.ip = ip;

            StartCounter(args, sing, fd, true);
            startUse = true;
            SetCurrentItem(ip, (ISkillArgs)args);
            SimpleProto data = FreePool.Allocate();

            data.Key = FreeMessageConstant.PlaySound;
            data.Ks.Add(0);
            data.Ins.Add(FreeUtil.ReplaceInt("{item.itemId}", args));
            fd.Player.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, data);
            PlayerStateUtil.AddPlayerState(EPlayerGameState.UseItem, fd.Player.gamePlay);
        }
Example #11
0
 public static void ShowSplitUI(ServerRoom room, FreeData fd, string key)
 {
     // 分拆道具
     if (key.StartsWith(ChickenConstant.BagDefault))
     {
         ItemPosition ip        = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
         FreeItemInfo info      = FreeItemConfig.GetItemInfo(ip.key.GetKey());
         var          stackable = true;
         if (info.cat == (int)ECategory.Weapon)
         {
             WeaponResConfigItem item = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(info.id);
             if (item.Type != (int)EWeaponType_Config.ThrowWeapon)
             {
                 stackable = false;
             }
         }
         else
         {
             if (info.stack <= 1)
             {
                 stackable = false;
             }
         }
         SimpleProto data = FreePool.Allocate();
         if (!stackable || ip.count <= 1)
         {
             data.Key = FreeMessageConstant.ChickenTip;
             data.Ss.Add("word78");
             FreeMessageSender.SendMessage(fd.Player, data);
             return;
         }
         data.Key = FreeMessageConstant.ShowSplitUI;
         data.Ins.Add(info.cat);
         data.Ins.Add(info.id);
         data.Ins.Add(ip.count);
         data.Ss.Add(key);
         data.Ss.Add(ip.GetKey().GetName());
         FreeMessageSender.SendMessage(fd.Player, data);
         PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
     }
 }
        public override void DoAction(IEventArgs args)
        {
            EPlayerGameState uiState = (EPlayerGameState)FreeUtil.ReplaceInt(state, args);
            FreeData         p       = GetPlayer(args);

            if (p != null)
            {
                if (remove)
                {
                    PlayerStateUtil.RemoveGameState(uiState, p.Player.gamePlay);
                }
                else
                {
                    int realTime = FreeUtil.ReplaceInt(time, args);
                    if (realTime > 0)
                    {
                        p.StateTimer.AddGameStateTime(uiState, realTime + args.Rule.ServerTime);
                    }
                    PlayerStateUtil.AddPlayerState(uiState, p.Player.gamePlay);
                }
            }
        }
Example #13
0
 public void CharacterDrawInterrupt()
 {
     PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, entity.gamePlay);
     RelatedCharState.InterruptAction();
     RelatedCharState.ForceFinishGrenadeThrow();
 }
Example #14
0
        public static bool AddItemToPlayer(ServerRoom room, PlayerEntity player, int entityId, int cat, int id, int count, string toInv = "")
        {
            SceneObjectEntity entity         = room.RoomContexts.sceneObject.GetEntityWithEntityKey(new EntityKey(entityId, (short)EEntityType.SceneObject));
            FreeMoveEntity    freeMoveEntity = null;

            if (entity == null || entity.isFlagDestroy)
            {
                freeMoveEntity = room.RoomContexts.freeMove.GetEntityWithEntityKey(new EntityKey(entityId, (short)EEntityType.FreeMove));
                if (freeMoveEntity == null)
                {
                    return(false);
                }
            }

            FreeData fd = (FreeData)player.freeData.FreeData;

            room.ContextsWrapper.FreeArgs.TempUse("current", fd);

            if (!FreeItemConfig.Contains(cat, id))
            {
                return(false);
            }

            FreeItemInfo             item   = FreeItemConfig.GetItemInfo(cat, id);
            CreateItemToPlayerAction action = new CreateItemToPlayerAction();

            action.name = ChickenConstant.BagDefault;
            switch (item.cat)
            {
            case (int)ECategory.Weapon:
                if (item.subType == ChickenConstant.ItemCatPrimeWeapon)
                {
                    action.name = ChickenConstant.BagPrimeWeapon;

                    int c1 = fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagPrimeWeapon).posList.Count;
                    int c2 = fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagSecondaryWeapon).posList.Count;

                    if (toInv.StartsWith(ChickenConstant.BagPrimeWeapon))
                    {
                        action.name = ChickenConstant.BagPrimeWeapon;
                        if (c1 > 0)
                        {
                            DropItem(action.name, fd, room);
                        }
                    }
                    else if (toInv.StartsWith(ChickenConstant.BagSecondaryWeapon))
                    {
                        action.name = ChickenConstant.BagSecondaryWeapon;
                        if (c2 > 0)
                        {
                            DropItem(action.name, fd, room);
                        }
                    }
                    else
                    {
                        if (c1 > 0 && c2 == 0)
                        {
                            action.name = ChickenConstant.BagSecondaryWeapon;
                        }

                        if (c1 > 0 && c2 > 0)
                        {
                            int currentKey = FreeWeaponUtil.GetWeaponKey(fd.Player.WeaponController().HeldSlotType);
                            if (currentKey == 0)
                            {
                                currentKey = 1;
                            }
                            if (currentKey == 1 || currentKey == 2)
                            {
                                action.name = "w" + currentKey;
                            }
                            else
                            {
                                action.name = ChickenConstant.BagPrimeWeapon;
                            }

                            DropItem(action.name, fd, room);
                        }
                    }
                }
                else if (item.subType == ChickenConstant.ItemCatPistolWeapon)
                {
                    action.name = ChickenConstant.BagPistolWeapon;
                    DropItem(action.name, fd, room);
                }
                else if (item.subType == ChickenConstant.ItemCatMeleeWeapon)
                {
                    action.name = ChickenConstant.BagMeleeWeapon;
                    DropItem(action.name, fd, room);
                }
                else if (item.subType == ChickenConstant.ItemCatGrenadeWeapon)
                {
                    action.name = ChickenConstant.BagDefault;
                }
                else if (item.subType == ChickenConstant.ItemCatArmor)
                {
                    action.name = ChickenConstant.BagArmor;
                    if (entity != null)
                    {
                        count = entity.armorDurability.CurDurability;
                    }
                    DropItem(action.name, fd, room);
                }
                else if (item.subType == ChickenConstant.ItemCatHelmet)
                {
                    action.name = ChickenConstant.BagHelmet;
                    if (entity != null)
                    {
                        count = entity.armorDurability.CurDurability;
                    }
                    DropItem(action.name, fd, room);
                }
                break;

            case (int)ECategory.Avatar:
                action.name = item.subType;
                DropItem(item.subType, fd, room);
                break;

            case (int)ECategory.WeaponPart:
                action.name = AutoPutPart(fd, item, toInv, room);
                break;

            default:
                break;
            }
            action.key = FreeItemConfig.GetItemKey(item.cat, item.id);

            int canCount = 0;

            if (action.name == ChickenConstant.BagDefault)
            {
                canCount = BagCapacityUtil.CanAddToBagCount(room.ContextsWrapper.FreeArgs, fd, item.cat, item.id, count);
            }
            else if (item.type == ChickenConstant.ItemCatAvatar || action.name == ChickenConstant.BagHelmet || action.name == ChickenConstant.BagArmor)
            {
                canCount = count;
            }
            else
            {
                canCount = 1;
            }

            bool pickupSuccess = false;

            if (canCount > 0 && !string.IsNullOrEmpty(action.name))
            {
                PlayerAnimationAction.DoAnimation(room.RoomContexts, PlayerAnimationAction.Interrupt, fd.Player, true);
                PlayerAnimationAction.DoAnimation(room.RoomContexts, PlayerAnimationAction.PickUp, fd.Player, true);
                PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);

                if (!string.IsNullOrEmpty(action.key))
                {
                    action.count = canCount.ToString();
                    action.SetPlayer("current");
                    room.ContextsWrapper.FreeArgs.TempUse("current", fd);
                    action.Act(room.ContextsWrapper.FreeArgs);
                    room.ContextsWrapper.FreeArgs.Resume("current");

                    if (count > canCount)
                    {
                        SimpleProto msg = FreePool.Allocate();
                        msg.Key = FreeMessageConstant.ChickenTip;
                        msg.Ss.Add("word80," + count + "," + canCount);
                        FreeMessageSender.SendMessage(fd.Player, msg);
                        room.ContextsWrapper.FreeArgs.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleObjectEntity((ECategory)item.cat,
                                                                                                                                                item.id, count - canCount, entity == null ? freeMoveEntity.position.Value : entity.position.Value);
                    }
                    pickupSuccess = true;
                }
                else
                {
                    Debug.LogError(item.cat + "-" + item.key + " not existed");
                }

                if (entity != null)
                {
                    entity.isFlagDestroy = true;
                }
                if (freeMoveEntity != null)
                {
                    freeMoveEntity.isFlagDestroy = true;
                    if (freeMoveEntity.freeData.Cat == FreeEntityConstant.DeadBox)
                    {
                        var deadBox = room.ContextsWrapper.FreeArgs.GameContext.freeMove.GetEntityWithEntityKey(new EntityKey(freeMoveEntity.freeData.IntValue, (short)EEntityType.FreeMove));
                        if (deadBox != null && deadBox.freeData.EmptyDelete)
                        {
                            if (deadBox.freeData.IntValue > 1)
                            {
                                deadBox.freeData.IntValue--;
                            }
                            else
                            {
                                deadBox.isFlagDestroy = true;
                            }
                        }
                    }
                }
            }
            room.ContextsWrapper.FreeArgs.Resume("current");

            return(pickupSuccess);
        }