Пример #1
0
        public virtual bool IsCanFire(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
        {
            if (cmd.UserCmd.RenderTime < attackProxy.RuntimeComponent.NextAttackTimestamp)
            {
                return(false);
            }
            if (attackProxy.BasicComponent.Bullet <= 0)
            {
                attackProxy.Owner.ShowTip(ETipType.FireWithNoBullet);
                if (cmd.FiltedInput(EPlayerInput.IsLeftAttack))
                {
                    attackProxy.AudioController.PlayEmptyFireAudio();
                }
                return(false);
            }

            EFireMode currentMode = (EFireMode)attackProxy.BasicComponent.RealFireModel;

            switch (currentMode)
            {
            case EFireMode.Manual:
                return(!attackProxy.RuntimeComponent.IsPrevCmdFire);

            case EFireMode.Auto:
                return(true);

            case EFireMode.Burst:
                return(!attackProxy.RuntimeComponent.IsPrevCmdFire || attackProxy.RuntimeComponent.NeedAutoBurstShoot);

            default:
                return(false);
            }
        }
        protected void UpdateOrientationAttenuation(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
        {
            var orientation = attackProxy.Orientation;
            var punchYaw    = orientation.AccPunchYaw;
            var punchPitch  = orientation.AccPunchPitch;

            var frameSec = cmd.UserCmd.FrameInterval / 1000f;
            //获取向量长度
            var puntchLength = Mathf.Sqrt(punchYaw * punchYaw + punchPitch * punchPitch);

            if (puntchLength > 0)
            {
                punchYaw   = punchYaw / puntchLength;
                punchPitch = punchPitch / puntchLength;

                puntchLength = UpdateLen(attackProxy, puntchLength, frameSec);
                //UpdateLen: AccPunchYaw  =>AccPunchYaw
                orientation.AccPunchYaw   = punchYaw * puntchLength;
                orientation.AccPunchPitch = punchPitch * puntchLength;

                var factor = GePuntchFallbackFactor(attackProxy.Owner);
                //GePuntchFallbackFactor : AccPunchYaw => AccPunchPitch
                orientation.AccPunchYawValue   = orientation.AccPunchYaw * factor;
                orientation.AccPunchPitchValue = orientation.AccPunchPitch * factor;
            }
        }
Пример #3
0
 private void CallOnFrame(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd)
 {
     foreach (var frame in _frames)
     {
         frame.OnFrame(weaponBaseAgent, cmd);
     }
 }
Пример #4
0
 private void CallOnIdle(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd)
 {
     foreach (var fireIdle in _idles)
     {
         fireIdle.OnIdle(weaponBaseAgent, cmd);
     }
 }
Пример #5
0
 private void CallBeforeFires(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd)
 {
     foreach (var beforeFire in _beforeFireProcessors)
     {
         beforeFire.OnBeforeFire(weaponBaseAgent, cmd);
     }
 }
Пример #6
0
 private void CallAfterFires(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd)
 {
     foreach (var afterfire in _afterFireProcessors)
     {
         afterfire.OnAfterFire(weaponBaseAgent, cmd);
     }
 }
Пример #7
0
        protected override void UpdateFire(PlayerWeaponController controller, WeaponSideCmd cmd, Contexts contexts)
        {
            bool isFire = false;

            foreach (var fireTrigger in _fireTrigggers)
            {
                isFire |= fireTrigger.IsTrigger(controller, cmd);
            }
            if (isFire)
            {
                foreach (var fireCheck in _fireCheckers)
                {
                    isFire &= fireCheck.IsCanFire(controller, cmd);
                }
            }
            if (isFire && controller.RelatedThrowAction.ThrowingEntityKey == EntityKey.Default &&
                (controller.RelatedThrowAction.LastFireWeaponKey == controller.HeldWeaponAgent.WeaponKey.EntityId || controller.RelatedThrowAction.LastFireWeaponKey == 0))
            {
                Fire(controller, cmd, contexts);
                controller.RelatedThrowAction.LastFireWeaponKey = controller.HeldWeaponAgent.WeaponKey.EntityId;
            }
            else
            {
                CallOnIdle(controller.HeldWeaponAgent, cmd);
            }

            CallOnFrame(controller.HeldWeaponAgent, cmd);
        }
        public void OnBulletFire(PlayerWeaponController controller, WeaponSideCmd cmd)
        {
            //            DebugUtil.MyLog("[seq:{1}]MuzzleP3Position:{0}",controller.RelatedFirePos.MuzzleP3Position,cmd.UserCmd.Seq);
            var bulletCfg = controller.HeldWeaponAgent.BulletCfg;

            AssertUtility.Assert(bulletCfg != null);
            var cmdSeq   = cmd.UserCmd.Seq;
            var fireAmmu = controller.RelatedCameraSNew.IsAiming() ? sightFireAmmu : normalFireAmmu;

            // 射出子弹
            for (int i = 0; i < bulletCfg.HitCount; i++)
            {
                var bulletData = PlayerBulletData.Allocate();
                bulletData.Dir =
                    PrecisionsVector3.MakePrecisionsV(
                        fireAmmu.GetFireDir(cmdSeq + i, controller, cmd.UserCmd.Seq), 3);
                var viewPos = PrecisionsVector3.MakePrecisionsV(fireAmmu.GetFireViewPosition(controller), 3);
                bulletData.ViewPosition = PrecisionsVector3.MakeRoundPrecisionsV(viewPos, 3);
                //枪口位置取原始精度
                bulletData.EmitPosition = fireAmmu.GetFireEmitPosition(controller);
                controller.AddAuxBullet(bulletData);
                // DebugUtil.AppendShootText(cmd.UserCmd.Seq, "[Bullet Fire]{0}", bulletData.ToStringExt());
            }

            controller.AfterAttack();
        }
Пример #9
0
        public void OnAfterFire(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
        {
            if (attackProxy.BasicComponent.RealFireModel != (int)EFireMode.Burst)
            {
                return;
            }

            var runTimeComponent = attackProxy.RuntimeComponent;

            runTimeComponent.NeedAutoBurstShoot = false;
            var config = attackProxy.WeaponConfigAssy.S_DefaultFireModeLogicCfg;

            runTimeComponent.BurstShootCount += 1;
            float intervalFactor = 1 - attackProxy.GetAttachedAttributeByType(WeaponAttributeType.AttackInterval) / 100;

            if (runTimeComponent.BurstShootCount < config.BurstCount)
            {
                runTimeComponent.NextAttackTimestamp = cmd.UserCmd.RenderTime + Mathf.CeilToInt(config.BurstAttackInnerInterval * intervalFactor);
                runTimeComponent.NeedAutoBurstShoot  = true;
                runTimeComponent.IsPrevCmdFire       = true;
            }
            else
            {
                runTimeComponent.NextAttackTimestamp = cmd.UserCmd.RenderTime + Mathf.CeilToInt(config.BurstAttackInterval * intervalFactor);
                runTimeComponent.BurstShootCount     = 0;
            }

            if (attackProxy.BasicComponent.Bullet == 0)
            {
                runTimeComponent.BurstShootCount    = 0;
                runTimeComponent.NeedAutoBurstShoot = false;
            }
        }
 private void CallAfterFires(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
 {
     foreach (var afterfire in _afterFireProcessors)
     {
         afterfire.OnAfterFire(attackProxy, cmd);
     }
 }
        protected override void UpdateFire(PlayerWeaponController controller, WeaponSideCmd cmd, Contexts contexts)
        {
            bool isFire      = false;
            var  attackProxy = controller.AttackProxy;

            foreach (var fireTrigger in _fireTrigggers)
            {
                isFire |= fireTrigger.IsTrigger(cmd);
            }

            isFire = isFire && attackProxy.CanFire;
            if (isFire)
            {
                foreach (var fireCheck in _fireCheckers)
                {
                    isFire &= fireCheck.IsCanFire(attackProxy, cmd);
                }
            }

            if (isFire && throwingActionData.ThrowingEntityKey == EntityKey.Default &&
                (throwingActionData.LastFireWeaponKey == controller.HeldWeaponAgent.WeaponKey.EntityId || throwingActionData.LastFireWeaponKey == 0))
            {
                Fire(controller, cmd, contexts);
                throwingActionData.LastFireWeaponKey = controller.HeldWeaponAgent.WeaponKey.EntityId;
            }
            else
            {
                CallOnIdle(attackProxy, cmd);
            }
            CallOnFrame(attackProxy, cmd);
        }
Пример #12
0
        //拉栓
        private void DoPull(PlayerWeaponController controller, WeaponSideCmd cmd)
        {
            if (controller.RelatedThrowAction.IsReady && !controller.RelatedThrowAction.IsPull)
            {
                if (GlobalConst.EnableWeaponLog)
                {
                    DebugUtil.MyLog("Do Pull");
                }

                controller.RelatedThrowAction.IsPull          = true;
                controller.RelatedThrowAction.LastPullTime    = controller.RelatedTime;
                controller.RelatedThrowAction.ShowCountdownUI = true;
                controller.RelatedThrowAction.IsInterrupt     = false;
                //生成Entity
                int renderTime = cmd.UserCmd.RenderTime;
                var dir        = BulletDirUtility.GetThrowingDir(controller);
                controller.RelatedThrowAction.ThrowingEntityKey           = _throwingFactory.CreateThrowing(controller, dir, renderTime, GetInitVel(controller));
                controller.HeldWeaponAgent.RunTimeComponent.LastBulletDir = dir;
                //弹片特效
                if (cmd.UserCmd.IsReload)
                {
                    controller.AddAuxEffect(EClientEffectType.PullBolt);
                }
                if (controller.AudioController != null)
                {
                    controller.AudioController.PlaySimpleAudio(EAudioUniqueId.GrenadeTrigger, true);
                }
            }
        }
 private void CallOnIdle(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
 {
     foreach (var fireIdle in _idles)
     {
         fireIdle.OnIdle(attackProxy, cmd);
     }
 }
 private void CallOnFrame(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
 {
     foreach (var frame in _frames)
     {
         frame.OnFrame(attackProxy, cmd);
     }
 }
Пример #15
0
        //准备
        private void DoReady(PlayerWeaponController controller, WeaponSideCmd cmd)
        {
            var throwAction = controller.RelatedThrowAction;

            if (!throwAction.IsReady &&
                throwAction.ThrowingEntityKey == EntityKey.Default &&
                controller.RelatedThrowAction.LastFireWeaponKey == 0)
            {
                if (GlobalConst.EnableWeaponLog)
                {
                    DebugUtil.MyLog("Do Ready");
                }
                throwAction.IsReady   = true;
                throwAction.ReadyTime = controller.RelatedTime;
                throwAction.Config    = _throwingFactory.ThrowingConfig;
                //准备动作
                controller.RelatedCharState.InterruptAction();
                controller.RelatedCharState.StartFarGrenadeThrow(() =>
                {
                    controller.AutoStuffGrenade();
                    DebugUtil.MyLog("ThrowGrenadeFinished");
                });
                controller.RelatedThrowAction.LastFireWeaponKey = controller.HeldWeaponAgent.WeaponKey.EntityId;
            }
        }
 private void CallBeforeFires(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
 {
     foreach (var beforeFire in _beforeFireProcessors)
     {
         beforeFire.OnBeforeFire(attackProxy, cmd);
     }
 }
Пример #17
0
        //拉栓/不按R进行一次自动拉栓
        private void DoPull(PlayerWeaponController controller, WeaponSideCmd cmd, bool playPullAudio = true)
        {
            if (!throwingActionData.CanPull())
            {
                return;
            }

            //生成Entity
            int renderTime = cmd.UserCmd.RenderTime;
            var throwAmmunitionCalculator = SingletonManager.Get <ThrowAmmunitionCalculator>();
            var dir            = throwAmmunitionCalculator.GetFireDir(0, controller, 0);
            var viewPosition   = throwAmmunitionCalculator.GetFireViewPosition(controller);
            var throwingEntity = ThrowingEntityFactory.CreateThrowingEntity(controller, renderTime, dir, viewPosition,
                                                                            throwCfg.Throwing.GetThrowingInitSpeed(throwingActionData.IsNearThrow), resCfg, throwCfg.Throwing);

            throwingActionData.SetPull(throwingEntity.entityKey.Value);
            //弹片特效
            if (cmd.UserCmd.IsReload)
            {
                controller.AddAuxEffect(EClientEffectType.PullBolt);
            }

            if (playPullAudio)
            {
                controller.AudioController.PlaySimpleAudio(EAudioUniqueId.GrenadeTrigger, true);
            }
        }
Пример #18
0
        protected override void Update(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
        {
            var   config            = attackProxy.WeaponConfigAssy.S_PistolSpreadLogicCfg;
            float spreadScaleFactor = FireSpreadProvider.GetSpreadScaleFactor(config, attackProxy);

            FireSpreadFormula.ApplyPistolFinalSpread(spreadScaleFactor, config.SpreadScale, attackProxy.RuntimeComponent);
        }
Пример #19
0
        protected override void DoIdle(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
        {
            //null->Fire->SpecialFireHold(1)->SpecialFireEnd->null
            if (cmd.FiltedInput(EPlayerInput.IsPullboltInterrupt))
            {//当前pullBolting被限制,不执行
                attackProxy.InterruptPullBolt();
                return;
            }
            var state = attackProxy.CharacterState.GetActionState();

            //正常开火拉栓
            if (state == ActionInConfig.SpecialFireHold)
            {
                logger.Info("Normal pullbolt");
                attackProxy.AudioController.PlayPullBoltAudio(attackProxy.WeaponConfigAssy.S_Id);
                attackProxy.CharacterState.SpecialFireEnd();
                attackProxy.RuntimeComponent.FinishPullBolt();
                return;
            }
            if (state == ActionInConfig.Null && attackProxy.BasicComponent.Bullet > 0)
            {
                //只拉栓逻辑
                if (attackProxy.RuntimeComponent.IsPullboltInterrupt)
                {
                    logger.Info("Interrupt pullbolt");
                    attackProxy.RuntimeComponent.FinishPullBolt();
                    attackProxy.AudioController.PlayPullBoltAudio(attackProxy.WeaponConfigAssy.S_Id);
                    attackProxy.CharacterState.SpecialFireEnd();
                }
                // var needActionDeal = SingletonManager.Get<WeaponResourceConfigManager>()
                //                 .NeedActionDeal(attackProxy.WeaponConfigAssy.S_Id, ActionDealEnum.Reload);
            }
        }
Пример #20
0
 public void OnFrame(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
 {
     if (!cmd.IsFire)
     {
         attackProxy.RuntimeComponent.IsPrevCmdFire = false;
         attackProxy.AudioController.StopFireTrigger();
     }
 }
        public override void OnAfterFire(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
        {
            var config     = attackProxy.WeaponConfigAssy.SRifleShakeCfg;
            var shakeGroup = FireShakeProvider.GetShakeGroup(config, attackProxy.Owner);
            var shakeInfo  = FireShakeProvider.GetShakeInfo(config, attackProxy.Owner, shakeGroup);

            CalcBaseShake(attackProxy, cmd.UserCmd.Seq, shakeInfo);
        }
Пример #22
0
 public override bool IsCanFire(PlayerWeaponController controller, WeaponSideCmd weaponCmd)
 {
     if (base.IsCanFire(controller, weaponCmd))
     {
         return(controller.HeldWeaponAgent.RunTimeComponent.PullBoltFinish);
     }
     return(false);
 }
 public void OnIdle(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
 {
     if (!cmd.IsFire)
     {
         attackProxy.AudioController.StopFireTrigger();
         DoIdle(attackProxy, cmd);
     }
 }
Пример #24
0
        protected override void Update(WeaponBaseAgent heldBaseAgent, WeaponSideCmd cmd)
        {
            var   config            = heldBaseAgent.PistolSpreadLogicCfg;
            var   weaponRuntime     = heldBaseAgent.RunTimeComponent;
            float spreadScaleFactor = FireSpreadProvider.GetSpreadScaleFactor(config, heldBaseAgent.Owner.WeaponController());

            FireSpreadFormula.ApplyPistolFinalSpread(spreadScaleFactor, config.SpreadScale, weaponRuntime);
        }
Пример #25
0
 public override bool IsCanFire(WeaponAttackProxy attackProxy, WeaponSideCmd weaponCmd)
 {
     if (base.IsCanFire(attackProxy, weaponCmd))
     {
         return(attackProxy.RuntimeComponent.PullBoltFinish);
     }
     return(false);
 }
Пример #26
0
        public override void OnAfterFire(WeaponBaseAgent agent, WeaponSideCmd cmd)
        {
            var weaponController = agent.Owner.WeaponController();
            var config           = agent.RifleShakeCfg;
            var shakeGroup       = FireShakeProvider.GetShakeGroup(config, weaponController);
            var shakeInfo        = FireShakeProvider.GetShakeInfo(config, weaponController, shakeGroup);

            CalcBaseShake(agent, cmd.UserCmd.Seq, shakeInfo);
        }
Пример #27
0
        protected override void Update(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd)

        {
            SniperSpreadLogicConfig config = weaponBaseAgent.SniperSpreadLogicCfg;
            var   runTimeComponent         = weaponBaseAgent.RunTimeComponent;
            float spread = FireSpreadProvider.GetSpreadScaleFactor(config, weaponBaseAgent.Owner.WeaponController());

            FireSpreadFormula.ApplyFixedFinalSpread(spread, config.SpreadScale, runTimeComponent);
        }
        public override void OnAfterFire(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
        {
            var config = attackProxy.WeaponConfigAssy.SFixedShakeCfg;

            if (null == config)
            {
                return;
            }
            attackProxy.Orientation.AccPunchPitch      += config.PunchPitch;
            attackProxy.Orientation.AccPunchPitchValue += config.PunchPitch * config.PunchOffsetFactor;
        }
Пример #29
0
 public void OnIdle(WeaponAttackProxy attackProxy, WeaponSideCmd cmd)
 {
     if (attackProxy.RuntimeComponent.ContinuesShootCount == 0)
     {
         var config = attackProxy.WeaponConfigAssy.S_PistolAccuracyLogicCfg;
         if (config != null)
         {
             attackProxy.RuntimeComponent.Accuracy = config.InitAccuracy;
         }
     }
 }
Пример #30
0
 public void OnIdle(WeaponBaseAgent agent, WeaponSideCmd cmd)
 {
     if (!cmd.IsFire)
     {
         var audioController = agent.Owner.AudioController();
         if (audioController != null)
         {
             audioController.StopFireTrigger();
         }
         DoIdle(agent.Owner.WeaponController(), cmd);
     }
 }