Esempio n. 1
0
        public virtual void AutoPickupWeapon(PlayerEntity player, List <int> sceneKeys)
        {
            for (int i = 0; i < sceneKeys.Count; i++)
            {
                SceneObjectEntity sceneEntity = sceneObjectEntityFactory.GetSceneEntity(sceneKeys[i]) as SceneObjectEntity;
                //sceneKeys.Remove(sceneKeys[i]);
                if (sceneEntity == null || !sceneEntity.hasWeaponObject)
                {
                    Logger.Warn("sceneEntity null failed");
                    return;
                }

                EWeaponType_Config configType = (EWeaponType_Config)SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(sceneEntity.weaponObject.ConfigId).Type;
                if (!configType.CanAutoPick())
                {
                    Logger.Warn("CanAutoPick failed");
                    return;
                }
                if (configType == EWeaponType_Config.TacticWeapon && !sceneEntity.IsCanPickUpByPlayer(player))
                {
                    Logger.Warn("IsCanPickUpByPlayer failed");
                    return;
                }

                var  newWeaponScan = (WeaponScanStruct)sceneEntity.weaponObject;
                bool pickupResult  = player.WeaponController().AutoPickUpWeapon(newWeaponScan);
                if (!pickupResult)
                {
                    Logger.Warn("pickupResult failed");
                    return;
                }

                sceneObjectEntityFactory.DestroySceneWeaponObjectEntity(sceneEntity.entityKey.Value);
                if (player.WeaponController().HeldConfigId == sceneEntity.weaponObject.ConfigId)
                {
                    player.stateInterface.State.PickUp();
                }

                IEventArgs args = commonSession.FreeArgs as IEventArgs;
                if (null != args)
                {
                    TriggerArgs ta = new TriggerArgs();
                    ta.AddPara(new IntPara("weaponId", sceneEntity.weaponObject.ConfigId));
                    ta.AddUnit("current", (FreeData)player.freeData.FreeData);
                    args.Trigger(FreeTriggerConstant.WEAPON_PICKUP, ta);
                }
            }
        }
        public void AutoPickupWeapon(PlayerEntity player, List <int> sceneKeys)
        {
            for (int i = 0; i < sceneKeys.Count; i++)
            {
                SceneObjectEntity sceneEntity = sceneObjectEntityFactory.GetSceneEntity(sceneKeys[i]) as SceneObjectEntity;
                if (sceneEntity == null || !sceneEntity.hasWeaponObject || sceneEntity.isFlagDestroy)
                {
                    continue;
                }

                EWeaponType_Config configType = (EWeaponType_Config)SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(sceneEntity.weaponObject.ConfigId).Type;
                if (!configType.CanAutoPick())
                {
                    continue;
                }

                if (configType == EWeaponType_Config.TacticWeapon && !sceneEntity.IsCanPickUpByPlayer(player))
                {
                    continue;
                }

                var  newWeaponScan = (WeaponScanStruct)sceneEntity.weaponObject;
                bool pickupResult  = player.WeaponController().AutoPickUpWeapon(newWeaponScan);
                if (!pickupResult)
                {
                    continue;
                }

                sceneObjectEntityFactory.DestroySceneWeaponObjectEntity(sceneEntity.entityKey.Value);

                if (player.WeaponController().HeldConfigId == sceneEntity.weaponObject.ConfigId && SharedConfig.IsServer)
                {
                    PlayerAnimationAction.DoAnimation(null, PlayerAnimationAction.PickUp, player, true);
                }

                IEventArgs args = commonSession.FreeArgs as IEventArgs;
                if (null != args)
                {
                    TriggerArgs ta = new TriggerArgs();
                    ta.AddPara(new IntPara("weaponId", sceneEntity.weaponObject.ConfigId));
                    ta.AddUnit("current", (FreeData)player.freeData.FreeData);
                    args.Trigger(FreeTriggerConstant.WEAPON_PICKUP, ta);
                }
            }
        }