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