From e13e506b9b509251a34be4ca11c160ee912d77a3 Mon Sep 17 00:00:00 2001 From: kimura Date: Tue, 26 Oct 2021 18:18:07 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=83=A9=E3=82=A4=E3=83=91=E3=83=B3?= =?UTF-8?q?=E3=82=B2=E3=83=BC=E3=83=A0=E3=83=81=E3=83=A5=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=83=AA=E3=82=A2=E3=83=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Cooking/Scripts/CookingResult.cs | 45 +++++++++++++++---- .../Cooking/Scripts/PopcornGameManager.cs | 25 +++++++++-- .../Scenes/Cooking/Scripts/PopcornGameView.cs | 7 +++ .../Scenes/Cooking/Scripts/ThermalControl.cs | 22 ++++++--- 4 files changed, 82 insertions(+), 17 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CookingResult.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CookingResult.cs index e495b6bc..fe15a2ae 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CookingResult.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CookingResult.cs @@ -41,6 +41,32 @@ public class CookingResult : MonoBehaviour var (rarityData, resultData, successAction) = LocalCacheManager.Load<(RarityData, CornResult, Action)>(PopcornGameManager.CookingResultDataTag); result.Value = resultData; SetData(productData, rarityData, viewType); + + if (GameDataManager.GameData.isFirstPlay) + { + SetUI(resultData, rarityData.Rarity != ProductRarity.Normal, true); + // ボタン非表示 + if (resultData == CornResult.Failure) + { + TutorialManager.Instance.ShowTutorialConversation(9, () => + { + TransitionManager.Instance.UnloadScene(GameScenes.CookingResults); + LocalCacheManager.Load(PopcornGameManager.RestartCallbackTag, null)?.Invoke(); + }); + } + else + { + centerOkButton.gameObject.SetActive(true); + centerOkButton.OnClickAsObservable().Subscribe(_ => + { + // 獲得、遷移 + AddStock(productData, rarityData.Rarity); + TransitionManager.Instance.LoadScene(GameScenes.Main); + }).AddTo(this); + } + return; + } + result.Subscribe(r => { SetUI(r, rarityData.Rarity != ProductRarity.Normal); @@ -123,21 +149,24 @@ public class CookingResult : MonoBehaviour Instantiate(recipe.GetLargePrefab(), popcornTarget); } - private void SetUI(CornResult result, bool hasRarity) + private void SetUI(CornResult result, bool hasRarity, bool isTutorial = false) { centerOkButton.gameObject.SetActive(false); perfectButton.gameObject.SetActive(false); leftOkButton.gameObject.SetActive(false); destructionButton.gameObject.SetActive(false); - this.CallWaitForSeconds(1.25f, () => + if (!isTutorial) { - centerOkButton.gameObject.SetActive(result == CornResult.Perfect); - perfectButton.gameObject.SetActive(result != CornResult.Perfect); - leftOkButton.gameObject.SetActive(result == CornResult.Good); - destructionButton.gameObject.SetActive(result == CornResult.Failure); - }); - + this.CallWaitForSeconds(1.25f, () => + { + centerOkButton.gameObject.SetActive(result == CornResult.Perfect); + perfectButton.gameObject.SetActive(result != CornResult.Perfect); + leftOkButton.gameObject.SetActive(result == CornResult.Good); + destructionButton.gameObject.SetActive(result == CornResult.Failure); + }); + } + perfectResultObject.SetActive(result == CornResult.Perfect); goodResultObject.SetActive(result == CornResult.Good); failureResultObject.SetActive(result == CornResult.Failure); diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PopcornGameManager.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PopcornGameManager.cs index 570301d1..c83833e2 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.Scripts; using UniRx; using UniRx.Triggers; using UnityEngine; @@ -9,6 +10,7 @@ using UnityEngine.UI; public enum GameState { + TutorialBeforeGuide, Guide, Playing, Result @@ -19,6 +21,7 @@ public class PopcornGameManager : MonoBehaviour public static readonly string CookingDataTag = "CookingData"; public static readonly string PanDataTag = "PanData"; public static readonly string CookingResultDataTag = "CookingResultData"; + public static readonly string RestartCallbackTag = "PopcornGameManagerRestartCallback"; // View [SerializeField] private PopcornGameView gameView; @@ -53,8 +56,9 @@ public class PopcornGameManager : MonoBehaviour gameView.ChangeUI(x); switch (x) { + case GameState.TutorialBeforeGuide: case GameState.Guide: - thermalControl.ResetMeter(); + thermalControl.ResetMeter(GameDataManager.GameData.isFirstPlay); thermoMeter.gameObject.SetActive(false); cornManager.RespawnCorn(); break; @@ -71,6 +75,20 @@ public class PopcornGameManager : MonoBehaviour }); ResetGame(); + + if (GameDataManager.GameData.isFirstPlay) + { + if (TutorialManager.Instance.Index == 7) + { + cornManager.SetCornsActive(false); + state.SetValueAndForceNotify(GameState.TutorialBeforeGuide); + TutorialManager.Instance.ShowTutorialConversation(8, () => + { + state.SetValueAndForceNotify(GameState.Guide); + cornManager.SetCornsActive(true); + }); + } + } #if DEVELOPMENT_BUILD || UNITY_EDITOR resetButton.OnClickAsObservable().Subscribe(_ => @@ -111,7 +129,6 @@ public class PopcornGameManager : MonoBehaviour // フライパン設定 gameView.SetPan(panData.GetPrefab()); thermalControl.SetPanData(panData); - // setPanData(); cornManager.SetCornsActive(true); compositeDisposable.Clear(); cornManager.Result.SkipLatestValueOnSubscribe() @@ -124,6 +141,7 @@ public class PopcornGameManager : MonoBehaviour this.CallWaitForSeconds(1.2f, () => { LocalCacheManager.Save(CookingResultDataTag, (rarityData, result, new Action(() => cornManager.SetCornsActive(false)))); + LocalCacheManager.Save(RestartCallbackTag, new Action(ResetGame)); TransitionManager.Instance.LoadSceneAdditive(GameScenes.CookingResults); }); }).AddTo(compositeDisposable); @@ -133,7 +151,8 @@ public class PopcornGameManager : MonoBehaviour .Select(_ => Input.GetMouseButton(0)) .DistinctUntilChanged() .Skip(1) - .FirstOrDefault(b => b) + .Where(_ => state.Value == GameState.Guide) + .Take(1) .Subscribe(_ => { state.Value = GameState.Playing; diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PopcornGameView.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PopcornGameView.cs index 1603a7c8..6b08b86c 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PopcornGameView.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PopcornGameView.cs @@ -15,6 +15,13 @@ public class PopcornGameView : MonoBehaviour { switch (state) { + case GameState.TutorialBeforeGuide: + SoundManager.Instance.StopSELoop("se_cooking_corn_bake"); + ChangeGuideState(false); + ChangeFireState(false); + ChangeStreamState(false); + ChangeCharacterState(ThermalCondition.Cold); + break; case GameState.Guide: SoundManager.Instance.StopSELoop("se_cooking_corn_bake"); ChangeGuideState(true); diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs index 33e2d2d3..9b870269 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs @@ -145,22 +145,32 @@ public class ThermalControl : MonoBehaviour return ThermalCondition.Yellow; } - private void SetMeterValue() + private void SetMeterValue(bool isTutorial = false) { - // Todo 初回プレイ時は中央 - var yellowPos = Random.Range(-randomRange, randomRange) + .5f; - var halfYellowSize = yellowSize / 2; + float yellowPos; + float halfYellowSize; + // チュートリアル時中央固定 + if (isTutorial) + { + yellowPos = .5f; + halfYellowSize = .4f / 2; + } + else + { + yellowPos = Random.Range(-randomRange, randomRange) + .5f; + halfYellowSize = yellowSize / 2; + } coldValue = Mathf.Max(0f, yellowPos - halfYellowSize); hotValue = Mathf.Min(1f, yellowPos + halfYellowSize); } - public void ResetMeter() + public void ResetMeter(bool isTutorial = false) { isMove = false; temperatureSpeed = 0f; temperature = 0f; thermoMeter.SetValue(temperature); - SetMeterValue(); + SetMeterValue(isTutorial); thermoMeter.SetScale(coldValue, hotValue); panController.ResetTargetPosition(); panController.enabled = true;