Пример #1
0
        private void DoRealod(PlayerEntity playerEntity, PlayerWeaponController controller, int target)
        {
            //PlayerWeaponController controller = playerEntity.WeaponController();
            //var configAssy = controller.HeldWeaponLogicConfigAssy;
            var cfg = controller.HeldWeaponAgent.CommonFireCfg;
            var lastReservedBullet = controller.GetReservedBullet();

            target = Mathf.Min(target, lastReservedBullet);
            controller.HeldWeaponAgent.BaseComponent.Bullet += target;
            //DebugUtil.MyLog("Bullet reload" + controller.HeldWeaponAgent.BaseComponent.Bullet, DebugUtil.DebugColor.Black);
            controller.SetReservedBullet(lastReservedBullet - target);

            IEventArgs args = (IEventArgs)(_sessonObjects).FreeArgs;

            if (!args.Triggers.IsEmpty((int)EGameEvent.WeaponState))
            {
                //TODO Implement
                SimpleParaList dama = new SimpleParaList();
                //    dama.AddFields(new ObjectFields(weaponState));
                dama.AddPara(new IntPara("CarryClip", lastReservedBullet - target));
                dama.AddPara(new IntPara("Clip", controller.HeldWeaponAgent.BaseComponent.Bullet));
                dama.AddPara(new IntPara("ClipType", (int)controller.HeldWeaponAgent.Caliber));
                dama.AddPara(new IntPara("id", (int)controller.HeldConfigId));
                SimpleParable sp = new SimpleParable(dama);
                dama.AddFields(new ObjectFields(playerEntity));
                args.Trigger((int)EGameEvent.WeaponState,
                             new TempUnit[]
                             { new TempUnit("state", sp), new TempUnit("current", (FreeData)playerEntity.freeData.FreeData) });
            }
        }
Пример #2
0
        private void Reload(PlayerEntity playerEntity, PlayerWeaponController controller, int clipSize)
        {
            var target = clipSize - controller.HeldWeaponAgent.BaseComponent.Bullet;

            target = Mathf.Max(0, target);
            DoRealod(playerEntity, controller, target);
        }
Пример #3
0
 private void AddPullBoltEvent(PlayerWeaponController controller)
 {
     if (controller.RelatedLocalEvents != null)
     {
         var e = EventInfos.Instance.Allocate(EEventType.PullBolt, false);
         controller.RelatedLocalEvents.AddEvent(e);
     }
 }
Пример #4
0
        private void SpecialReload(PlayerEntity playerEntity, PlayerWeaponController controller, int clipSize)
        {
            var cfg       = controller.HeldWeaponAgent.CommonFireCfg;
            var loadCount = cfg.SpecialReloadCount;
            var target    = clipSize - controller.HeldWeaponAgent.BaseComponent.Bullet;

            loadCount = Mathf.Min(loadCount, target);
            DoRealod(playerEntity, controller, loadCount);
        }
Пример #5
0
 private void AddLocalEffect(PlayerWeaponController controller)
 {
     if (!SharedConfig.IsServer && DefaultCfg != null)
     {
         //枪口火花
         CreateMuzzleSparkEffect(controller);
         //子弹抛壳
         CreateBulletDropEffect(controller);
         //   CreatePullBoltEffect(controller);
     }
 }
Пример #6
0
        public override Vector3 GetFireDir(int seed, PlayerWeaponController controller, int userCmdSeq)
        {
            var delta            = GetFireViewPosition(controller) - controller.RelatedCameraFinal.Position;
            var runTimeComponent = controller.HeldWeaponAgent.RunTimeComponent;

            //         DebugUtil.AppendShootText(userCmdSeq, "ViewPos1:{0},ViewPos2:{1} Sx:{2} Sy:{3}",
            // GetFireViewPosition(controller), controller.RelatedCameraFinal.Position, runTimeComponent.LastSpreadX,
            // runTimeComponent.LastSpreadY);
            return(CalculateShotingDir(seed, delta.GetYaw(), delta.GetPitch(), runTimeComponent.LastSpreadX,
                                       runTimeComponent.LastSpreadY));
        }
