フライパンゲームチュートリアル追加
This commit is contained in:
parent
2bc9cdbccb
commit
e13e506b9b
|
|
@ -41,6 +41,32 @@ public class CookingResult : MonoBehaviour
|
||||||
var (rarityData, resultData, successAction) = LocalCacheManager.Load<(RarityData, CornResult, Action)>(PopcornGameManager.CookingResultDataTag);
|
var (rarityData, resultData, successAction) = LocalCacheManager.Load<(RarityData, CornResult, Action)>(PopcornGameManager.CookingResultDataTag);
|
||||||
result.Value = resultData;
|
result.Value = resultData;
|
||||||
SetData(productData, rarityData, viewType);
|
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 =>
|
result.Subscribe(r =>
|
||||||
{
|
{
|
||||||
SetUI(r, rarityData.Rarity != ProductRarity.Normal);
|
SetUI(r, rarityData.Rarity != ProductRarity.Normal);
|
||||||
|
|
@ -123,21 +149,24 @@ public class CookingResult : MonoBehaviour
|
||||||
Instantiate(recipe.GetLargePrefab(), popcornTarget);
|
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);
|
centerOkButton.gameObject.SetActive(false);
|
||||||
perfectButton.gameObject.SetActive(false);
|
perfectButton.gameObject.SetActive(false);
|
||||||
leftOkButton.gameObject.SetActive(false);
|
leftOkButton.gameObject.SetActive(false);
|
||||||
destructionButton.gameObject.SetActive(false);
|
destructionButton.gameObject.SetActive(false);
|
||||||
|
|
||||||
this.CallWaitForSeconds(1.25f, () =>
|
if (!isTutorial)
|
||||||
{
|
{
|
||||||
centerOkButton.gameObject.SetActive(result == CornResult.Perfect);
|
this.CallWaitForSeconds(1.25f, () =>
|
||||||
perfectButton.gameObject.SetActive(result != CornResult.Perfect);
|
{
|
||||||
leftOkButton.gameObject.SetActive(result == CornResult.Good);
|
centerOkButton.gameObject.SetActive(result == CornResult.Perfect);
|
||||||
destructionButton.gameObject.SetActive(result == CornResult.Failure);
|
perfectButton.gameObject.SetActive(result != CornResult.Perfect);
|
||||||
});
|
leftOkButton.gameObject.SetActive(result == CornResult.Good);
|
||||||
|
destructionButton.gameObject.SetActive(result == CornResult.Failure);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
perfectResultObject.SetActive(result == CornResult.Perfect);
|
perfectResultObject.SetActive(result == CornResult.Perfect);
|
||||||
goodResultObject.SetActive(result == CornResult.Good);
|
goodResultObject.SetActive(result == CornResult.Good);
|
||||||
failureResultObject.SetActive(result == CornResult.Failure);
|
failureResultObject.SetActive(result == CornResult.Failure);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MyGame.Scripts;
|
||||||
using UniRx;
|
using UniRx;
|
||||||
using UniRx.Triggers;
|
using UniRx.Triggers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -9,6 +10,7 @@ using UnityEngine.UI;
|
||||||
|
|
||||||
public enum GameState
|
public enum GameState
|
||||||
{
|
{
|
||||||
|
TutorialBeforeGuide,
|
||||||
Guide,
|
Guide,
|
||||||
Playing,
|
Playing,
|
||||||
Result
|
Result
|
||||||
|
|
@ -19,6 +21,7 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
public static readonly string CookingDataTag = "CookingData";
|
public static readonly string CookingDataTag = "CookingData";
|
||||||
public static readonly string PanDataTag = "PanData";
|
public static readonly string PanDataTag = "PanData";
|
||||||
public static readonly string CookingResultDataTag = "CookingResultData";
|
public static readonly string CookingResultDataTag = "CookingResultData";
|
||||||
|
public static readonly string RestartCallbackTag = "PopcornGameManagerRestartCallback";
|
||||||
// View
|
// View
|
||||||
[SerializeField] private PopcornGameView gameView;
|
[SerializeField] private PopcornGameView gameView;
|
||||||
|
|
||||||
|
|
@ -53,8 +56,9 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
gameView.ChangeUI(x);
|
gameView.ChangeUI(x);
|
||||||
switch (x)
|
switch (x)
|
||||||
{
|
{
|
||||||
|
case GameState.TutorialBeforeGuide:
|
||||||
case GameState.Guide:
|
case GameState.Guide:
|
||||||
thermalControl.ResetMeter();
|
thermalControl.ResetMeter(GameDataManager.GameData.isFirstPlay);
|
||||||
thermoMeter.gameObject.SetActive(false);
|
thermoMeter.gameObject.SetActive(false);
|
||||||
cornManager.RespawnCorn();
|
cornManager.RespawnCorn();
|
||||||
break;
|
break;
|
||||||
|
|
@ -71,6 +75,20 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
});
|
});
|
||||||
|
|
||||||
ResetGame();
|
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
|
#if DEVELOPMENT_BUILD || UNITY_EDITOR
|
||||||
resetButton.OnClickAsObservable().Subscribe(_ =>
|
resetButton.OnClickAsObservable().Subscribe(_ =>
|
||||||
|
|
@ -111,7 +129,6 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
// フライパン設定
|
// フライパン設定
|
||||||
gameView.SetPan(panData.GetPrefab());
|
gameView.SetPan(panData.GetPrefab());
|
||||||
thermalControl.SetPanData(panData);
|
thermalControl.SetPanData(panData);
|
||||||
// setPanData();
|
|
||||||
cornManager.SetCornsActive(true);
|
cornManager.SetCornsActive(true);
|
||||||
compositeDisposable.Clear();
|
compositeDisposable.Clear();
|
||||||
cornManager.Result.SkipLatestValueOnSubscribe()
|
cornManager.Result.SkipLatestValueOnSubscribe()
|
||||||
|
|
@ -124,6 +141,7 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
this.CallWaitForSeconds(1.2f, () =>
|
this.CallWaitForSeconds(1.2f, () =>
|
||||||
{
|
{
|
||||||
LocalCacheManager.Save(CookingResultDataTag, (rarityData, result, new Action(() => cornManager.SetCornsActive(false))));
|
LocalCacheManager.Save(CookingResultDataTag, (rarityData, result, new Action(() => cornManager.SetCornsActive(false))));
|
||||||
|
LocalCacheManager.Save(RestartCallbackTag, new Action(ResetGame));
|
||||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.CookingResults);
|
TransitionManager.Instance.LoadSceneAdditive(GameScenes.CookingResults);
|
||||||
});
|
});
|
||||||
}).AddTo(compositeDisposable);
|
}).AddTo(compositeDisposable);
|
||||||
|
|
@ -133,7 +151,8 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
.Select(_ => Input.GetMouseButton(0))
|
.Select(_ => Input.GetMouseButton(0))
|
||||||
.DistinctUntilChanged()
|
.DistinctUntilChanged()
|
||||||
.Skip(1)
|
.Skip(1)
|
||||||
.FirstOrDefault(b => b)
|
.Where(_ => state.Value == GameState.Guide)
|
||||||
|
.Take(1)
|
||||||
.Subscribe(_ =>
|
.Subscribe(_ =>
|
||||||
{
|
{
|
||||||
state.Value = GameState.Playing;
|
state.Value = GameState.Playing;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,13 @@ public class PopcornGameView : MonoBehaviour
|
||||||
{
|
{
|
||||||
switch (state)
|
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:
|
case GameState.Guide:
|
||||||
SoundManager.Instance.StopSELoop("se_cooking_corn_bake");
|
SoundManager.Instance.StopSELoop("se_cooking_corn_bake");
|
||||||
ChangeGuideState(true);
|
ChangeGuideState(true);
|
||||||
|
|
|
||||||
|
|
@ -145,22 +145,32 @@ public class ThermalControl : MonoBehaviour
|
||||||
return ThermalCondition.Yellow;
|
return ThermalCondition.Yellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetMeterValue()
|
private void SetMeterValue(bool isTutorial = false)
|
||||||
{
|
{
|
||||||
// Todo 初回プレイ時は中央
|
float yellowPos;
|
||||||
var yellowPos = Random.Range(-randomRange, randomRange) + .5f;
|
float halfYellowSize;
|
||||||
var halfYellowSize = yellowSize / 2;
|
// チュートリアル時中央固定
|
||||||
|
if (isTutorial)
|
||||||
|
{
|
||||||
|
yellowPos = .5f;
|
||||||
|
halfYellowSize = .4f / 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yellowPos = Random.Range(-randomRange, randomRange) + .5f;
|
||||||
|
halfYellowSize = yellowSize / 2;
|
||||||
|
}
|
||||||
coldValue = Mathf.Max(0f, yellowPos - halfYellowSize);
|
coldValue = Mathf.Max(0f, yellowPos - halfYellowSize);
|
||||||
hotValue = Mathf.Min(1f, yellowPos + halfYellowSize);
|
hotValue = Mathf.Min(1f, yellowPos + halfYellowSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetMeter()
|
public void ResetMeter(bool isTutorial = false)
|
||||||
{
|
{
|
||||||
isMove = false;
|
isMove = false;
|
||||||
temperatureSpeed = 0f;
|
temperatureSpeed = 0f;
|
||||||
temperature = 0f;
|
temperature = 0f;
|
||||||
thermoMeter.SetValue(temperature);
|
thermoMeter.SetValue(temperature);
|
||||||
SetMeterValue();
|
SetMeterValue(isTutorial);
|
||||||
thermoMeter.SetScale(coldValue, hotValue);
|
thermoMeter.SetScale(coldValue, hotValue);
|
||||||
panController.ResetTargetPosition();
|
panController.ResetTargetPosition();
|
||||||
panController.enabled = true;
|
panController.enabled = true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue