試食中アニメーション内部対応
This commit is contained in:
parent
f9ceb4bde8
commit
9c9120fe4c
|
|
@ -31,6 +31,9 @@ public class Market : SingletonMonoBehaviour<Market>
|
||||||
[SerializeField] private CustomerSetting customerSetting;
|
[SerializeField] private CustomerSetting customerSetting;
|
||||||
[SerializeField] private CustomerController customerControllerPrefab;
|
[SerializeField] private CustomerController customerControllerPrefab;
|
||||||
|
|
||||||
|
// 暫定
|
||||||
|
public float TastingCustomerInterval => customerFlow.TastingCustomerInterval;
|
||||||
|
|
||||||
public List<ProductStockData> DisplayFlavors => displayFlavors;
|
public List<ProductStockData> DisplayFlavors => displayFlavors;
|
||||||
private List<ProductStockData> displayFlavors = new List<ProductStockData>();
|
private List<ProductStockData> displayFlavors = new List<ProductStockData>();
|
||||||
public List<int> ShuffledOrder => shuffledOrder;
|
public List<int> ShuffledOrder => shuffledOrder;
|
||||||
|
|
@ -59,7 +62,7 @@ public class Market : SingletonMonoBehaviour<Market>
|
||||||
private int orderIndex;
|
private int orderIndex;
|
||||||
private int oneByOneIndex = 0;
|
private int oneByOneIndex = 0;
|
||||||
private GameData gameData;
|
private GameData gameData;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|
@ -333,6 +336,22 @@ public class Market : SingletonMonoBehaviour<Market>
|
||||||
BrotherPinkView.Instance.SetWalk();
|
BrotherPinkView.Instance.SetWalk();
|
||||||
}
|
}
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
|
||||||
|
isPromotion.Subscribe(x =>
|
||||||
|
{
|
||||||
|
if (x)
|
||||||
|
{
|
||||||
|
BrotherPinkView.Instance.StartPromotion();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BrotherPinkView.Instance.StopPromotion();
|
||||||
|
if (gameData.TastingCount > 0 && shopState.Value == ShopState.Open)
|
||||||
|
{
|
||||||
|
BrotherPinkView.Instance.StartTasting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).AddTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -517,8 +536,7 @@ public class Market : SingletonMonoBehaviour<Market>
|
||||||
isPromotion.Value = true;
|
isPromotion.Value = true;
|
||||||
customerFlow.StartAdWalker(() =>
|
customerFlow.StartAdWalker(() =>
|
||||||
{
|
{
|
||||||
isPromotion.Value = false;
|
isPromotion.Value = false;
|
||||||
BrotherPinkView.Instance.StopPromotion();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ public class MarketManager : MonoBehaviour
|
||||||
[SerializeField] private MarketCartView cartView;
|
[SerializeField] private MarketCartView cartView;
|
||||||
[SerializeField] private BrotherBlueView blueView;
|
[SerializeField] private BrotherBlueView blueView;
|
||||||
[SerializeField] private IncreaseCustomerButtonView rewardButtonView;
|
[SerializeField] private IncreaseCustomerButtonView rewardButtonView;
|
||||||
|
[SerializeField] private MarketSignBoardView signBoardView;
|
||||||
[SerializeField] private Transform pinkTarget;
|
[SerializeField] private Transform pinkTarget;
|
||||||
[SerializeField] private Transform coinPrefab;
|
[SerializeField] private Transform coinPrefab;
|
||||||
[SerializeField] private Transform rootTransform;
|
[SerializeField] private Transform rootTransform;
|
||||||
|
|
@ -108,6 +109,7 @@ public class MarketManager : MonoBehaviour
|
||||||
cartView.SetStock(startStocks, false);
|
cartView.SetStock(startStocks, false);
|
||||||
BrotherPinkView.Instance.SetBrotherView(pinkTarget);
|
BrotherPinkView.Instance.SetBrotherView(pinkTarget);
|
||||||
|
|
||||||
|
// 宣伝ボタン
|
||||||
rewardButtonView.RewardButton.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
rewardButtonView.RewardButton.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
||||||
{
|
{
|
||||||
GetRewardDialog.ShowIncreaseCustomerDialog(() =>
|
GetRewardDialog.ShowIncreaseCustomerDialog(() =>
|
||||||
|
|
@ -153,21 +155,12 @@ public class MarketManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
resetRefreshTimer.OnNext(Unit.Default);
|
resetRefreshTimer.OnNext(Unit.Default);
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
|
||||||
market.IsPromotion.Subscribe(active =>
|
market.IsPromotion.Subscribe(active =>
|
||||||
{
|
{
|
||||||
if (active)
|
SoundManager.Instance.PlayBGM(active ? "bgm_publicity" : "bgm_marketing");
|
||||||
{
|
|
||||||
SoundManager.Instance.PlayBGM("bgm_publicity");
|
|
||||||
BrotherPinkView.Instance.StartPromotion();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SoundManager.Instance.PlayBGM("bgm_marketing");
|
|
||||||
}
|
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
|
||||||
|
|
||||||
// Customerの各アニメーション設定
|
// Customerの各アニメーション設定
|
||||||
foreach (var controller in market.CustomerControllerList)
|
foreach (var controller in market.CustomerControllerList)
|
||||||
{
|
{
|
||||||
|
|
@ -230,19 +223,67 @@ public class MarketManager : MonoBehaviour
|
||||||
.SkipWhile(_ => !gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
.SkipWhile(_ => !gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
||||||
.Subscribe(state =>
|
.Subscribe(state =>
|
||||||
{
|
{
|
||||||
Debug.Log($"SetShopView");
|
|
||||||
SetShopView(state);
|
SetShopView(state);
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
|
||||||
|
// 宣伝ボタン/試食表示切替
|
||||||
|
var tastingComplete = new Subject<Unit>().AddTo(this);
|
||||||
|
market.CurrentShopState
|
||||||
|
.CombineLatest(market.IsPromotion, tastingComplete, (shopState, isPromotion, _) => (shopState == ShopState.Open, isPromotion))
|
||||||
|
.Subscribe(x =>
|
||||||
|
{
|
||||||
|
var (isOpen, isPromotion) = x;
|
||||||
|
if (isOpen)
|
||||||
|
{
|
||||||
|
if (isPromotion)
|
||||||
|
{
|
||||||
|
// 宣伝ボタン表示
|
||||||
|
rewardButtonView.gameObject.SetActive(true);
|
||||||
|
signBoardView.SetActiveTastingBoard(false);
|
||||||
|
}
|
||||||
|
else if (gameData.TastingCount > 0)
|
||||||
|
{
|
||||||
|
rewardButtonView.gameObject.SetActive(false);
|
||||||
|
signBoardView.SetActiveTastingBoard(true);
|
||||||
|
BrotherPinkView.Instance.StartTasting();
|
||||||
|
BrotherPinkView.Instance.SetTastingCount(gameData.TastingCount);
|
||||||
|
signBoardView.SetTimer(gameData.TastingCount * (int)market.TastingCustomerInterval, () =>
|
||||||
|
{
|
||||||
|
BrotherPinkView.Instance.SetTastingCount(gameData.TastingCount);
|
||||||
|
}, () =>
|
||||||
|
{
|
||||||
|
// 試食タイマーが終わったら表示更新トリガー
|
||||||
|
tastingComplete.OnNext(Unit.Default);
|
||||||
|
BrotherPinkView.Instance.StopTasting();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BrotherPinkView.Instance.StopTasting();
|
||||||
|
rewardButtonView.gameObject.SetActive(true);
|
||||||
|
signBoardView.SetActiveTastingBoard(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BrotherPinkView.Instance.StopTasting();
|
||||||
|
rewardButtonView.gameObject.SetActive(false);
|
||||||
|
signBoardView.SetActiveTastingBoard(false);
|
||||||
|
}
|
||||||
|
}).AddTo(this);
|
||||||
|
// CombineLatest動かすのに必要
|
||||||
|
tastingComplete.OnNext(Unit.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetShopView(ShopState state)
|
private void SetShopView(ShopState state)
|
||||||
{
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
Debug.Log($"SetShopView");
|
||||||
|
#endif
|
||||||
ShopClosedCompositeDisposable.Clear();
|
ShopClosedCompositeDisposable.Clear();
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case ShopState.Open:
|
case ShopState.Open:
|
||||||
// 宣伝ボタン表示
|
|
||||||
rewardButtonView.gameObject.SetActive(true);
|
|
||||||
BrotherPinkView.Instance.SetNormal();
|
BrotherPinkView.Instance.SetNormal();
|
||||||
blueView.OpenAction();
|
blueView.OpenAction();
|
||||||
closeSign.SetActive(false);
|
closeSign.SetActive(false);
|
||||||
|
|
@ -250,8 +291,6 @@ public class MarketManager : MonoBehaviour
|
||||||
case ShopState.Busy:
|
case ShopState.Busy:
|
||||||
break;
|
break;
|
||||||
case ShopState.Close:
|
case ShopState.Close:
|
||||||
// 宣伝ボタン非表示
|
|
||||||
rewardButtonView.gameObject.SetActive(false);
|
|
||||||
if (market.CustomerList.Count(x => x.State.Value == CustomerState.Order) == 0)
|
if (market.CustomerList.Count(x => x.State.Value == CustomerState.Order) == 0)
|
||||||
{
|
{
|
||||||
BrotherPinkView.Instance.SetSleepy();
|
BrotherPinkView.Instance.SetSleepy();
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
using System;
|
||||||
|
using UniRx;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
|
@ -5,15 +7,39 @@ namespace MyGame.Scenes.marketing.Scripts
|
||||||
{
|
{
|
||||||
public class MarketSignBoardView : MonoBehaviour
|
public class MarketSignBoardView : MonoBehaviour
|
||||||
{
|
{
|
||||||
private static readonly string remainTimeFormat = "残り{0:D2}:{1:D2}";
|
private static readonly string remainTimeFormat = "残り{0:D2}:{1:D2}";
|
||||||
[SerializeField] private Text remainTimeText;
|
[SerializeField] private Text remainTimeText;
|
||||||
[SerializeField] private GameObject normalBoardObject;
|
[SerializeField] private GameObject normalBoardObject;
|
||||||
[SerializeField] private GameObject tastingBoardObject;
|
[SerializeField] private GameObject tastingBoardObject;
|
||||||
|
private IDisposable timerDispose;
|
||||||
|
|
||||||
|
// 宣伝中は宣伝優先で通常看板
|
||||||
|
public void SetActiveTastingBoard(bool active)
|
||||||
|
{
|
||||||
|
normalBoardObject.SetActive(!active);
|
||||||
|
tastingBoardObject.SetActive(active);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetTime(int seconds)
|
private void SetTime(int seconds)
|
||||||
{
|
{
|
||||||
seconds = Mathf.Max(0, seconds);
|
seconds = Mathf.Max(0, seconds);
|
||||||
remainTimeText.text = string.Format(remainTimeFormat, Mathf.Min(seconds / 60, 99), seconds % 60);
|
remainTimeText.text = string.Format(remainTimeFormat, Mathf.Min(seconds / 60, 99), seconds % 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetTimer(int remaining, Action onInterval = null, Action onComplete = null)
|
||||||
|
{
|
||||||
|
timerDispose?.Dispose();
|
||||||
|
var timer = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f))
|
||||||
|
.Select(x => (int)(remaining - x))
|
||||||
|
.TakeWhile(x => x >= 0);
|
||||||
|
timerDispose = timer.Subscribe(x =>
|
||||||
|
{
|
||||||
|
SetTime(x);
|
||||||
|
onInterval?.Invoke();
|
||||||
|
}, () =>
|
||||||
|
{
|
||||||
|
onComplete?.Invoke();
|
||||||
|
}).AddTo(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue