挙動調整
This commit is contained in:
parent
badec02b7d
commit
7d7693bb66
|
|
@ -44,7 +44,6 @@ public class CornManager : MonoBehaviour
|
|||
private bool isCompleted;
|
||||
private readonly List<IObservable<CornCondition>> cornConditions = new List<IObservable<CornCondition>>();
|
||||
private readonly Subject<CornCondition> cornSpilledSubject = new Subject<CornCondition>();
|
||||
private readonly Subject<CornCondition> cornMissCountSubject = new Subject<CornCondition>();
|
||||
private readonly ReactiveProperty<int> missCount = new ReactiveProperty<int>();
|
||||
private readonly ReactiveProperty<float> cornGrowSpeed = new FloatReactiveProperty(0f);
|
||||
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||
|
|
@ -77,7 +76,6 @@ public class CornManager : MonoBehaviour
|
|||
// 5フレームごとに2回など演出の回数を制御
|
||||
cornSpilledSubject
|
||||
.Where(x => x != CornCondition.Seed) // Seedは演出なし
|
||||
.Where(_ => !isCompleted) // 終了後は飛び出さない
|
||||
.BatchFrame(5, FrameCountType.EndOfFrame) // 指定フレーム分まとめる
|
||||
.Subscribe(x =>
|
||||
{
|
||||
|
|
@ -87,23 +85,6 @@ public class CornManager : MonoBehaviour
|
|||
}
|
||||
}).AddTo(this);
|
||||
|
||||
// ミス通知
|
||||
cornMissCountSubject
|
||||
.Where(_ => !isCompleted)
|
||||
.Subscribe(x =>
|
||||
{
|
||||
SpawnMissAnimation(x);
|
||||
});
|
||||
|
||||
// ミス数メータ反映
|
||||
missCount
|
||||
.BatchFrame(2, FrameCountType.Update)
|
||||
.Select(x => x.Max())
|
||||
.Subscribe(x =>
|
||||
{
|
||||
cornMissMeter.SetMeter((float)x/maxFailedCornCount);
|
||||
}).AddTo(this);
|
||||
|
||||
// ミス数上限で失敗
|
||||
missCount
|
||||
.Where(x => x == maxFailedCornCount)
|
||||
|
|
@ -111,6 +92,7 @@ public class CornManager : MonoBehaviour
|
|||
{
|
||||
SetResult(CornResult.Failure);
|
||||
}).AddTo(this);
|
||||
|
||||
#if DEVELOPMENT_BUILD || UNITY_EDITOR
|
||||
cornCountSlider.wholeNumbers = true;
|
||||
cornCountSlider.value = cornSpawnCount;
|
||||
|
|
@ -171,6 +153,7 @@ public class CornManager : MonoBehaviour
|
|||
|
||||
|
||||
corn.Condition
|
||||
.Where(_ => !isCompleted) // 結果確定後通知抑制
|
||||
.Pairwise()
|
||||
.Subscribe(condition =>
|
||||
{
|
||||
|
|
@ -187,12 +170,16 @@ public class CornManager : MonoBehaviour
|
|||
}
|
||||
break;
|
||||
case CornCondition.Burnt:
|
||||
cornMissCountSubject.OnNext(condition.Current);
|
||||
// ミス数加算
|
||||
missCount.Value++;
|
||||
SpawnMissAnimation(condition.Current);
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
if (condition.Previous != CornCondition.Burnt)
|
||||
{
|
||||
cornMissCountSubject.OnNext(condition.Current);
|
||||
// ミス数加算
|
||||
missCount.Value++;
|
||||
SpawnMissAnimation(condition.Current);
|
||||
}
|
||||
// 同時に飛び出したとき用に演出をばらつかせる
|
||||
corn.CallWaitForSeconds(Random.Range(0f, .5f), () => cornSpilledSubject.OnNext(condition.Previous));
|
||||
|
|
@ -209,6 +196,7 @@ public class CornManager : MonoBehaviour
|
|||
|
||||
// すべてのコーンがSeedではなくなった場合
|
||||
cornConditionsObservable
|
||||
// .Do(x => { Debug.Log($"done:{x.Count(y => y != CornCondition.Seed):00} fail:{x.Count(y => y == CornCondition.Burnt || y == CornCondition.Spilled):00}");})
|
||||
.FirstOrDefault(x => !x.Contains(CornCondition.Seed))
|
||||
.Subscribe(x =>
|
||||
{
|
||||
|
|
@ -217,7 +205,7 @@ public class CornManager : MonoBehaviour
|
|||
{
|
||||
SetResult(CornResult.Perfect);
|
||||
}
|
||||
else if (x.Count(c => c == CornCondition.Simple) == 0) // すべてのコーンが飛び出した OR すべて焦げた
|
||||
else if (x.Count(c => c == CornCondition.Burnt || c == CornCondition.Spilled) >= maxFailedCornCount) // すべてのコーンが飛び出した OR すべて焦げた
|
||||
{
|
||||
SetResult(CornResult.Failure);
|
||||
}
|
||||
|
|
@ -263,20 +251,20 @@ public class CornManager : MonoBehaviour
|
|||
|
||||
private void SpawnMissAnimation(CornCondition condition)
|
||||
{
|
||||
var position = new Vector2(Random.Range(missEffectBounds.min.x, missEffectBounds.max.x), Random.Range(missEffectBounds.min.y, missEffectBounds.max.y));
|
||||
// ミス表示
|
||||
var position = new Vector2(Random.Range(missEffectBounds.min.x, missEffectBounds.max.x), Random.Range(missEffectBounds.min.y, missEffectBounds.max.y));
|
||||
var animation = Instantiate(missCornAnimationPrefab, position, Quaternion.identity, missTextSpawnTransform);
|
||||
animation.GetComponent<CornMissEffect>().ChangeSkin(condition);
|
||||
|
||||
this.CallWaitForSeconds(.5f, () =>
|
||||
{
|
||||
this.CallLerp(.2f, f =>
|
||||
{
|
||||
animation.transform.position = Vector3.Lerp(position, cornMissMeter.transform.position, f.EaseInQuadratic());
|
||||
animation.transform.position = Vector3.Lerp(position, cornMissMeter.transform.position, f.EaseInCubic());
|
||||
}, () =>
|
||||
{
|
||||
VibrationManager.Instance.PlayVibrationOnce();
|
||||
// 表示終了後ミス数加算
|
||||
missCount.Value++;
|
||||
cornMissMeter.SetMeter((float)missCount.Value/maxFailedCornCount);
|
||||
Destroy(animation);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,31 +8,33 @@ using UnityEngine.UI;
|
|||
public class CornMissMeter : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image missGauge;
|
||||
private float minValue = 0.08f;
|
||||
private static readonly float minValue = 0.08f;
|
||||
private static readonly float totalValue = 1 - minValue;
|
||||
private float prevValue;
|
||||
private float nextValue;
|
||||
private float elapsed;
|
||||
private float duration = .4f;
|
||||
private float duration = .3f;
|
||||
private void Start()
|
||||
{
|
||||
var totalValue = 1 - minValue;
|
||||
ResetMeter();
|
||||
this.UpdateAsObservable().Subscribe(x =>
|
||||
{
|
||||
missGauge.fillAmount = minValue + Mathf.Lerp(prevValue, nextValue, elapsed.EaseInQuadratic()) * totalValue;
|
||||
elapsed += Time.deltaTime / duration;
|
||||
missGauge.fillAmount = minValue + Mathf.Lerp(prevValue, nextValue, elapsed.EaseOutQuadratic()) * totalValue;
|
||||
elapsed = Mathf.Clamp01(elapsed + Time.deltaTime / duration);
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
public void SetMeter(float value, bool animated = true)
|
||||
{
|
||||
|
||||
nextValue = value;
|
||||
prevValue = missGauge.fillAmount;
|
||||
prevValue = (missGauge.fillAmount - minValue) / totalValue;
|
||||
elapsed = animated ? 0f : 1f;
|
||||
}
|
||||
|
||||
public void ResetMeter()
|
||||
{
|
||||
missGauge.fillAmount = minValue;
|
||||
SetMeter(0f, false);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue