add AutoCookCaution.cs
This commit is contained in:
parent
ca87c97318
commit
0bd7b74efd
|
|
@ -128,16 +128,66 @@ PrefabInstance:
|
|||
m_Modification:
|
||||
m_TransformParent: {fileID: 1707876981274895579}
|
||||
m_Modifications:
|
||||
- target: {fileID: 4223190801597337599, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801597337599, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801597337599, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801597337599, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801597337599, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 329
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801597337599, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801737283886, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801737283886, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801737283886, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801737283886, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801737283886, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 329
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801737283886, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4223190801807453305, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
|
|
@ -396,6 +446,90 @@ RectTransform:
|
|||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1580291474}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1580291476 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 413027507554482889, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1580291474}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2df417e1f2b649c2bd38ea6627e453f2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &1580291477 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 413027506448404572, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1580291474}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2df417e1f2b649c2bd38ea6627e453f2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &1580291478 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 413027506772110985, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1580291474}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2df417e1f2b649c2bd38ea6627e453f2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &1580291479 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 413027507580250462, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1580291474}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2df417e1f2b649c2bd38ea6627e453f2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &1580291480 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 413027507672086750, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1580291474}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2df417e1f2b649c2bd38ea6627e453f2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &1580291481 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 413027506800827693, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1580291474}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2df417e1f2b649c2bd38ea6627e453f2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &1580291482 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 413027506015082184, guid: 5f90e42166914c0b83b48c62b7e279e5,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1580291474}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2df417e1f2b649c2bd38ea6627e453f2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &1707876980489548924
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -479,6 +613,7 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1707876980637188849}
|
||||
- component: {fileID: 1707876980637188850}
|
||||
m_Layer: 5
|
||||
m_Name: Window
|
||||
m_TagString: Untagged
|
||||
|
|
@ -507,6 +642,29 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 72}
|
||||
m_SizeDelta: {x: 705, y: 900}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1707876980637188850
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1707876980637188848}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 837dd3250ce549a8af77a678f5218afe, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
backgroundAnimator: {fileID: 1707876980787449930}
|
||||
closeButton: {fileID: 1707876981116840883}
|
||||
getButton: {fileID: 1707876980958523552}
|
||||
popcorns:
|
||||
- {fileID: 1580291482}
|
||||
- {fileID: 1580291481}
|
||||
- {fileID: 1580291480}
|
||||
- {fileID: 1580291479}
|
||||
- {fileID: 1580291478}
|
||||
- {fileID: 1580291477}
|
||||
- {fileID: 1580291476}
|
||||
--- !u!1 &1707876980682129410
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace MyGame.Scenes.Main.Scripts
|
||||
{
|
||||
public class AutoCookCaution : MonoBehaviour
|
||||
{
|
||||
private static readonly string CallbackTag = "UpdateDialogCallback";
|
||||
public static readonly string AutoCookCompleteProductsTag = "AutoCookCompleteProducts";
|
||||
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 getButton;
|
||||
|
||||
[SerializeField] private AutoCookPopcornView[] popcorns;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var (earnList, discardList) = LocalCacheManager.Load<(IReadOnlyList<ProductData>, IReadOnlyList<ProductData>)>(AutoCookCompleteProductsTag);
|
||||
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.Remove(CallbackTag);
|
||||
TransitionManager.Instance.LoadScene(GameScenes.ProductManagement);
|
||||
}).AddTo(this);
|
||||
getButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||
{
|
||||
// コーン獲得
|
||||
foreach (var productData in earnList.Where(data => !discardList.Contains(data)))
|
||||
{
|
||||
CookingResult.AddStock(productData);
|
||||
}
|
||||
|
||||
// 自動調理セーブ
|
||||
gameData.AutoCookProducts = Array.Empty<int>();
|
||||
var maxLevel = autoCookDataList.Last().level;
|
||||
if (gameData.AutoCookLevel < maxLevel)
|
||||
{
|
||||
gameData.AutoCookUsesCount++;
|
||||
if (gameData.AutoCookUsesCount >= autoCookData.clearCount)
|
||||
{
|
||||
gameData.AutoCookUsesCount = 0;
|
||||
gameData.AutoCookLevel++;
|
||||
}
|
||||
}
|
||||
GameDataManager.SaveGameData();
|
||||
|
||||
LocalCacheManager.Load<Action>(CallbackTag, null)?.Invoke();
|
||||
LocalCacheManager.Remove(CallbackTag);
|
||||
transform.parent.SetLocalScale(0);
|
||||
backgroundAnimator.SetTrigger(CloseTrigger);
|
||||
this.CallWaitForSeconds(.25f, () =>
|
||||
{
|
||||
TransitionManager.Instance.UnloadScene(GameScenes.AutomaticCookingCaution);
|
||||
});
|
||||
}).AddTo(this);
|
||||
|
||||
// 完成したポップコーンを表示
|
||||
var productCount = discardList.Count;
|
||||
for (int i = 0; i < popcorns.Length; i++)
|
||||
{
|
||||
if (i < productCount)
|
||||
{
|
||||
popcorns[i].SetView(discardList[i]);
|
||||
popcorns[i].SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
popcorns[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
// 描画計算
|
||||
var rebuildTarget = popcorns[0].transform.parent.parent;
|
||||
var originalScale = rebuildTarget.localScale;
|
||||
rebuildTarget.localScale = Vector3.zero;
|
||||
Observable.TimerFrame(0, FrameCountType.EndOfFrame).Subscribe(_ =>
|
||||
{
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(rebuildTarget as RectTransform);
|
||||
rebuildTarget.localScale = originalScale;
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
public static void ShowDialog((IReadOnlyList<ProductData> earnList, IReadOnlyList<ProductData> discardList) products, Action onClose = null){
|
||||
LocalCacheManager.Save(AutoCookCompleteProductsTag, products);
|
||||
LocalCacheManager.Save(CallbackTag, onClose);
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.AutomaticCookingCaution);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 837dd3250ce549a8af77a678f5218afe
|
||||
timeCreated: 1650000631
|
||||
Loading…
Reference in New Issue