ゲーム進捗で判定が変化する機能追加

This commit is contained in:
kimura 2022-04-22 17:44:30 +09:00
parent e849907ef7
commit 19ce5ce261
3 changed files with 44 additions and 3 deletions

View File

@ -4309,6 +4309,9 @@ MonoBehaviour:
thermalControl: {fileID: 1870432535}
thermoMeter: {fileID: 1928679192}
cornManager: {fileID: 1870432536}
panColliderChanger: {fileID: 2137549896}
gameProgress: 0
resultDelay: 1.8
--- !u!4 &1870432534
Transform:
m_ObjectHideFlags: 0
@ -4904,6 +4907,18 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 2137549891}
m_PrefabAsset: {fileID: 0}
--- !u!114 &2137549896 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 6144151140781756319, guid: b6b05cbc51c744ac2ad95a8b229d4ddd,
type: 3}
m_PrefabInstance: {fileID: 2137549891}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0921292620c649ef8f75f013ff51c349, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &2603874726320550220
GameObject:
m_ObjectHideFlags: 0

View File

@ -38,7 +38,10 @@ public class CornManager : MonoBehaviour
public ReactiveProperty<GameState> GameState => gameState;
private readonly ReactiveProperty<GameState> gameState = new ReactiveProperty<GameState>();
public IReadOnlyReactiveProperty<float> Progress => progress;
private readonly ReactiveProperty<float> progress = new ReactiveProperty<float>(0f);
private Corn[] cornArray;
private bool isHot;
private bool isCompleted;
@ -65,6 +68,8 @@ public class CornManager : MonoBehaviour
{
cornArray = new Corn[cornSpawnCount];
result.AddTo(this);
gameState.AddTo(this);
progress.AddTo(this);
cornGrowSpeed.AddTo(this);
compositeDisposable.AddTo(this);
}
@ -126,6 +131,7 @@ public class CornManager : MonoBehaviour
isCompleted = false;
compositeDisposable.Clear();
cornConditions.Clear();
progress.Value = 0f;
for (int i = 0; i < cornArray.Length; i++)
{
if (cornArray[i] != null)
@ -197,6 +203,13 @@ public class CornManager : MonoBehaviour
var cornConditionsObservable = Observable.CombineLatest(cornConditions).Publish().RefCount();
cornConditionsObservable
.Select(x => x.Count(cond => cond != CornCondition.Seed))
.Subscribe(x =>
{
progress.Value = (float)x / cornArray.Length;
}).AddTo(compositeDisposable);
// すべてのコーンが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}");})

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MyGame.Scenes.Cooking.Scripts;
using MyGame.Scripts;
using UniRx;
using UniRx.Diagnostics;
@ -29,7 +30,12 @@ public class PopcornGameManager : MonoBehaviour
[SerializeField] private ThermalControl thermalControl;
[SerializeField] private ThermoMeter thermoMeter;
[SerializeField] private CornManager cornManager;
[SerializeField] private PanColliderChanger panColliderChanger;
[Space]
[SerializeField, ReadOnly] private float gameProgress;
[SerializeField] private float resultDelay = 1.2f;
private readonly ReactiveProperty<GameState> state = new ReactiveProperty<GameState>(GameState.Guide);
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
@ -70,6 +76,12 @@ public class PopcornGameManager : MonoBehaviour
throw new ArgumentOutOfRangeException(nameof(x), x, null);
}
});
cornManager.Progress.Subscribe(x =>
{
gameProgress = x;
panColliderChanger.ChangeState(x);
}).AddTo(this);
ResetGame();
@ -120,6 +132,7 @@ public class PopcornGameManager : MonoBehaviour
gameView.SetPan(panData.GetPrefab());
thermalControl.SetPanData(panData);
cornManager.SetCornsActive(true);
panColliderChanger.Reset();
compositeDisposable.Clear();
cornManager.Result.SkipLatestValueOnSubscribe()
.Take(1)
@ -127,7 +140,7 @@ public class PopcornGameManager : MonoBehaviour
{
state.Value = GameState.Result;
// リザルト表示遅延
Observable.Timer(TimeSpan.FromSeconds(1.2f)).Subscribe(_ =>
Observable.Timer(TimeSpan.FromSeconds(resultDelay)).Subscribe(_ =>
{
LocalCacheManager.Save(CookingResultDataTag, (rarityData, result, new Action(() => cornManager.SetCornsActive(false))));
LocalCacheManager.Save(RestartCallbackTag, new Action(ResetGame));