Пример #7
0
 public override Vector3 GetFireViewPosition(PlayerWeaponController controller)
 {
     if (controller.RelatedFirePos.SightValid)
     {
         var firePos = controller.RelatedFirePos.SightPosition.ShiftedVector3();
         var clientUpdateComponent = controller.RelatedClientUpdate;
         return(new Vector3(firePos.x + clientUpdateComponent.LastSpreadOffsetX, firePos.y + clientUpdateComponent.LastSpreadOffsetY, firePos.z));
         // DebugUtil.MyLog("{0} {1}",clientUpdateComponent.LastSpreadOffsetX.ToString("f4"),clientUpdateComponent.LastSpreadOffsetY.ToString("f4"));
     }
     //  return controller.RelatedFirePos.SightPosition.ShiftedVector3();
     return(base.GetFireViewPosition(controller));
 }
Пример #8
0
        public virtual Vector3 GetFireDir(int seed, PlayerWeaponController controller, int userCmdSeq)
        {
            var runTimeComponent = controller.HeldWeaponAgent.RunTimeComponent;
            var orientation      = controller.RelatedOrientation;
            var yaw   = orientation.YawRound - orientation.AccPunchYawValue * 2;
            var pitch = orientation.PitchRound - orientation.AccPunchPitchValue * 2;
            var dir   = CalculateShotingDir(seed, yaw, pitch, runTimeComponent.LastSpreadX,
                                            runTimeComponent.LastSpreadY);

            //            DebugUtil.AppendShootText(userCmdSeq,"Yaw:{0},PunchYaw:{1:F5},pitch:{2:F5},AccPunchPitch:{3:F5},LastSpreadX:{4:F5},LastSpreadY:{5:F5}",yaw,orientation.PunchYaw,orientation.Pitch,orientation.AccPunchPitch,runTimeComponent.LastSpreadX,runTimeComponent.LastSpreadY );
            return(dir.normalized);
        }
Пример #9
0
        public Vector3 GetFireDir(int seed, PlayerWeaponController controller, int userCmdSeq)
        {
            var orientation = controller.RelatedOrientation;
            var yaw         = orientation.Yaw - orientation.AccPunchPitchValue * 2;
            var pitch       = orientation.Pitch - orientation.AccPunchYawValue * 2;

            Quaternion q       = Quaternion.Euler(pitch, yaw, 0);
            Vector3    forward = q.Forward();

            forward.y += 0.2f;
            return(forward.normalized);
        }
Пример #10
0
 public void CreateFireEvent(PlayerWeaponController controller)
 {
     if (null == controller)
     {
         Logger.Error("player state owner is not player or null !");
         return;
     }
     if (controller.RelatedLocalEvents != null)
     {
         var e = EventInfos.Instance.Allocate(EEventType.Fire, false);
         controller.RelatedLocalEvents.Events.AddEvent(e);
     }
 }
Пример #11
0
        /// <summary>
        /// 真实投掷位置
        /// 从手上投掷点做射线检测,检测不到阻挡时以正常方式扔出
        /// </summary>
        /// <param name="controller"></param>
        /// <returns></returns>
        public Vector3 GetFireEmitPosition(PlayerWeaponController controller)
        {
            var        handPos = controller.RelatedThrowAction.throwBackupPos;
            var        vieDir  = GetFireDir(0, controller, 0);
            var        tarPos  = handPos + vieDir * 20 * 0.2f;
            RaycastHit hitInfo;

            if (Physics.Raycast(handPos, vieDir, out hitInfo, Vector3.Distance(tarPos, handPos), UnityLayers.PickupObstacleLayerMask))
            {
                return(controller.RelatedThrowAction.throwBackupPos);
            }

            return(GetFireViewPosition(controller));;
        }
Пример #12
0
        public virtual Vector3 GetFireEmitPosition(PlayerWeaponController controller)
        {
            var firePosition = controller.RelatedFirePos;

            if (firePosition == null)
            {
                return(Vector3.zero);
            }

            if (firePosition.MuzzleP3Valid)
            {
                return(firePosition.MuzzleP3Position.ShiftedVector3());
            }

            return(GetFireViewPosition(controller));
        }
