フライパンゲームチュートリアル追加

This commit is contained in:
kimura 2021-10-26 18:18:07 +09:00
parent 2bc9cdbccb
commit e13e506b9b
4 changed files with 82 additions and 17 deletions

View File

@ -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<Action>(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);

View File

@ -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;

View File

@ -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);

View File

@ -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;