示例#1
0
        protected override void InternalExecute()
        {
            var player     = _contexts.player.flagSelfEntity;
            var controller = player.WeaponController();

            if (!player.gamePlay.IsLifeState(EPlayerLifeState.Alive) || !player.gamePlay.CanAutoPick())
            {
                return;
            }

            Collider[] colliders = Physics.OverlapCapsule(player.position.Value, player.bones.Head.position,
                                                          0.4f, UnityLayerManager.GetLayerMask(EUnityLayerName.UserInputRaycast));
            foreach (Collider collider in colliders)
            {
                var rcTar = collider.transform.GetComponentInParent <RayCastTarget>();
                if (rcTar == null)
                {
                    continue;
                }
                if (SingletonManager.Get <GameModeConfigManager>().GetBagTypeById(_contexts.session.commonSession.RoomInfo.ModeId) == EBagType.Chicken)
                {
                    var target = _contexts.sceneObject.GetEntityWithEntityKey(new EntityKey(rcTar.IdList[1], (short)EEntityType.SceneObject));
                    if (target.simpleItem.Category == (int)ECategory.Weapon && player.WeaponController().FilterAutoPickup(target.simpleItem.Id))
                    {
                        var model = target.hasUnityObject ? target.unityObject.UnityObject : target.multiUnityObject.FirstAsset;
                        if (CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, target.position.Value, model))
                        {
                            continue;
                        }

                        SimpleProto pickUp = FreePool.Allocate();
                        pickUp.Key = FreeMessageConstant.PickUpItem;
                        pickUp.Ins.Add(rcTar.IdList[1]);
                        pickUp.Ins.Add(target.simpleItem.Category);
                        pickUp.Ins.Add(target.simpleItem.Id);
                        pickUp.Ins.Add(1);
                        player.network.NetworkChannel.SendReliable((int)EClient2ServerMessage.FreeEvent, pickUp);
                    }
                }
                else
                {
                    _userCmdGenerator.SetUserCmd((userCmd) =>
                    {
                        if (!userCmd.AutoPickUpEquip.Contains(rcTar.IdList[1]))
                        {
                            userCmd.AutoPickUpEquip.Add(rcTar.IdList[1]);
                        }
                    });
                }
            }

            if (controller.AutoThrowing.HasValue && controller.AutoThrowing.Value)
            {
                if (null != _userCmdGenerator && controller.RelatedThrowAction.IsReady == true)
                {
                    _userCmdGenerator.SetUserCmd((userCmd) => { userCmd.IsThrowing = true; });
                    controller.AutoThrowing = false;
                }
            }
        }
示例#2
0
        public override void SendAutoPickupWeapon(int entityId)
        {
            var target = _contexts.sceneObject.GetEntityWithEntityKey(new EntityKey(entityId, (short)EEntityType.SceneObject));
            var model  = target.hasUnityObject ? target.unityObject.UnityObject : target.multiUnityObject.FirstAsset;

            if (!CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(Player, target.position.Value, model))
            {
                _userCmdGenerator.SetUserCmd((cmd) => cmd.AutoPickUpEquip.Add(entityId));
            }
        }
示例#3
0
        private bool HasObstacle(PlayerEntity player, Vector3 targetCenter, GameObject item)
        {
            var hasObstacle = CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, targetCenter, item);

            if (hasObstacle)
            {
                Logger.DebugFormat("There must be obstacle(s) between player and {0}", item.name);
            }
            return(hasObstacle);
        }
示例#4
0
 private bool HasNoObstacle(FreeMoveEntity item, PlayerEntity player)
 {
     if (item.hasUnityGameObject)
     {
         var noObstacle = !CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, item.position.Value, item.unityGameObject.UnityObject);
         return(noObstacle);
     }
     else
     {
         var noObstacle = !CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, item.position.Value, null);
         return(noObstacle);
     }
 }
示例#5
0
 private bool HasNoObstacle(SceneObjectEntity item, PlayerEntity player)
 {
     if (item.hasUnityObject)
     {
         return(!CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, item.position.Value, item.unityObject.UnityObject));
     }
     else if (item.hasMultiUnityObject)
     {
         return(!CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, item.position.Value, item.multiUnityObject.FirstAsset));
     }
     else
     {
         return(!CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, item.position.Value, null));
     }
 }
示例#6
0
        public override void SendAutoPickupWeapon(int entityId)
        {
            var target = _contexts.sceneObject.GetEntityWithEntityKey(new EntityKey(entityId, (short)EEntityType.SceneObject));
            var model  = target.hasUnityObject ? target.unityObject.UnityObject : target.multiUnityObject.FirstAsset;

            if (!CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(Player, target.position.Value, model))
            {
                _userCmdGenerator.SetUserCmd((cmd) => cmd.AutoPickUpEquip.Add(entityId));
            }

            SimpleProto pickUp = FreePool.Allocate();

            _userCmdGenerator.SetUserCmd((cmd) => cmd.IsManualPickUp = true);
            _userCmdGenerator.SetUserCmd((cmd) => cmd.IsUseAction    = true);
            pickUp.Key = FreeMessageConstant.PickUpItem;
            pickUp.Ins.Add(entityId);
            pickUp.Ins.Add(target.simpleEquipment.Category);
            pickUp.Ins.Add(target.simpleEquipment.Id);
            pickUp.Ins.Add(1);
            Player.network.NetworkChannel.SendReliable((int)EClient2ServerMessage.FreeEvent, pickUp);
        }
示例#7
0
        private bool HasObstacle(PlayerEntity player, Vector3 targetCenter, GameObject item)
        {
            var hasObstacle = CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, targetCenter, item);

            return(hasObstacle);
        }