From faa5e8f569ec48ee3c6b354cdb24bda23e1b3835 Mon Sep 17 00:00:00 2001 From: kimura Date: Mon, 26 Jul 2021 12:38:49 +0900 Subject: [PATCH] =?UTF-8?q?=E6=BC=94=E5=87=BA=E7=B5=84=E3=81=BF=E8=BE=BC?= =?UTF-8?q?=E3=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/Cooking/Scripts/Corn.cs | 2 +- .../Scenes/Cooking/Scripts/CornManager.cs | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Corn.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Corn.cs index 8f911f80..ea55a2c2 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Corn.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Corn.cs @@ -66,7 +66,7 @@ public class Corn : MonoBehaviour this.ObserveEveryValueChanged(x => x.rigidbody.velocity.magnitude) .Where(x => x >= cornSpillSpeed) .ThrottleFirstFrame(30) // 30フレーム間隔開ける - .Select(_ => Random.value < .2f) // 演出を出す確率 + .Where(_ => Random.value < .2f) // 演出を出す確率 .FirstOrDefault() .Subscribe(_ => { diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs index 3e9a2bd0..3edcf9aa 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs @@ -39,7 +39,7 @@ public class CornManager : MonoBehaviour private bool isHot; private bool isCompleted; private readonly List> cornConditions = new List>(); - private readonly Subject cornSpilledSubject = new Subject(); + private readonly Subject<(CornCondition cond, Vector3 pos)> cornSpilledSubject = new Subject<(CornCondition, Vector3)>(); private readonly ReactiveProperty missCount = new ReactiveProperty(); private readonly ReactiveProperty cornGrowSpeed = new FloatReactiveProperty(0f); private readonly CompositeDisposable compositeDisposable = new CompositeDisposable(); @@ -72,13 +72,13 @@ public class CornManager : MonoBehaviour // コーン飛び出し制御 // 5フレームごとに2回など演出の回数を制御 cornSpilledSubject - .Where(x => x != CornCondition.Seed) // Seedは演出なし + .Where(x => x.cond != CornCondition.Seed) // Seedは演出なし .BatchFrame(5, FrameCountType.EndOfFrame) // 指定フレーム分まとめる .Subscribe(x => { - foreach (var condition in x.RandomChoose(2)) + foreach (var item in x.RandomChoose(2)) { - SpawnSpilledAnimation(condition); + SpawnSpilledAnimation(item.cond, item.pos); } }).AddTo(this); @@ -192,11 +192,7 @@ public class CornManager : MonoBehaviour }).AddTo(compositeDisposable); corn.Spilled - .Subscribe(_ => - { - // 同時に飛び出したとき用に演出をばらつかせる - corn.CallWaitForSeconds(Random.Range(0f, .5f), () => cornSpilledSubject.OnNext(corn.Condition.Value)); - }).AddTo(compositeDisposable); + .Subscribe(_ => cornSpilledSubject.OnNext((corn.Condition.Value, corn.transform.position))).AddTo(compositeDisposable); cornConditions.Add(corn.Condition); } @@ -246,10 +242,8 @@ public class CornManager : MonoBehaviour } } - private void SpawnSpilledAnimation(CornCondition condition) + private void SpawnSpilledAnimation(CornCondition condition, Vector3 position) { - // Result表示より下の範囲にランダム表示 - var position = new Vector2((Random.value * 2 - 1) * worldWidth, Mathf.Lerp(-worldHeight, maxSpilledHeight, Random.value)); // 画面KO再生 var animation = Instantiate(spilledCornAnimationPrefab, position, Quaternion.identity); // KOコーンスキン変更