Пример #13
0
        public virtual Vector3 GetFireViewPosition(PlayerWeaponController controller)
        {
            var outputView = controller.RelatedCameraFinal;

            if (outputView == null)
            {
                return(Vector3.zero);
            }

            //  var cameraAngle = outputView.EulerAngle;
            //var matrix = Matrix4x4.TRS(BulletEmittorOffset, Quaternion.Euler(cameraAngle), Vector3.one);
            //var offset = matrix.ExtractPosition();
            return(outputView.PlayerFocusPosition);
            // var runtimeComp = controller.HeldWeaponAgent.RunTimeComponent;
            // return new Vector3(outputView.PlayerFocusPosition.x+runtimeComp.LastSpreadOffsetX,outputView.PlayerFocusPosition.x+runtimeComp.LastSpreadOffsetX,outputView.PlayerFocusPosition.z);
            //return offset + outputView.Position;
        }
Пример #14
0
        public void PlayPullBoltEffect(PlayerWeaponController controller)
        {
            if (null == controller)
            {
                Logger.Error("player state owner is not player or null !");
                return;
            }

            var   effectPos   = PlayerEntityUtility.GetThrowingEmitPosition(controller);
            float effectYaw   = (controller.RelatedOrient.Yaw + 90) % 360;
            float effectPitch = controller.RelatedOrient.Pitch;
            int   effectId    = 32;
            int   effectTime  = 3000;

            ClientEffectFactory.CreateGrenadeExplosionEffect(_context, _idGenerator,
                                                             controller.Owner, effectPos, effectYaw, effectPitch, effectId, effectTime, EClientEffectType.PullBolt);
        }
        private void CreatePullBoltEffect(PlayerWeaponController controller)
        {
            if (null == controller)
            {
                Logger.Error("player state owner is not player or null !");
                return;
            }

            var   effectPos   = SingletonManager.Get <ThrowAmmunitionCalculator>().GetFireViewPosition(controller);
            float effectYaw   = (controller.RelatedOrientation.Yaw + 90) % 360;
            float effectPitch = controller.RelatedOrientation.Pitch;
            int   effectId    = 32;
            int   effectTime  = 3000;

            ClientEffectFactory.CreateGrenadeExplosionEffect(_context, _idGenerator, controller.Owner, effectPos,
                                                             effectYaw, effectPitch, effectId, effectTime, EClientEffectType.PullBolt);
        }
Пример #16
0
        /// <summary>
        /// 预估位置
        /// </summary>
        /// <param name="controller"></param>
        /// <returns></returns>
        public Vector3 GetFireViewPosition(PlayerWeaponController controller)
        {
            go.transform.rotation = Quaternion.Euler(controller.RelatedCameraFinal.EulerAngle);
            go.transform.position = controller.RelatedCameraFinal.Position;
            Vector3 rc;

            if (controller.RelatedCameraSNew.IsAiming())
            {
                rc = go.transform.TransformPoint(GlobalConst.ThrowingEmittorFirstOffset);
            }
            else
            {
                rc = go.transform.TransformPoint(GlobalConst.ThrowingEmittorThirdOffset);
            }

            return(rc);
        }
Пример #17
0
        public void PlayBulletDropEffect(PlayerWeaponController controller)
        {
            if (null == controller)
            {
                Logger.Error("player state owner is not player or null !");
                return;
            }
            var ejectTrans = controller.RelatedBones.GetLocation(SpecialLocation.EjectionLocation, controller.RelatedAppearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson);

            if (null != ejectTrans)
            {
                ClientEffectFactory.CreateBulletDrop(_context, _idGenerator, controller.Owner, ejectTrans.position, controller.RelatedOrient.Yaw, controller.RelatedOrient.Pitch, _config.BulletDrop);
            }
            else
            {
                Logger.Error("Get ejectionLocation location failed");
            }
        }
Пример #18
0
        public void PlayMuzzleSparkEffect(PlayerWeaponController controller)
        {
            if (null == controller)
            {
                Logger.Error("player state owner is not player or null !");
                return;
            }
            var muzzleTrans = controller.RelatedBones.GetLocation(SpecialLocation.MuzzleEffectPosition, controller.RelatedAppearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson);

            if (null != muzzleTrans)
            {
                ClientEffectFactory.CreateMuzzleSparkEffct(_context, _idGenerator, controller.Owner, muzzleTrans, controller.RelatedOrient.Pitch, controller.RelatedOrient.Yaw, _config.Spark);
            }
            else
            {
                Logger.Error("Get muzzleLocation location failed");
            }
        }
