失敗時の条件修正
This commit is contained in:
parent
5b4aa17d44
commit
9bdb0e20db
|
|
@ -16,6 +16,7 @@ public class CornManager : MonoBehaviour
|
|||
[SerializeField] private Transform cornSpawnTarget;
|
||||
[SerializeField] private Corn cornPrefab;
|
||||
[SerializeField] private int cornSpawnCount = 20;
|
||||
[SerializeField] private int maxFailedCornCount = 10;
|
||||
[SerializeField, ReadOnly] private float baseGrowSpeed = 1f;
|
||||
[SerializeField] private float hotGrowSpeed;
|
||||
[SerializeField] private float baseCornPopTime = 5f;
|
||||
|
|
@ -88,24 +89,35 @@ public class CornManager : MonoBehaviour
|
|||
cornConditions.Add(corn.Condition);
|
||||
}
|
||||
|
||||
// すべてのコーンがSeedではなくなったら通知
|
||||
Observable.CombineLatest(cornConditions)
|
||||
var cornConditionsObservable = Observable.CombineLatest(cornConditions).Publish().RefCount();
|
||||
|
||||
// 焦げたコーンorフライパンを飛び出したコーンが設定値を超えるとFailure
|
||||
cornConditionsObservable
|
||||
.FirstOrDefault(x => x.Count(c => c == CornCondition.Burnt || c == CornCondition.Spilled) >= maxFailedCornCount)
|
||||
.Subscribe(x =>
|
||||
{
|
||||
if (x == null) return;
|
||||
SetResult(CornResult.Failure);
|
||||
})
|
||||
.AddTo(compositeDisposable);
|
||||
|
||||
// すべてのコーンがSeedではなくなった場合
|
||||
cornConditionsObservable
|
||||
.FirstOrDefault(x => !x.Contains(CornCondition.Seed))
|
||||
.Subscribe(x =>
|
||||
{
|
||||
cornGrowSpeed.Value = 0f;
|
||||
isCompleted = true;
|
||||
if (x == null) return;
|
||||
if (x.Count(c => c == CornCondition.Simple) == x.Count) // すべてのコーンがPopped
|
||||
{
|
||||
result.SetValueAndForceNotify(CornResult.Perfect);
|
||||
SetResult(CornResult.Perfect);
|
||||
}
|
||||
else if (x.Count(c => c == CornCondition.Simple) == 0) // すべてのコーンが飛び出した OR すべて焦げた
|
||||
{
|
||||
result.SetValueAndForceNotify(CornResult.Failure);
|
||||
SetResult(CornResult.Failure);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.SetValueAndForceNotify(CornResult.Good);
|
||||
SetResult(CornResult.Good);
|
||||
}
|
||||
}).AddTo(compositeDisposable);
|
||||
}
|
||||
|
|
@ -130,4 +142,11 @@ public class CornManager : MonoBehaviour
|
|||
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetResult(CornResult resultValue)
|
||||
{
|
||||
cornGrowSpeed.Value = 0f;
|
||||
isCompleted = true;
|
||||
result.SetValueAndForceNotify(resultValue);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue