演出組み込み

This commit is contained in:
kimura 2021-07-26 12:38:49 +09:00
parent 09abcff7aa
commit faa5e8f569
2 changed files with 7 additions and 13 deletions

View File

@ -66,7 +66,7 @@ public class Corn : MonoBehaviour
this.ObserveEveryValueChanged(x => x.rigidbody.velocity.magnitude) this.ObserveEveryValueChanged(x => x.rigidbody.velocity.magnitude)
.Where(x => x >= cornSpillSpeed) .Where(x => x >= cornSpillSpeed)
.ThrottleFirstFrame(30) // 30フレーム間隔開ける .ThrottleFirstFrame(30) // 30フレーム間隔開ける
.Select(_ => Random.value < .2f) // 演出を出す確率 .Where(_ => Random.value < .2f) // 演出を出す確率
.FirstOrDefault() .FirstOrDefault()
.Subscribe(_ => .Subscribe(_ =>
{ {

View File

@ -39,7 +39,7 @@ public class CornManager : MonoBehaviour
private bool isHot; private bool isHot;
private bool isCompleted; private bool isCompleted;
private readonly List<IObservable<CornCondition>> cornConditions = new List<IObservable<CornCondition>>(); private readonly List<IObservable<CornCondition>> cornConditions = new List<IObservable<CornCondition>>();
private readonly Subject<CornCondition> cornSpilledSubject = new Subject<CornCondition>(); private readonly Subject<(CornCondition cond, Vector3 pos)> cornSpilledSubject = new Subject<(CornCondition, Vector3)>();
private readonly ReactiveProperty<int> missCount = new ReactiveProperty<int>(); private readonly ReactiveProperty<int> missCount = new ReactiveProperty<int>();
private readonly ReactiveProperty<float> cornGrowSpeed = new FloatReactiveProperty(0f); private readonly ReactiveProperty<float> cornGrowSpeed = new FloatReactiveProperty(0f);
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable(); private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
@ -72,13 +72,13 @@ public class CornManager : MonoBehaviour
// コーン飛び出し制御 // コーン飛び出し制御
// 5フレームごとに2回など演出の回数を制御 // 5フレームごとに2回など演出の回数を制御
cornSpilledSubject cornSpilledSubject
.Where(x => x != CornCondition.Seed) // Seedは演出なし .Where(x => x.cond != CornCondition.Seed) // Seedは演出なし
.BatchFrame(5, FrameCountType.EndOfFrame) // 指定フレーム分まとめる .BatchFrame(5, FrameCountType.EndOfFrame) // 指定フレーム分まとめる
.Subscribe(x => .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); }).AddTo(this);
@ -192,11 +192,7 @@ public class CornManager : MonoBehaviour
}).AddTo(compositeDisposable); }).AddTo(compositeDisposable);
corn.Spilled corn.Spilled
.Subscribe(_ => .Subscribe(_ => cornSpilledSubject.OnNext((corn.Condition.Value, corn.transform.position))).AddTo(compositeDisposable);
{
// 同時に飛び出したとき用に演出をばらつかせる
corn.CallWaitForSeconds(Random.Range(0f, .5f), () => cornSpilledSubject.OnNext(corn.Condition.Value));
}).AddTo(compositeDisposable);
cornConditions.Add(corn.Condition); 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再生 // 画面KO再生
var animation = Instantiate(spilledCornAnimationPrefab, position, Quaternion.identity); var animation = Instantiate(spilledCornAnimationPrefab, position, Quaternion.identity);
// KOコーンスキン変更 // KOコーンスキン変更