From 64b300c4c6e971a1a0225d46bcc7c07e68b9abe4 Mon Sep 17 00:00:00 2001 From: kimura Date: Fri, 22 Apr 2022 17:44:30 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B2=E3=83=BC=E3=83=A0=E9=80=B2=E6=8D=97?= =?UTF-8?q?=E3=81=A7=E5=88=A4=E5=AE=9A=E3=81=8C=E5=A4=89=E5=8C=96=E3=81=99?= =?UTF-8?q?=E3=82=8B=E6=A9=9F=E8=83=BD=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/MyGame/Scenes/Cooking/Cooking.unity | 15 +++++++++++++++ .../Scenes/Cooking/Scripts/CornManager.cs | 15 ++++++++++++++- .../Cooking/Scripts/PopcornGameManager.cs | 17 +++++++++++++++-- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Cooking.unity b/popcorn/Assets/MyGame/Scenes/Cooking/Cooking.unity index 6344a11f..147829cd 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Cooking.unity +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Cooking.unity @@ -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 diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs index 793b5be6..05ede726 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs @@ -38,7 +38,10 @@ public class CornManager : MonoBehaviour public ReactiveProperty GameState => gameState; private readonly ReactiveProperty gameState = new ReactiveProperty(); - + + public IReadOnlyReactiveProperty Progress => progress; + private readonly ReactiveProperty progress = new ReactiveProperty(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}");}) diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PopcornGameManager.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PopcornGameManager.cs index dd39f273..7fc4138b 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PopcornGameManager.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PopcornGameManager.cs @@ -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 state = new ReactiveProperty(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));