キッチンの休憩動画リワードを追加
This commit is contained in:
parent
fa3445f1b4
commit
9d19db4a34
|
|
@ -43,7 +43,7 @@ public class CornField : MonoBehaviour
|
|||
private static readonly int animationDivisor = 3;
|
||||
private static readonly int animationLimit = 100;
|
||||
|
||||
private static readonly double fertilizerWaitTime = 600f;
|
||||
private static readonly double fertilizerWaitTime = 300f;
|
||||
|
||||
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||
private readonly Subject<int> resetFertilizerTimer = new Subject<int>();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MyGame.Scripts;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
using Unity.Mathematics;
|
||||
|
|
@ -11,11 +12,15 @@ using UnityEngine.UI;
|
|||
public class KitchenManager : MonoBehaviour
|
||||
{
|
||||
public static readonly string ArchivedCallbackTag = "KitchenCancelCallback";
|
||||
private static readonly double refreshWaitTime = 300;
|
||||
private static readonly int RewardCoin = 30;
|
||||
[SerializeField] private Button cookingButton;
|
||||
[SerializeField] private Button adButton;
|
||||
[SerializeField] private KitchenView kitchenView;
|
||||
[SerializeField] private BulkOrderIndicatorView orderIndicatorView;
|
||||
|
||||
private readonly Subject<int> resetRefreshTimer = new Subject<int>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
|
@ -39,20 +44,46 @@ public class KitchenManager : MonoBehaviour
|
|||
}).AddTo(this);
|
||||
|
||||
kitchenView.Initialize();
|
||||
kitchenView.SetNormalAnimation();
|
||||
adButton.gameObject.SetActive(false);
|
||||
|
||||
// 動画視聴可能かどうかはシーンロード時に確認
|
||||
// kitchenView.SetNormalAnimation();
|
||||
#if UNITY_EDITOR || DEVELOPMENT_BUILD
|
||||
adButton.gameObject.SetActive(true);
|
||||
kitchenView.SetTiredAnimation();
|
||||
adButton.OnClickAsObservable().Subscribe(_ =>
|
||||
{
|
||||
// 動画視聴POP
|
||||
GetRewardDialog.ShowCoinDialog(() =>
|
||||
{
|
||||
CoinGetDialog.ShowDialog(RewardCoin, () =>
|
||||
{
|
||||
CoinManager.Instance.AddCoinWithEffect(RewardCoin);
|
||||
gameData.Coin = CoinManager.Instance.OwnCoin;
|
||||
gameData.kitchenRefreshTime = DateTime.UtcNow.AddSeconds(refreshWaitTime).ToBinary();
|
||||
GameDataManager.SaveGameData();
|
||||
resetRefreshTimer.OnNext((int) DateTime.FromBinary(gameData.kitchenRefreshTime).Subtract(DateTime.UtcNow).TotalSeconds);
|
||||
});
|
||||
});
|
||||
}).AddTo(this);
|
||||
|
||||
resetRefreshTimer
|
||||
.Subscribe(time =>
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
time = 5;
|
||||
#endif
|
||||
adButton.gameObject.SetActive(false);
|
||||
kitchenView.SetNormalAnimation();
|
||||
Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f))
|
||||
.Select(x => time - x)
|
||||
.TakeWhile(x => x > 0)
|
||||
.Subscribe(_ => { }, () =>
|
||||
{
|
||||
adButton.gameObject.SetActive(true);
|
||||
kitchenView.SetTiredAnimation();
|
||||
}).AddTo(this);
|
||||
#endif
|
||||
}).AddTo(this);
|
||||
|
||||
// 動画視聴可能かどうかはシーンロード時に確認
|
||||
var remaining = (int) DateTime.FromBinary(gameData.kitchenRefreshTime).Subtract(DateTime.UtcNow).TotalSeconds;
|
||||
resetRefreshTimer.OnNext(remaining);
|
||||
|
||||
|
||||
// 大量注文
|
||||
var bulkOrderList = SpreadsheetDataManager.Instance.GetBaseDataList<BulkOrderData>(Const.BulkOrderDataSheet);
|
||||
|
|
|
|||
|
|
@ -1596,6 +1596,7 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2123520807}
|
||||
- component: {fileID: 2123520808}
|
||||
m_Layer: 5
|
||||
m_Name: Window
|
||||
m_TagString: Untagged
|
||||
|
|
@ -1624,6 +1625,22 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 57}
|
||||
m_SizeDelta: {x: 705, y: 550}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &2123520808
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2123520806}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dad3ad3b84bc4991a49aef6f39e98896, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
backgroundAnimator: {fileID: 660781990}
|
||||
closeButton: {fileID: 2088564207}
|
||||
okButton: {fileID: 0}
|
||||
messageText: {fileID: 726079106}
|
||||
--- !u!1001 &8412240709702713318
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace MyGame.Scripts
|
||||
{
|
||||
public class CoinGetDialog : MonoBehaviour
|
||||
{
|
||||
private static readonly string CallbackTag = "CoinGetDialogCallback";
|
||||
private static readonly string AmountTag = "CoinGetDialogAmount";
|
||||
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 Text messageText;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
closeButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||
{
|
||||
transform.parent.SetLocalScale(0);
|
||||
backgroundAnimator.SetTrigger(CloseTrigger);
|
||||
this.CallWaitForSeconds(.25f, () =>
|
||||
{
|
||||
LocalCacheManager.Load<Action>(CallbackTag)?.Invoke();
|
||||
TransitionManager.Instance.UnloadScene(GameScenes.WatchMovieCoinGet);
|
||||
});
|
||||
}).AddTo(this);
|
||||
|
||||
messageText.text = LocalCacheManager.Load<int>(AmountTag, 0).ToString();
|
||||
}
|
||||
|
||||
public static void ShowDialog(int amount, Action closeCallback)
|
||||
{
|
||||
LocalCacheManager.Save(CallbackTag, closeCallback);
|
||||
LocalCacheManager.Save(AmountTag, amount);
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.WatchMovieCoinGet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dad3ad3b84bc4991a49aef6f39e98896
|
||||
timeCreated: 1634789523
|
||||
|
|
@ -124,7 +124,8 @@ public sealed class GameData {
|
|||
public long fertilizerTime = DateTime.UtcNow.ToBinary();
|
||||
[DataMember(Name = "Data36")]
|
||||
public long increaseCustomerTime= DateTime.UtcNow.ToBinary();
|
||||
// [DataMember(Name = "Data37")]
|
||||
[DataMember(Name = "Data37")]
|
||||
public long kitchenRefreshTime= DateTime.UtcNow.ToBinary();
|
||||
|
||||
// mission
|
||||
[DataMember(Name = "Data1001")]
|
||||
|
|
|
|||
Loading…
Reference in New Issue