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); }
public static ThrowingEntity CreateThrowingEntity( ThrowingContext throwingContext, IEntityIdGenerator entityIdGenerator, PlayerEntity playerEntity, int serverTime, Vector3 dir, float initVel, NewWeaponConfigItem newWeaponConfig, ThrowingConfig throwingConfig) { int throwingEntityId = entityIdGenerator.GetNextEntityId(); var emitPost = PlayerEntityUtility.GetThrowingEmitPosition(playerEntity); Vector3 velocity = dir * initVel; var throwingEntity = throwingContext.CreateEntity(); throwingEntity.AddEntityKey(new EntityKey(throwingEntityId, (int)EEntityType.Throwing)); throwingEntity.AddThrowingData( velocity, false, false, 0, serverTime, false, initVel, throwingConfig, newWeaponConfig.SubType ); throwingEntity.AddPosition(emitPost); throwingEntity.AddOwnerId(playerEntity.entityKey.Value); throwingEntity.isFlagSyncNonSelf = true; throwingEntity.AddLifeTime(DateTime.Now, throwingConfig.CountdownTime + 2000); return(throwingEntity); }
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 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; }
public void PlayPullBoltEffect(IPlayerWeaponState playerState) { var player = playerState.Owner as PlayerEntity; if (null == player) { Logger.Error("player state owner is not player or null !"); return; } var owner = player.entityKey.Value; var effectPos = PlayerEntityUtility.GetThrowingEmitPosition(player); float effectYaw = (playerState.ViewYaw + 90) % 360; float effectPitch = playerState.ViewPitch; int effectId = 32; int effectTime = 3000; ClientEffectFactory.CreateGrenadeExplosionEffect(_context, _idGenerator, owner, effectPos, effectYaw, effectPitch, effectId, effectTime, EClientEffectType.PullBolt); }
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); }