private IEnumerable <Object> NitroAfterTreatment(Ped driver, Vehicle vehicle) { //カウンタ作成 var counter = new ReduceCounter((int)(CoolDownSeconds * 1000)); //カウンタを描画 RegisterProgressBar( new ProgressBarData(counter, new Point(0, 30), Color.FromArgb(200, 0, 255, 125), Color.FromArgb(128, 0, 0, 0), DrawType.RightToLeft, 100, 10, 2)); //カウンタを自動カウント RegisterCounter(counter); foreach (var s in WaitForSeconds(CoolDownSeconds)) { if (!PlayerPed.IsInVehicle() || PlayerPed.IsDead) { //死んだりクルマから降りたらリセット counter.Finish(); _isNitroOk = true; yield break; } yield return(s); } counter.Finish(); _isNitroOk = true; DrawText("Nitro:OK", 2.0f); }
public void Set(UIText text, float expireSeconds) { uiText = text; reduceCounter = new ReduceCounter((int)(1000 * expireSeconds)); parent.RegisterCounter(reduceCounter); setTextSubject.OnNext(Unit.Default); }
public override void OnStart() { ReduceCounter = new ReduceCounter(25000); AddProgressBar(ReduceCounter); var v = core.PlayerPed.CurrentVehicle; v.EnginePowerMultiplier = 10000.0f; v.EngineTorqueMultiplier = 50000.0f; v.Health = 5000; if (core.PlayerPed.IsInVehicle() && v.IsSafeExist()) { //メイン処理 this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.VehicleAccelerate)) .Subscribe(_ => { var targetPos = (core.PlayerPed.ForwardVector).Normalized(); var targetPosition = core.PlayerPed.Position + targetPos * 10; var direction = targetPosition - core.PlayerPed.Position; v.ApplyForce(direction + new Vector3(0, 0, -5)); }); this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.VehicleBrake)) .Subscribe(_ => { var targetPos = (core.PlayerPed.ForwardVector).Normalized(); var targetPosition = core.PlayerPed.Position + targetPos * 10; var direction = targetPosition - core.PlayerPed.Position; v.ApplyForce(-direction * 0.7f + new Vector3(0, 0, -15)); }); this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.Sprint)) .Subscribe(_ => { v.ApplyForce(new Vector3(0, 0, 2)); }); } else { ParupunteEnd(); } ReduceCounter.OnFinishedAsync.Subscribe(_ => ParupunteEnd()); }
public override void OnStart() { var ptfxName = "core"; if (!Function.Call <bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, ptfxName)) { Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, ptfxName); } Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, ptfxName); var animDict = "missfam5_yoga"; var animPlay = "a2_pose"; Function.Call(Hash.REQUEST_ANIM_DICT, animDict); core.PlayerPed.CanRagdoll = false; core.PlayerPed.CanSufferCriticalHits = false; core.PlayerPed.CanPlayGestures = false; core.PlayerPed.CanBeDraggedOutOfVehicle = false; core.PlayerPed.BlockPermanentEvents = false; //メイン処理 this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.Sprint)) .Subscribe(_ => { core.PlayerPed.IsInvincible = true; SetAnimRate(core.PlayerPed, 6.0f + addSpeed); Function.Call(Hash.SET_OBJECT_PHYSICS_PARAMS, core.PlayerPed, 1000000000.0, 1, 1000, 1, 0, 0, 0, 0, 0, 0, 0); Function.Call(Hash.SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN, core.PlayerPed, false); var hp = core.PlayerPed.ForwardVector; Function.Call(Hash.APPLY_FORCE_TO_ENTITY, core.PlayerPed, hp.X * addSpeed, hp.Y * addSpeed, hp.Z * addSpeed, 0, 0, 0, 1, false, true, true, true, true); Function.Call(Hash.TASK_PLAY_ANIM, core.PlayerPed, animDict, animPlay, 0.0, 0.0, -1, 9, 0, 0, 0, 0); //徐々に加速 //addSpeed *= 20.0f; //addSpeed = Math.Min(5, addSpeed); core.PlayerPed.ApplyForce(new Vector3(hp.X * 10.0f, hp.Y * 10.0f, hp.Z * -10.0f)); var pos = core.PlayerPed.Position; GTA.World.AddOwnedExplosion(core.PlayerPed, pos, GTA.ExplosionType.Rocket, 5.0f, 0); }); //左右移動 this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.Sprint)) .Select(_ => core.GetStickValue().X) .Subscribe(input => { var player = core.PlayerPed; player.Quaternion = Quaternion.RotationAxis(player.UpVector, (-input / 127.0f) * 0.4f) * player.Quaternion; }); //下降 // this.OnUpdateAsObservable // .Where(_ => core.IsGamePadPressed(GameKey.Space)) // .Select(_ => core.GetStickValue().X) // .Subscribe(input => // { // var player = core.PlayerPed; // player.ApplyForce(Vector3.WorldUp * 3.0f); //}); //上昇 this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.VehicleHorn)) .Select(_ => core.GetStickValue().X) .Subscribe(input => { var player = core.PlayerPed; player.ApplyForce(Vector3.WorldDown * 6.0f); }); //ボタンを離したら中断 this.OnUpdateAsObservable .Select(_ => core.IsGamePadPressed(GameKey.Sprint)) .DistinctUntilChanged() .Where(x => !x) .Subscribe(_ => { addSpeed = 1.0f; SetAnimRate(core.PlayerPed, 1); Function.Call(Hash.TASK_FORCE_MOTION_STATE, core.PlayerPed, 0xFFF7E7A4, 0); }); ReduceCounter = new ReduceCounter(25000); AddProgressBar(ReduceCounter); ReduceCounter.OnFinishedAsync.Subscribe(_ => ParupunteEnd()); }
public override void OnStart() { var ptfxName = "core"; if (!Function.Call <bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, ptfxName)) { Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, ptfxName); } Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, ptfxName); var animDict = "creatures@pigeon@move"; var animPlay = "flapping"; Function.Call(Hash.REQUEST_ANIM_DICT, animDict); //メイン処理 this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.Sprint)) .Subscribe(_ => { SetAnimRate(core.PlayerPed, 6.0f + addSpeed); Function.Call(Hash.SET_OBJECT_PHYSICS_PARAMS, core.PlayerPed, 200000000.0, 1, 1000, 1, 0, 0, 0, 0, 0, 0, 0); Function.Call(Hash.SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN, core.PlayerPed, true); var hp = core.PlayerPed.ForwardVector; Function.Call(Hash.APPLY_FORCE_TO_ENTITY, core.PlayerPed, hp.X * addSpeed, hp.Y * addSpeed, hp.Z * addSpeed, 0, 0, 0, 1, false, true, true, true, true); Function.Call(Hash.TASK_PLAY_ANIM, core.PlayerPed, animDict, animPlay, 3.0, -3.0, -1, 9, 0, 0, 0, 0); //徐々に加速 addSpeed *= 1.1f; addSpeed = Math.Min(5, addSpeed); }); //定期的にエフェクト再生 this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.Sprint)) .ThrottleFirst(TimeSpan.FromSeconds(1)) .Subscribe(_ => { // StartFire(); }); //左右移動 this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.Sprint)) .Select(_ => core.GetStickValue().X) .Subscribe(input => { var player = core.PlayerPed; player.Quaternion = Quaternion.RotationAxis(player.UpVector, (-input / 127.0f) * 0.2f) * player.Quaternion; }); //上昇 this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.Space)) .Select(_ => core.GetStickValue().X) .Subscribe(input => { var player = core.PlayerPed; player.ApplyForce(Vector3.WorldUp * 1.0f); }); this.OnUpdateAsObservable .Where(_ => core.IsGamePadPressed(GameKey.VehicleHorn)) .Select(_ => core.GetStickValue().X) .Subscribe(input => { var player = core.PlayerPed; player.ApplyForce(Vector3.WorldDown * 6.0f); }); //ボタンを離したら中断 this.OnUpdateAsObservable .Select(_ => core.IsGamePadPressed(GameKey.Sprint)) .DistinctUntilChanged() .Where(x => !x) .Subscribe(_ => { addSpeed = 1.0f; SetAnimRate(core.PlayerPed, 1); Function.Call(Hash.TASK_FORCE_MOTION_STATE, core.PlayerPed, 0xFFF7E7A4, 0); }); //死んだら爆発 this.OnUpdateAsObservable .Select(_ => core.PlayerPed.IsDead) .DistinctUntilChanged() .Where(x => x).Subscribe(_ => { GTA.World.AddExplosion(core.PlayerPed.Position, GTA.ExplosionType.Rocket, 1.0f, 1.0f); }); ReduceCounter = new ReduceCounter(25000); AddProgressBar(ReduceCounter); ReduceCounter.OnFinishedAsync.Subscribe(_ => ParupunteEnd()); }