add AutoCookDialog
This commit is contained in:
parent
0610bfb4d6
commit
26a93aca78
|
|
@ -130,7 +130,7 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 185282311}
|
||||
- component: {fileID: 185282312}
|
||||
- component: {fileID: 185282313}
|
||||
m_Layer: 5
|
||||
m_Name: Window
|
||||
m_TagString: Untagged
|
||||
|
|
@ -159,7 +159,7 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 126}
|
||||
m_SizeDelta: {x: 780, y: 900}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &185282312
|
||||
--- !u!114 &185282313
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
|
|
@ -168,23 +168,16 @@ MonoBehaviour:
|
|||
m_GameObject: {fileID: 185282310}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 48fa1fc1b2ab4b229d8f7b26b9ad2401, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: e9acbaa05b4d40fabd5a33eb7f3ba676, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
backgroundAnimator: {fileID: 1266368101}
|
||||
closeButton: {fileID: 1177471513}
|
||||
okButton: {fileID: 1725004924}
|
||||
messageText: {fileID: 1771385233}
|
||||
narrowCloseButton: {fileID: 0}
|
||||
narrowOkButton: {fileID: 0}
|
||||
narrowMessageText: {fileID: 0}
|
||||
normalWindow: {fileID: 185282310}
|
||||
narrowWindow: {fileID: 0}
|
||||
movieObject: {fileID: 564427509}
|
||||
coinObject: {fileID: 299394113}
|
||||
fertilizerObject: {fileID: 0}
|
||||
publicityObject: {fileID: 0}
|
||||
vipObject: {fileID: 0}
|
||||
movieButton: {fileID: 1725004924}
|
||||
cookerLevelText: {fileID: 1771385233}
|
||||
earnCountText: {fileID: 1165270082}
|
||||
remainingTimeText: {fileID: 445717700}
|
||||
usesCountText: {fileID: 1667839400}
|
||||
--- !u!1001 &198950442
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using MyGame.Scripts;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace MyGame.Scenes.Main.Scripts
|
||||
{
|
||||
public class AutoCookDialog : MonoBehaviour
|
||||
{
|
||||
private static readonly string CallbackTag = "AutoCookDialogCallback";
|
||||
private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger");
|
||||
private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger");
|
||||
|
||||
[SerializeField] private Animator backgroundAnimator;
|
||||
[SerializeField] private Button closeButton;
|
||||
[SerializeField] private Button movieButton;
|
||||
|
||||
[SerializeField] private Text cookerLevelText;
|
||||
[SerializeField] private Text earnCountText;
|
||||
[SerializeField] private Text remainingTimeText;
|
||||
[SerializeField] private Text usesCountText;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var gameData = GameDataManager.GameData;
|
||||
var autoCookDataList = SpreadsheetDataManager.Instance.GetBaseDataList<AutoCookData>(Const.AutoCookDataSheet);
|
||||
var autoCookData = autoCookDataList.First(data => data.level == gameData.AutoCookLevel);
|
||||
|
||||
closeButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||
{
|
||||
LocalCacheManager.Load<Action>(CallbackTag, null)?.Invoke();
|
||||
LocalCacheManager.Remove(CallbackTag);
|
||||
transform.parent.SetLocalScale(0);
|
||||
backgroundAnimator.SetTrigger(CloseTrigger);
|
||||
this.CallWaitForSeconds(.25f, () =>
|
||||
{
|
||||
TransitionManager.Instance.UnloadScene(GameScenes.AutomaticCookingMovie);
|
||||
});
|
||||
}).AddTo(this);
|
||||
movieButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||
{
|
||||
GetRewardDialog.ShowRewardVideo(GameScenes.AutomaticCookingMovie, AdManager.AD_PLACEMENT_AUTO, () =>
|
||||
{
|
||||
// 自動調理開始
|
||||
gameData.AutoCookFinishTime = DateTime.UtcNow.AddHours(autoCookData.duration).ToBinary();
|
||||
// レシピをランダムに並び替えて保存
|
||||
gameData.AutoCookProducts = gameData.MyRecipes.OrderBy(x => Random.value).ToArray();
|
||||
GameDataManager.SaveGameData();
|
||||
});
|
||||
}).AddTo(this);
|
||||
|
||||
cookerLevelText.text = $"{gameData.AutoCookLevel}";
|
||||
earnCountText.text = $"{autoCookData.earnCount}個";
|
||||
remainingTimeText.text = $"{DateTime.FromBinary(GameDataManager.GameData.AutoCookFinishTime).Subtract(DateTime.UtcNow).TotalHours}時間";
|
||||
usesCountText.text = $"{gameData.AutoCookUsesCount}/{autoCookData.clearCount}";
|
||||
}
|
||||
|
||||
public static void ShowDialog(Action onClose = null){
|
||||
LocalCacheManager.Save(CallbackTag, onClose);
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.AutomaticCookingMovie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e9acbaa05b4d40fabd5a33eb7f3ba676
|
||||
timeCreated: 1649901581
|
||||
Loading…
Reference in New Issue