main に自動調理処理追加
This commit is contained in:
parent
70854541b9
commit
3d4ca9f428
|
|
@ -367,6 +367,18 @@ Animator:
|
|||
m_HasTransformHierarchy: 1
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorControllerStateOnDisable: 0
|
||||
--- !u!114 &249665956 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 7685984615756169863, guid: caaa748dbeed576499e8cae74d33f689,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 3664916832445709976}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &251891026
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -6351,6 +6363,7 @@ MonoBehaviour:
|
|||
adButton: {fileID: 445566315}
|
||||
kitchenView: {fileID: 1870432536}
|
||||
orderIndicatorView: {fileID: 2021031102}
|
||||
autoCookView: {fileID: 2088316432}
|
||||
--- !u!4 &1870432534
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -7313,6 +7326,7 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2088316431}
|
||||
- component: {fileID: 2088316432}
|
||||
m_Layer: 0
|
||||
m_Name: AutomaticCooking
|
||||
m_TagString: Untagged
|
||||
|
|
@ -7340,6 +7354,26 @@ Transform:
|
|||
m_Father: {fileID: 2082561918}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2088316432
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2088316430}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c9365f427d5d4c1da76ea03b91840c7a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
cookAnimator: {fileID: 178476878}
|
||||
progressImages:
|
||||
- {fileID: 1928899247}
|
||||
- {fileID: 546637092}
|
||||
- {fileID: 1886098664}
|
||||
- {fileID: 758194584}
|
||||
- {fileID: 278785268}
|
||||
autoCookButton: {fileID: 249665956}
|
||||
--- !u!1 &2124297503
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace MyGame.Scenes.Main.Scripts
|
||||
{
|
||||
public enum CookState
|
||||
{
|
||||
Ready,
|
||||
Progress,
|
||||
Complete
|
||||
}
|
||||
public class AutoCookView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Animator cookAnimator;
|
||||
[SerializeField] private GameObject[] progressImages;
|
||||
[SerializeField] private Button autoCookButton;
|
||||
|
||||
public IObservable<Unit> Button => autoCookButton.OnClickAsObservable().TakeUntilDestroy(this);
|
||||
private IDisposable timerDisposable;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
cookAnimator.enabled = false;
|
||||
SetProgress(0f);
|
||||
}
|
||||
|
||||
public void SetActive(bool active)
|
||||
{
|
||||
autoCookButton.gameObject.SetActive(active);
|
||||
gameObject.SetActive(active);
|
||||
}
|
||||
|
||||
private void SetProgress(float value)
|
||||
{
|
||||
// Debug.Log($"setprogress:{value}");
|
||||
var border = Mathf.FloorToInt(progressImages.Length * Mathf.Clamp01(value));
|
||||
for (var i = 0; i < progressImages.Length; i++)
|
||||
{
|
||||
progressImages[i].SetActive(i + 1 == border);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetTimer(int remainingTime, int duration)
|
||||
{
|
||||
cookAnimator.enabled = true;
|
||||
SetProgress(1f - (float)remainingTime/duration);
|
||||
// タイマーの更新処理
|
||||
timerDisposable?.Dispose();
|
||||
timerDisposable = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f))
|
||||
.Select(x => (int)(remainingTime - x))
|
||||
.TakeWhile(x => x > 0)
|
||||
.Subscribe(x =>
|
||||
{
|
||||
SetProgress(1f - (float)x/duration);
|
||||
}, () =>
|
||||
{
|
||||
cookAnimator.enabled = false;
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
public void ShowDialog(CookState state, Action onClose = null)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case CookState.Ready:
|
||||
AutoCookDialog.ShowDialog(onClose);
|
||||
break;
|
||||
case CookState.Progress:
|
||||
AutoCookProgressView.ShowDialog();
|
||||
break;
|
||||
case CookState.Complete:
|
||||
AutoCookCompleteView.ShowDialog();
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c9365f427d5d4c1da76ea03b91840c7a
|
||||
timeCreated: 1649983197
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MyGame.Scenes.Main.Scripts;
|
||||
using MyGame.Scripts;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
|
|
@ -19,6 +20,7 @@ public class KitchenManager : MonoBehaviour
|
|||
[SerializeField] private Button adButton;
|
||||
[SerializeField] private KitchenView kitchenView;
|
||||
[SerializeField] private BulkOrderIndicatorView orderIndicatorView;
|
||||
[SerializeField] private AutoCookView autoCookView;
|
||||
|
||||
private readonly Subject<Unit> showAdDialogSubject = new Subject<Unit>();
|
||||
private IDisposable timerDisposable = null;
|
||||
|
|
@ -68,6 +70,58 @@ public class KitchenManager : MonoBehaviour
|
|||
BulkOrderShowDialogWithSetup();
|
||||
}
|
||||
|
||||
// 自動調理
|
||||
autoCookView.Initialize();
|
||||
// レベル確認
|
||||
autoCookView.SetActive(gameData.ViewedShopLevel >= Const.AutoCookAvailableLevel);
|
||||
|
||||
var autoCookDataList = SpreadsheetDataManager.Instance.GetBaseDataList<AutoCookData>(Const.AutoCookDataSheet);
|
||||
if (autoCookDataList.FirstOrDefault(data => data.level == gameData.AutoCookLevel) is AutoCookData autoCookData)
|
||||
{
|
||||
CookState state;
|
||||
var remainingTime = DateTime.FromBinary(gameData.AutoCookFinishTime).Subtract(DateTime.UtcNow);
|
||||
var isReady = gameData.AutoCookProducts.Length == 0;
|
||||
if (!isReady)
|
||||
{
|
||||
autoCookView.ResetTimer((int)remainingTime.TotalSeconds, autoCookData.duration);
|
||||
}
|
||||
autoCookView.Button.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
||||
{
|
||||
// 自動調理チュートリアル
|
||||
if (!gameData.FinishedFlags.HasFlag(TutorialFlag.AutoCook))
|
||||
{
|
||||
TutorialManager.Instance.ShowTutorialConversation(14, () =>
|
||||
{
|
||||
gameData.FinishedFlags |= TutorialFlag.AutoCook;
|
||||
GameDataManager.SaveGameData();
|
||||
autoCookView.ShowDialog(CookState.Ready);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
remainingTime = DateTime.FromBinary(gameData.AutoCookFinishTime).Subtract(DateTime.UtcNow);
|
||||
isReady = gameData.AutoCookProducts.Length == 0;
|
||||
var isFinished = remainingTime.TotalSeconds <= 0;
|
||||
if (isReady)
|
||||
{
|
||||
state = CookState.Ready;
|
||||
}
|
||||
else if (isFinished)
|
||||
{
|
||||
state = CookState.Complete;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = CookState.Progress;
|
||||
}
|
||||
|
||||
autoCookView.ShowDialog(state, () =>
|
||||
{
|
||||
autoCookView.ResetTimer((int)remainingTime.TotalSeconds, autoCookData.duration);
|
||||
});
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
// tutorial
|
||||
if (!gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
||||
{
|
||||
|
|
@ -136,6 +190,7 @@ public class KitchenManager : MonoBehaviour
|
|||
{
|
||||
kitchenView.SetActive(true);
|
||||
CheckOrderAndSetPhoneTap();
|
||||
autoCookView.SetActive(gameData.ViewedShopLevel >= Const.AutoCookAvailableLevel);
|
||||
});
|
||||
}).AddTo(this);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue