Exemplo n.º 1
0
        //投掷
        private void DoThrowing(PlayerWeaponController controller, WeaponSideCmd cmd, Contexts contexts)
        {
            if (!throwingActionData.CanThrow())
            {
                return;
            }

            if (!throwingActionData.IsPull)
            {
                DoPull(controller, cmd, false);
            }

            var handPos = controller.HandPos;

            DebugUtil.MyLog("Throw");
            throwingActionData.SetThrow(handPos);
            ThrowingEntityFactory.StartThrowingEntityFly(throwingActionData.ThrowingEntityKey, true,
                                                         throwCfg.Throwing.GetThrowingInitSpeed(throwingActionData.IsNearThrow));
            //投掷动作
            characterState.FinishGrenadeThrow();
            //状态重置
            if (controller.RelatedThrowUpdate != null)
            {
                controller.RelatedThrowUpdate.ReadyFly = false;
            }
            //投掷型物品使用数量
            controller.RelatedStatisticsData.UseThrowingCount++;
            controller.RelatedAppearence.UnmountWeaponFromHand();
            controller.RelatedAppearence.UnmountWeaponInPackage(WeaponInPackage.ThrownWeapon);

            if (SharedConfig.IsServer)
            {
                FreeRuleEventArgs args = contexts.session.commonSession.FreeArgs as FreeRuleEventArgs;
                (args.Rule as IGameRule).HandleWeaponFire(contexts,
                                                          contexts.player.GetEntityWithEntityKey(controller.Owner), resCfg);
                (args.Rule as IGameRule).HandleWeaponState(contexts,
                                                           contexts.player.GetEntityWithEntityKey(controller.Owner), resCfg.Id);
            }

            controller.AudioController.PlaySimpleAudio(EAudioUniqueId.GrenadeThrow, true);
        }