private void StartFlying(PlayerEntity playerEntity, ThrowingEntity throwingEntity)
        {
            IPlayerWeaponState playerWeapon = playerEntity.weaponLogic.State;
            var     dir = BulletDirUtility.GetThrowingDir(playerWeapon);
            Vector3 vel = dir * throwingEntity.throwingData.InitVelocity;
            Vector3 pos = PlayerEntityUtility.GetThrowingEmitPosition(playerEntity);

            throwingEntity.position.Value        = pos;
            throwingEntity.throwingData.Velocity = vel;
            throwingEntity.throwingData.IsFly    = true;
            //扔掉手雷
            playerWeapon.LastGrenadeId = playerEntity.grenade.Id;

            if (SharedConfig.IsServer)
            {
                IEventArgs args = (IEventArgs)_contexts.session.commonSession.FreeArgs;

                if (!args.Triggers.IsEmpty((int)EGameEvent.WeaponState))
                {
                    SimpleParaList dama = new SimpleParaList();
                    dama.AddFields(new ObjectFields(playerWeapon));
                    dama.AddPara(new IntPara("CarryClip", playerWeapon.ReservedBulletCount));
                    dama.AddPara(new IntPara("Clip", playerWeapon.LoadedBulletCount));
                    dama.AddPara(new IntPara("ClipType", (int)playerWeapon.Caliber));
                    dama.AddPara(new IntPara("id", (int)playerWeapon.CurrentWeapon));
                    SimpleParable sp = new SimpleParable(dama);

                    args.Trigger((int)EGameEvent.WeaponState, new TempUnit[] { new TempUnit("state", sp), new TempUnit("current", (FreeData)((PlayerEntity)playerWeapon.Owner).freeData.FreeData) });
                }
            }
            playerWeapon.LastGrenadeId      = 0;
            playerWeapon.IsThrowingStartFly = false;
            //清理状态
            CastGrenade(playerEntity);
        }
Пример #2
0
        private void RefreshThrowingData(PlayerEntity player)
        {
            ThrowingActionInfo actionInfo = player.throwingAction.ActionInfo;
            var dir = BulletDirUtility.GetThrowingDir(player.WeaponController());

            if (actionInfo.IsNearThrow)
            {
                actionInfo.Vel = dir * actionInfo.Config.NearInitSpeed;
            }
            else
            {
                actionInfo.Vel = dir * actionInfo.Config.FarInitSpeed;
            }
            actionInfo.Pos           = PlayerEntityUtility.GetThrowingEmitPosition(player.WeaponController());
            actionInfo.Gravity       = actionInfo.Config.Gravity;
            actionInfo.Decay         = actionInfo.Config.VelocityDecay;
            actionInfo.CountdownTime = actionInfo.Config.CountdownTime;
        }
Пример #3
0
 //拉栓
 private void DoPull(IPlayerWeaponState playerWeapon, IWeaponCmd cmd)
 {
     if (playerWeapon.ThrowingActionInfo.IsReady && !playerWeapon.ThrowingActionInfo.IsPull)
     {
         playerWeapon.ThrowingActionInfo.IsPull          = true;
         playerWeapon.ThrowingActionInfo.LastPullTime    = playerWeapon.ClientTime;
         playerWeapon.ThrowingActionInfo.ShowCountdownUI = true;
         playerWeapon.ThrowingActionInfo.IsInterrupt     = false;
         //生成Entity
         int renderTime = cmd.RenderTime;
         var dir        = BulletDirUtility.GetThrowingDir(playerWeapon);
         playerWeapon.ThrowingActionInfo.ThrowingEntityKey = _throwingFactory.CreateThrowing(playerWeapon, dir, renderTime, GetInitVel(playerWeapon));
         playerWeapon.LastBulletDir = dir;
         //弹片特效
         if (cmd.IsReload)
         {
             _weaponEffectLogic.CreatePullBoltEffect(playerWeapon);
         }
         playerWeapon.OnWeaponStateChanged();
     }
 }
Пример #4
0
        private void StartFlying(PlayerEntity playerEntity, ThrowingEntity throwingEntity)
        {
            var     dir = BulletDirUtility.GetThrowingDir(playerEntity.WeaponController());
            Vector3 vel = dir * throwingEntity.throwingData.InitVelocity;
            Vector3 pos = PlayerEntityUtility.GetThrowingEmitPosition(playerEntity.WeaponController());

            throwingEntity.position.Value        = pos;
            throwingEntity.throwingData.Velocity = vel;
            throwingEntity.throwingData.IsFly    = true;

            if (SharedConfig.IsServer)
            {
                IEventArgs args = (IEventArgs)_contexts.session.commonSession.FreeArgs;

                if (!args.Triggers.IsEmpty((int)EGameEvent.WeaponState))
                {
                    SimpleParaList dama = new SimpleParaList();
                    //TODO 确认逻辑
                    dama.AddFields(new ObjectFields(playerEntity));
                    var weaponData = playerEntity.WeaponController().HeldWeaponAgent.ComponentScan;
                    if (!weaponData.IsSafeVailed)
                    {
                        return;
                    }
                    dama.AddPara(new IntPara("CarryClip", playerEntity.WeaponController().GetReservedBullet()));
                    dama.AddPara(new IntPara("Clip", weaponData.Bullet));
                    var config = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(weaponData.ConfigId);
                    dama.AddPara(new IntPara("ClipType", null == config ? 0 : config.Caliber));
                    dama.AddPara(new IntPara("id", weaponData.ConfigId));
                    SimpleParable sp = new SimpleParable(dama);

                    args.Trigger((int)EGameEvent.WeaponState, new TempUnit("state", sp), new TempUnit("current", (FreeData)(playerEntity).freeData.FreeData));
                }
            }

            //清理状态
            CastGrenade(_contexts, playerEntity);
        }