diff --git a/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_pink.controller b/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_pink.controller index fc11917a..09421063 100644 --- a/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_pink.controller +++ b/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_pink.controller @@ -91,6 +91,8 @@ AnimatorStateMachine: - {fileID: 51081042415013300} - {fileID: 4394378192515912696} - {fileID: -4201787685094799525} + - {fileID: 1938256483501769669} + - {fileID: 265964369079198928} m_EntryTransitions: [] m_StateMachineTransitions: {} m_StateMachineBehaviours: [] @@ -242,25 +244,37 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Promotion m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Sleepy m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Walk m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} + - m_Name: Tasting + m_Type: 9 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} + - m_Name: TastingWalk + m_Type: 9 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -299,6 +313,56 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 0 +--- !u!1101 &265964369079198928 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: TastingWalk + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: -7730918100354297461} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 0.75 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &1938256483501769669 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Tasting + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: -6388531656861423336} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 0.75 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1102 &4390197982913342166 AnimatorState: serializedVersion: 5 diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs index 6a587aa3..1e334546 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs @@ -76,6 +76,8 @@ public class BulkOrder : MonoBehaviour // カウントリセット gameData.OrderConditionCount = 0; GameDataManager.SaveGameData(); + // 試食スタート + BrotherPinkView.Instance.StartTasting(); LocalCacheManager.Load(CancelCallbackTag, null)?.Invoke(); LocalCacheManager.Remove(CancelCallbackTag); // キャンセルと同時に閉じる diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Brother_pink.prefab b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Brother_pink.prefab index 500b2f33..ac3bf69d 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Brother_pink.prefab +++ b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Brother_pink.prefab @@ -1012,7 +1012,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &8458098820248002959 Transform: m_ObjectHideFlags: 0 @@ -1576,6 +1576,7 @@ GameObject: - component: {fileID: 7854448232971748899} - component: {fileID: 7854448232971748898} - component: {fileID: 7854448232971748956} + - component: {fileID: 3285748382438269010} m_Layer: 0 m_Name: Brother_pink m_TagString: Untagged @@ -1633,6 +1634,22 @@ SortingGroup: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 23 +--- !u!114 &3285748382438269010 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7854448232971748896} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: acf2a111dab748379c60a37b887bd20c, type: 3} + m_Name: + m_EditorClassIdentifier: + itemMany: {fileID: 7527088936072372818} + itemFew: {fileID: 3577262440827808746} + manyCount: 6 + fewCount: 3 --- !u!1 &7854448233088646087 GameObject: m_ObjectHideFlags: 0 diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/BrotherPinkView.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/BrotherPinkView.cs index ad5bf563..9ee208f5 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/BrotherPinkView.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/BrotherPinkView.cs @@ -1,4 +1,5 @@ using System; +using MyGame.Scenes.marketing.Scripts; using UniRx; using UniRx.Triggers; using UnityEngine; @@ -9,6 +10,8 @@ public class BrotherPinkView : SingletonMonoBehaviour private static readonly int Promotion = Animator.StringToHash("Promotion"); private static readonly int Sleepy = Animator.StringToHash("Sleepy"); private static readonly int Walk = Animator.StringToHash("Walk"); + private static readonly int Tasting = Animator.StringToHash("Tasting"); + private static readonly int TastingWalk = Animator.StringToHash("TastingWalk"); private static readonly Vector2 RightPos = new Vector2(4.96f, -0.26f); private static readonly Vector2 LeftPos = new Vector2(-4.96f, -0.26f); @@ -22,9 +25,12 @@ public class BrotherPinkView : SingletonMonoBehaviour public int FewerBorder => fewerBorder; private Animator animator; - private bool isManyCustomer; - private bool isLocked; + private TastingBasketView basketView; + private bool waitMove; + private bool isMoveLocked; private bool isPromotion; + private bool isEndingPromotion; + private bool isTasting; private int nextId; private readonly (int trigger, Vector2 wayPoint, float wait)[] pinkMoves = { @@ -33,23 +39,48 @@ public class BrotherPinkView : SingletonMonoBehaviour (Walk, RightPos, 0f), (Promotion, RightPos + Vector2.left * .03f, 5.35f), }; + private readonly (int trigger, Vector2 wayPoint, float wait)[] pinkTastingMoves = + { + (TastingWalk, LeftPos, 0f), + (Tasting, LeftPos + Vector2.right * .03f, 5.35f), + (TastingWalk, RightPos, 0f), + (Tasting, RightPos + Vector2.left * .03f, 5.35f), + }; private int moveIndex; private Vector2 wayPoint; private float durationDelta; private float completedDuration; + private (int trigger, Vector2 wayPoint, float wait)[] selectedMoves; + private IDisposable moveLockDispose; + private Subject setTrigger = new Subject(); private void Awake() { + setTrigger.AddTo(this); nextId = Normal; - isManyCustomer = true; + waitMove = true; + selectedMoves = pinkMoves; } private void Start() { pinkTransform.localPosition = RightPos; + /* + * 1フレーム内で最後に受け取った値をSetする + * アニメーター挙動考慮 + */ + setTrigger + .ThrottleFrame(1) + .Subscribe(x => + { + if (animator != null) + { + animator.SetTrigger(x); + } + }).AddTo(this); this.UpdateAsObservable().Subscribe(_ => { - if (isManyCustomer || isLocked || isPromotion) + if (waitMove || isMoveLocked || isPromotion) { return; } @@ -66,14 +97,16 @@ public class BrotherPinkView : SingletonMonoBehaviour } durationDelta = 0; moveIndex++; - if (moveIndex == pinkMoves.Length) + if (moveIndex == selectedMoves.Length) { - ResetMove(); - isLocked = true; - this.CallWaitForSeconds(coolTime, () => + if (isTasting) { - isLocked = false; - }); + moveIndex = 0; + SetPinkMove(); + return; + } + ResetMove(); + LockMove(coolTime); return; } SetPinkMove(); @@ -81,10 +114,21 @@ public class BrotherPinkView : SingletonMonoBehaviour }).AddTo(this); } + private void LockMove(float time) + { + isMoveLocked = true; + moveLockDispose?.Dispose(); + moveLockDispose = Observable.Timer(TimeSpan.FromSeconds(time)) + .Subscribe(l => { }, () => + { + isMoveLocked = false; + }).AddTo(this); + } + private void ResetMove() { + waitMove = true; moveIndex = 0; - isManyCustomer = true; if (animator != null) animator.SetTrigger(nextId); } @@ -92,12 +136,13 @@ public class BrotherPinkView : SingletonMonoBehaviour { target.DestroyAllChildrens(); animator = Instantiate(animatorPrefab, target); + basketView = animator.GetComponent(); this.UpdateAsObservable().Subscribe(_ => { target.localPosition = pinkTransform.localPosition; target.localRotation = pinkTransform.localRotation; }).AddTo(animator); - if (isManyCustomer || isPromotion) + if (waitMove || isPromotion || isTasting) { return; } @@ -106,13 +151,14 @@ public class BrotherPinkView : SingletonMonoBehaviour private void SetPinkMove() { - var move = pinkMoves[moveIndex]; + var move = selectedMoves[moveIndex]; wayPoint = move.wayPoint; completedDuration = move.wait; if (animator != null) { animator.ResetTrigger(Normal); - animator.SetTrigger(move.trigger); + // animator.SetTrigger(move.trigger); + setTrigger.OnNext(move.trigger); } if (Vector2.Distance(wayPoint, pinkTransform.localPosition.ToVector2()) < .01f) { @@ -127,10 +173,11 @@ public class BrotherPinkView : SingletonMonoBehaviour } } + // お客さんが多い場合に使用するアニメーション切替え private void SetTrigger(int id) { nextId = id; - if (isManyCustomer) + if (waitMove) { animator.SetTrigger(id); } @@ -161,34 +208,50 @@ public class BrotherPinkView : SingletonMonoBehaviour { if (animator != null) { - var stateInfo = animator.GetCurrentAnimatorStateInfo(0); - if (stateInfo.IsName("Brother_pink_promotion")) - { - var length = stateInfo.length; - var time = stateInfo.normalizedTime; - this.CallWaitForSeconds((1 - time % 1) * length - .3f, () => - { - animator.ResetTrigger(Promotion); - ResetMove(); - isPromotion = false; - }); - return; - } + animator.ResetTrigger(Promotion); } ResetMove(); isPromotion = false; } - public void SetWalk() + public void StartTasting() { - if (isLocked || isPromotion) + // tasting発動 + moveLockDispose?.Dispose(); + isMoveLocked = false; + waitMove = false; + + isTasting = true; + selectedMoves = pinkTastingMoves; + SetPinkMove(); + } + + public void StopTasting() + { + if (!isTasting) { return; } - if (isManyCustomer) + isTasting = false; + selectedMoves = pinkMoves; + SetPinkMove(); + } + + public void SetTastingCount(int count) + { + if (basketView != null) { - isManyCustomer = false; - SetPinkMove(); + basketView.SetItem(count); } } + + public void SetWalk() + { + if (!waitMove || isMoveLocked || isPromotion || isTasting) + { + return; + } + waitMove = false; + SetPinkMove(); + } } diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs index f123b44a..60b95341 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs @@ -23,6 +23,9 @@ public class CustomerFlow : MonoBehaviour [Header("試食のお客さん出現間隔(秒)")] [SerializeField] private float tastingCustomerInterval = 5f; + public float TastingCustomerInterval => tastingCustomerInterval; + private int adActiveCount = 0; + public IObservable Flow => walkerObservable.Merge(customerObservable, adWalkerObservable, tastingCustomerObservable); private void Awake() @@ -66,8 +69,11 @@ public class CustomerFlow : MonoBehaviour } #endif // 試食 + // tastingCustomerInterval毎にTastingCountを確認 var tastingTimer = Observable.Interval(TimeSpan.FromSeconds(tastingCustomerInterval)) - .Where(_ => GameDataManager.GameData.TastingCount > 0) + .Where(_ => adActiveCount <= 0) // 宣伝中判定 + .Where(_ => GameDataManager.GameData.ShopStock.Count > 0) // 在庫ゼロ判定 + .Where(_ => GameDataManager.GameData.TastingCount > 0) // 試食残り判定 .Publish() .RefCount(); // 試食残りカウントを減らす @@ -84,8 +90,10 @@ public class CustomerFlow : MonoBehaviour { var timerObservable = AdWalkerTimer().Publish().RefCount(); adStartObservable.OnNext(timerObservable); + adActiveCount++; timerObservable.Subscribe(_ => { }, () => { + adActiveCount--; onComplete?.Invoke(); }).AddTo(this); } diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs index cee24653..70d6017c 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs @@ -31,6 +31,9 @@ public class Market : SingletonMonoBehaviour [SerializeField] private CustomerSetting customerSetting; [SerializeField] private CustomerController customerControllerPrefab; + // 暫定 + public float TastingCustomerInterval => customerFlow.TastingCustomerInterval; + public List DisplayFlavors => displayFlavors; private List displayFlavors = new List(); public List ShuffledOrder => shuffledOrder; @@ -59,7 +62,7 @@ public class Market : SingletonMonoBehaviour private int orderIndex; private int oneByOneIndex = 0; private GameData gameData; - + // Start is called before the first frame update void Start() { @@ -333,6 +336,22 @@ public class Market : SingletonMonoBehaviour BrotherPinkView.Instance.SetWalk(); } }).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 isPromotion.Value = true; customerFlow.StartAdWalker(() => { - isPromotion.Value = false; - BrotherPinkView.Instance.StopPromotion(); + isPromotion.Value = false; }); } diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs index e3d1d266..d19f2e8e 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs @@ -17,6 +17,7 @@ public class MarketManager : MonoBehaviour [SerializeField] private MarketCartView cartView; [SerializeField] private BrotherBlueView blueView; [SerializeField] private IncreaseCustomerButtonView rewardButtonView; + [SerializeField] private MarketSignBoardView signBoardView; [SerializeField] private Transform pinkTarget; [SerializeField] private Transform coinPrefab; [SerializeField] private Transform rootTransform; @@ -24,7 +25,7 @@ public class MarketManager : MonoBehaviour private Market market; List productDataList; - private readonly Subject resetRefreshTimer = new Subject(); + private readonly Subject resetRefreshTimer = new Subject(); private readonly CompositeDisposable ShopClosedCompositeDisposable = new CompositeDisposable(); private void Start() @@ -67,7 +68,7 @@ public class MarketManager : MonoBehaviour gameData.FinishTutorial(); GameDataManager.SaveGameData(); walkerMask.gameObject.SetActive(false); - resetRefreshTimer.OnNext((int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds); + resetRefreshTimer.OnNext(Unit.Default); SetShopView(market.CurrentShopState.Value); }).AddTo(controller).AddTo(this); }); @@ -108,6 +109,7 @@ public class MarketManager : MonoBehaviour cartView.SetStock(startStocks, false); BrotherPinkView.Instance.SetBrotherView(pinkTarget); + // 宣伝ボタン rewardButtonView.RewardButton.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ => { GetRewardDialog.ShowIncreaseCustomerDialog(() => @@ -118,14 +120,17 @@ public class MarketManager : MonoBehaviour gameData.increaseCustomerTime = DateTime.UtcNow.AddSeconds(10).ToBinary(); #endif GameDataManager.SaveGameData(); - resetRefreshTimer.OnNext((int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds); + resetRefreshTimer.OnNext(Unit.Default); }); }).AddTo(this); + // onNextをトリガーに実行 IDisposable timerDisposable = null; resetRefreshTimer + .Select(_ => (int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds) .Subscribe(time => { + // タイマーの更新処理 timerDisposable?.Dispose(); rewardButtonView.SetButtonActive(time <= 0); rewardButtonView.SetTime(time); @@ -141,30 +146,21 @@ public class MarketManager : MonoBehaviour }).AddTo(this); }).AddTo(this); - var remaining = (int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds; - resetRefreshTimer.OnNext(remaining); + resetRefreshTimer.OnNext(Unit.Default); + // アプリ復帰時に残り時間更新 Observable.EveryApplicationPause() .Where(pause => !pause) .Subscribe(_ => { - resetRefreshTimer.OnNext((int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds); + resetRefreshTimer.OnNext(Unit.Default); }).AddTo(this); - + market.IsPromotion.Subscribe(active => { - if (active) - { - SoundManager.Instance.PlayBGM("bgm_publicity"); - BrotherPinkView.Instance.StartPromotion(); - } - else - { - SoundManager.Instance.PlayBGM("bgm_marketing"); - } + SoundManager.Instance.PlayBGM(active ? "bgm_publicity" : "bgm_marketing"); }).AddTo(this); - // Customerの各アニメーション設定 foreach (var controller in market.CustomerControllerList) { @@ -227,19 +223,70 @@ public class MarketManager : MonoBehaviour .SkipWhile(_ => !gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay)) .Subscribe(state => { - Debug.Log($"SetShopView"); SetShopView(state); }).AddTo(this); + + // 試食看板はStart時非表示 + signBoardView.SetActiveTastingBoard(false); + + // 宣伝ボタン/試食表示切替 + var tastingComplete = new Subject().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); + } + } + else // 閉店 + { + BrotherPinkView.Instance.StopTasting(); + rewardButtonView.gameObject.SetActive(false); + signBoardView.CancelTasting(); + } + }).AddTo(this); + // CombineLatest動かすのに必要 + tastingComplete.OnNext(Unit.Default); } private void SetShopView(ShopState state) { +#if UNITY_EDITOR + Debug.Log($"SetShopView"); +#endif ShopClosedCompositeDisposable.Clear(); switch (state) { case ShopState.Open: - // 宣伝ボタン表示 - rewardButtonView.gameObject.SetActive(true); BrotherPinkView.Instance.SetNormal(); blueView.OpenAction(); closeSign.SetActive(false); @@ -247,8 +294,6 @@ public class MarketManager : MonoBehaviour case ShopState.Busy: break; case ShopState.Close: - // 宣伝ボタン非表示 - rewardButtonView.gameObject.SetActive(false); if (market.CustomerList.Count(x => x.State.Value == CustomerState.Order) == 0) { BrotherPinkView.Instance.SetSleepy(); diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketSignBoardView.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketSignBoardView.cs new file mode 100644 index 00000000..f537b7a9 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketSignBoardView.cs @@ -0,0 +1,53 @@ +using System; +using UniRx; +using UnityEngine; +using UnityEngine.UI; + +namespace MyGame.Scenes.marketing.Scripts +{ + public class MarketSignBoardView : MonoBehaviour + { + private static readonly string RemainTimeFormat = "残り{0:D2}:{1:D2}"; + private static readonly string TimeUpText = "終了"; + [SerializeField] private Text remainTimeText; + [SerializeField] private GameObject normalBoardObject; + [SerializeField] private GameObject tastingBoardObject; + private IDisposable timerDispose; + + // 宣伝中は宣伝優先で通常看板 + public void SetActiveTastingBoard(bool active) + { + normalBoardObject.SetActive(!active); + tastingBoardObject.SetActive(active); + } + + private void SetTime(int seconds) + { + seconds = Mathf.Max(0, seconds); + 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(); + }, () => + { + remainTimeText.text = TimeUpText; + onComplete?.Invoke(); + }).AddTo(this); + } + + public void CancelTasting() + { + timerDispose?.Dispose(); + remainTimeText.text = TimeUpText; + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketSignBoardView.cs.meta b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketSignBoardView.cs.meta new file mode 100644 index 00000000..59f81dfb --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketSignBoardView.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7a19dcec25224a75a8f3635153cef5c9 +timeCreated: 1639378152 \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs index c9fd832d..e5c5e2c2 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs @@ -303,6 +303,7 @@ public class ProductManagement : MonoBehaviour GameDataManager.GameData.AddTastingCustomerCount(tank.Stock); tank.ClearStock(); GameDataManager.SaveGameData(); + BrotherPinkView.Instance.StartTasting(); } private void OnDestroy() diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingBasketView.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingBasketView.cs new file mode 100644 index 00000000..2a3dd51c --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingBasketView.cs @@ -0,0 +1,31 @@ +using UnityEngine; + +namespace MyGame.Scenes.marketing.Scripts +{ + public class TastingBasketView : MonoBehaviour + { + [SerializeField] private GameObject itemMany; + [SerializeField] private GameObject itemFew; + [SerializeField] private int manyCount; + [SerializeField] private int fewCount; + + public void SetItem(int count) + { + if (count >= manyCount) + { + itemMany.SetActive(true); + itemFew.SetActive(false); + } + else if (count >= fewCount) + { + itemMany.SetActive(false); + itemFew.SetActive(true); + } + else + { + itemMany.SetActive(false); + itemFew.SetActive(false); + } + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingBasketView.cs.meta b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingBasketView.cs.meta new file mode 100644 index 00000000..53395743 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/TastingBasketView.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: acf2a111dab748379c60a37b887bd20c +timeCreated: 1639454549 \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/marketing/marketing.unity b/popcorn/Assets/MyGame/Scenes/marketing/marketing.unity index 48d1b694..bfcb1cb3 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/marketing.unity +++ b/popcorn/Assets/MyGame/Scenes/marketing/marketing.unity @@ -3622,7 +3622,7 @@ PrefabInstance: - target: {fileID: 4293843007976718249, guid: 1c993e9707f1a4fada56020be27dde28, type: 3} propertyPath: m_AnchoredPosition.y - value: 66.25009 + value: 66.25 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 1c993e9707f1a4fada56020be27dde28, type: 3} @@ -5582,6 +5582,7 @@ MonoBehaviour: cartView: {fileID: 2048621276} blueView: {fileID: 1506158581} rewardButtonView: {fileID: 820175261} + signBoardView: {fileID: 1732899481} pinkTarget: {fileID: 1749782974} coinPrefab: {fileID: 8159396421809467538, guid: 9fc8076f17c26ff4d9be53b90a7dad4c, type: 3} @@ -6172,7 +6173,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &1165998904 Transform: m_ObjectHideFlags: 0 @@ -6736,17 +6737,17 @@ RectTransform: m_GameObject: {fileID: 1265140448} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.005197392, y: 0.005197392, z: 0.005197392} m_Children: - {fileID: 1629640653} m_Father: {fileID: 1423968762} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0, y: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0.001, y: -0.563} + m_SizeDelta: {x: 300, y: 300} + m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1265140450 MonoBehaviour: m_ObjectHideFlags: 0 @@ -6754,16 +6755,11 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1265140448} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Script: {fileID: 11500000, guid: be39b2648c1548e2a2338ea75a51fcc6, type: 3} m_Name: m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 4294967295 --- !u!114 &1265140451 MonoBehaviour: m_ObjectHideFlags: 0 @@ -6795,9 +6791,9 @@ Canvas: m_GameObject: {fileID: 1265140448} m_Enabled: 1 serializedVersion: 3 - m_RenderMode: 1 - m_Camera: {fileID: 1277621136} - m_PlaneDistance: 0 + m_RenderMode: 2 + m_Camera: {fileID: 658354829} + m_PlaneDistance: 1 m_PixelPerfect: 0 m_ReceivesEvents: 1 m_OverrideSorting: 0 @@ -7057,7 +7053,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &1423968762 Transform: m_ObjectHideFlags: 0 @@ -7066,7 +7062,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1423968761} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.052, y: -0.277, z: 0} + m_LocalPosition: {x: 0.31, y: 0.96, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 1265140449} @@ -13093,10 +13089,10 @@ RectTransform: m_Father: {fileID: 1265140449} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 469.1, y: -28} - m_SizeDelta: {x: 170, y: 40} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1629640654 MonoBehaviour: @@ -13119,12 +13115,12 @@ MonoBehaviour: m_Calls: [] m_FontData: m_Font: {fileID: 12800000, guid: b5532e9ce15694f55a0893a76a98cd78, type: 3} - m_FontSize: 28 - m_FontStyle: 0 + m_FontSize: 52 + m_FontStyle: 1 m_BestFit: 0 - m_MinSize: 2 - m_MaxSize: 40 - m_Alignment: 3 + m_MinSize: 0 + m_MaxSize: 300 + m_Alignment: 4 m_AlignByGeometry: 0 m_RichText: 1 m_HorizontalOverflow: 0 @@ -13418,6 +13414,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1732899480} + - component: {fileID: 1732899481} m_Layer: 0 m_Name: Signboard m_TagString: Untagged @@ -13441,6 +13438,21 @@ Transform: m_Father: {fileID: 1102296790} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1732899481 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1732899479} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a19dcec25224a75a8f3635153cef5c9, type: 3} + m_Name: + m_EditorClassIdentifier: + remainTimeText: {fileID: 1629640654} + normalBoardObject: {fileID: 1165998903} + tastingBoardObject: {fileID: 1423968761} --- !u!1 &1749782973 GameObject: m_ObjectHideFlags: 0 @@ -13466,7 +13478,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1749782973} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 4.96, y: -0.26, z: 0} + m_LocalPosition: {x: 3.46, y: -0.26, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 1189290113}