Пример #19
0
        private void CreateMuzzleSparkEffect(PlayerWeaponController controller)
        {
            if (null == controller || DefaultCfg.Spark < 1)
            {
                return;
            }
            var muzzleTrans = controller.RelatedBones.GetLocation(SpecialLocation.MuzzleEffectPosition,
                                                                  controller.RelatedAppearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson);

            if (null != muzzleTrans)
            {
                //   Logger.Info("CreateMuzzleSparkEffct Once");
                ClientEffectFactory.CreateMuzzleSparkEffct(_context, _idGenerator, controller.Owner, muzzleTrans, controller.RelatedOrientation.Pitch, controller.RelatedOrientation.Yaw, DefaultCfg.Spark);
            }
            else
            {
                Logger.Error("Get muzzleLocation location failed");
            }
        }
Пример #20
0
            public EntityKey CreateThrowing(PlayerWeaponController controller, Vector3 direction, int renderTime, float initVel)
            {
                var throwingEntity = ThrowingEntityFactory.CreateThrowingEntity(
                    _throwingContext,
                    _entityIdGenerator,
                    controller,
                    renderTime,
                    direction,
                    initVel,
                    _newWeaponConfig,
                    _config);

                _logger.InfoFormat("CreateThrowing from {0} with velocity {1}, entity key {2}",
                                   throwingEntity.position.Value,
                                   throwingEntity.throwingData.Velocity,
                                   throwingEntity.entityKey);

                return(throwingEntity.entityKey.Value);
            }
Пример #21
0
        private void AddFireEvent(PlayerWeaponController controller)
        {
            AudioGrp_ShotMode shotMode;

            if (controller.HeldWeaponAgent.HasSilencerPart)
            {
                shotMode = AudioGrp_ShotMode.Silencer;
            }
            else
            {
                shotMode = ((EFireMode)controller.HeldWeaponAgent.BaseComponent.RealFireModel).ToAudioGrpShotMode();
            }
            var position = controller.RelatedAppearence.WeaponHandObject().transform.position;

            if (controller.AudioController != null)
            {
                controller.AudioController.PlayFireAudio(controller.HeldConfigId, shotMode, position);
            }
        }
Пример #22
0
        private void CreateBulletDropEffect(PlayerWeaponController controller)
        {
            if (DefaultCfg.BulletDrop < 1)
            {
                return;
            }
            //For test
            //  var ejectTrans = controller.RelatedBones.GetLocation(SpecialLocation.MuzzleEffectPosition,
            //     controller.RelatedAppearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson);
            var ejectTrans = controller.RelatedBones.GetLocation(SpecialLocation.EjectionLocation, controller.RelatedAppearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson);

            if (null != ejectTrans)
            {
                ClientEffectFactory.CreateBulletDrop(_context, _idGenerator, controller.Owner, ejectTrans.position, controller.RelatedOrientation.Yaw,
                                                     controller.RelatedOrientation.Pitch, DefaultCfg.BulletDrop, controller.HeldConfigId, AudioGrp_FootMatType.Concrete);
            }
            else
            {
                Logger.Error("Get ejectionLocation location failed");
            }
        }
 public PlayerEntityWeaponInteract(PlayerWeaponController in_weaponController, PlayerEntity in_entity)
 {
     entity = in_entity;
 }
 private void AddFireEvent(PlayerWeaponController controller)
 {
 }
Пример #25
0
 public static ShakeGroup GetShakeGroup(RifleShakeConfig shakeConfig, PlayerWeaponController controller)
 {
     return(controller.RelatedCameraSNew.IsAiming() ? shakeConfig.Aiming : shakeConfig.Default);
 }
Пример #26
0
 private bool CheckNeedActionDeal(PlayerWeaponController sharedApi, ActionDealEnum action)
 {
     return(SingletonManager.Get <WeaponResourceConfigManager>()
            .NeedActionDeal(sharedApi.HeldWeaponAgent.ConfigId, action));
 }
Пример #27
0
 public PlayerEntityWeaponInteract(PlayerWeaponController in_weaponController)
 {
     weaponController = in_weaponController;
 }
Пример #28
0
 public void SetController(PlayerWeaponController in_controller)
 {
     controller = in_controller;
 }
Пример #29
0
 public void CreateSparkEffect(PlayerWeaponController controller)
 {
     controller.AddAuxEffect(XmlConfig.EClientEffectType.MuzzleSpark);
 }
Пример #30
0
 public void CreateBulletDropEffect(PlayerWeaponController controller)
 {
     controller.AddAuxEffect(XmlConfig.EClientEffectType.BulletDrop);
 }