From 4d4c4da2445c7b2f72caa46b2ac0cced0729bd67 Mon Sep 17 00:00:00 2001 From: kimura Date: Fri, 10 Dec 2021 11:26:56 +0900 Subject: [PATCH] =?UTF-8?q?=E8=AA=BF=E7=90=86=E3=82=B7=E3=83=BC=E3=83=B3?= =?UTF-8?q?=E3=81=AE=E5=85=84=E5=BC=9F=E3=82=A2=E3=83=8B=E3=83=A1=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Brother/Brother_Blue_Main.controller | 38 +++++++++++- .../Brother/Brother_pink_Main.controller | 38 +++++++++++- popcorn/Assets/MyGame/Scenes/Main/Main.unity | 4 +- .../Scenes/Main/Scripts/KitchenManager.cs | 59 ++++++++++++++++--- .../MyGame/Scenes/Main/Scripts/KitchenView.cs | 44 +++++++++----- 5 files changed, 153 insertions(+), 30 deletions(-) diff --git a/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_Blue_Main.controller b/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_Blue_Main.controller index 398e36e2..3bf7abe3 100644 --- a/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_Blue_Main.controller +++ b/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_Blue_Main.controller @@ -91,13 +91,19 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Normal m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} + - m_Name: Flame + m_Type: 9 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -176,7 +182,7 @@ AnimatorStateMachine: m_Position: {x: 250, y: -10, z: 0} - serializedVersion: 1 m_State: {fileID: -6981161888748237111} - m_Position: {x: 240, y: 110, z: 0} + m_Position: {x: 310, y: 80, z: 0} - serializedVersion: 1 m_State: {fileID: 3909174915482303229} m_Position: {x: 275, y: 175, z: 0} @@ -184,6 +190,7 @@ AnimatorStateMachine: m_AnyStateTransitions: - {fileID: 871869168590934795} - {fileID: -6968845174723350288} + - {fileID: 6228895696704337158} m_EntryTransitions: [] m_StateMachineTransitions: {} m_StateMachineBehaviours: [] @@ -192,3 +199,28 @@ AnimatorStateMachine: m_ExitPosition: {x: 800, y: 120, z: 0} m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} m_DefaultState: {fileID: -5348363866995552689} +--- !u!1101 &6228895696704337158 +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: Flame + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 3909174915482303229} + 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 diff --git a/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_pink_Main.controller b/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_pink_Main.controller index 32f00022..0a140187 100644 --- a/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_pink_Main.controller +++ b/popcorn/Assets/MyGame/Resource/Animation/Brother/Brother_pink_Main.controller @@ -26,6 +26,7 @@ AnimatorStateMachine: - {fileID: -5209310951543379251} - {fileID: 1703827808131827942} - {fileID: -6918687918940225781} + - {fileID: 418725440919557013} m_EntryTransitions: [] m_StateMachineTransitions: {} m_StateMachineBehaviours: [] @@ -176,19 +177,25 @@ AnimatorController: 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: Sleep m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} + - m_Name: Vitality + m_Type: 9 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -202,6 +209,31 @@ AnimatorController: m_IKPass: 0 m_SyncedLayerAffectsTiming: 0 m_Controller: {fileID: 9100000} +--- !u!1101 &418725440919557013 +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: Vitality + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: -2896776327676832643} + 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 &1480020873699022687 AnimatorState: serializedVersion: 5 diff --git a/popcorn/Assets/MyGame/Scenes/Main/Main.unity b/popcorn/Assets/MyGame/Scenes/Main/Main.unity index 571f8410..ef9d75f0 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Main.unity +++ b/popcorn/Assets/MyGame/Scenes/Main/Main.unity @@ -5151,6 +5151,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9b3b578c8a46648248e58adb3ee9caba, type: 3} m_Name: m_EditorClassIdentifier: + livelyRate: 7 refreshRewardCoin: 100 cookingButton: {fileID: 414580708} adButton: {fileID: 445566315} @@ -5185,7 +5186,8 @@ MonoBehaviour: blueBrotherAnimator: {fileID: 1124341218} pinkBrotherAnimator: {fileID: 519190656} pinkTransform: {fileID: 519190655} - pinkWalkspeed: 0.8 + pinkWalkSpeed: 0.8 + pinkLivelySpeed: 1 --- !u!1 &1906074463 GameObject: m_ObjectHideFlags: 0 diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs index 9a892db0..5565eba6 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs @@ -12,6 +12,8 @@ using UnityEngine.UI; public class KitchenManager : MonoBehaviour { private static readonly double refreshWaitTime = 300; + [Range(0, 9)] + [SerializeField] private int livelyRate = 7; [SerializeField] int refreshRewardCoin = 100; [SerializeField] private Button cookingButton; [SerializeField] private Button adButton; @@ -19,6 +21,7 @@ public class KitchenManager : MonoBehaviour [SerializeField] private BulkOrderIndicatorView orderIndicatorView; private readonly Subject showAdDialogSubject = new Subject(); + IDisposable timerDisposable = null; // Start is called before the first frame update void Start() @@ -108,41 +111,65 @@ public class KitchenManager : MonoBehaviour { CoinGetDialog.ShowDialog(refreshRewardCoin, () => { - adButton.gameObject.SetActive(false); - kitchenView.SetNormalAnimation(); - CoinManager.Instance.AddCoin(refreshRewardCoin); gameData.Coin = CoinManager.Instance.OwnCoin; gameData.kitchenRefreshTime = DateTime.UtcNow.AddSeconds(refreshWaitTime).ToBinary(); GameDataManager.SaveGameData(); + + // SetTimer((int)refreshWaitTime); + adButton.gameObject.SetActive(false); + if (gameData.kitchenRefreshTime % 10 < livelyRate) + { + kitchenView.SetLivelyAnimation(); + } + else + { + kitchenView.SetNormalAnimation(); + } }); }); }).AddTo(this); // 休憩リワード var remaining = (int) DateTime.FromBinary(gameData.kitchenRefreshTime).Subtract(DateTime.UtcNow).TotalSeconds; + // timerDisposable = SetTimer(remaining); // 商品在庫計算 var shopStock = gameData.ShopStock.Count; var tankStock = gameData.StorageTanks.Sum(x => x.Stock); var totalStock = shopStock + tankStock; - if (gameData.Coin + gameData.Material.Sum(data => data.Amount) + totalStock == 0) + if (remaining <= 0 && gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay)) + { + // コイン獲得有効 + adButton.gameObject.SetActive(true); + kitchenView.SetNormalAnimation(); + } + else if (gameData.Coin + gameData.Material.Sum(data => data.Amount) + totalStock == 0) { // 所持金0救済 adButton.gameObject.SetActive(true); - kitchenView.SetTiredAnimation(); + kitchenView.SetNormalAnimation(); showAdDialogSubject.OnNext(Unit.Default); } - else if (remaining > 0 || !gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay)) + else if (remaining > 0) { + // 獲得後 adButton.gameObject.SetActive(false); - kitchenView.SetNormalAnimation(); + if (gameData.kitchenRefreshTime % 10 < livelyRate) + { + kitchenView.SetLivelyAnimation(); + } + else + { + kitchenView.SetNormalAnimation(); + } } else { - adButton.gameObject.SetActive(true); - kitchenView.SetTiredAnimation(); + // 獲得無効 + adButton.gameObject.SetActive(false); + kitchenView.SetNormalAnimation(); } #if UNITY_EDITOR Debug.Log($"remaining: {remaining}"); @@ -293,6 +320,20 @@ public class KitchenManager : MonoBehaviour return (condition <= gameData.OrderConditionCount, nextOrderId, nextOrderLevel); } + private IDisposable SetTimer(int time) + { + timerDisposable?.Dispose(); + return Observable.Timer(TimeSpan.Zero,TimeSpan.FromSeconds(1f)) + .Select(x => (int)(time - x)) + .TakeWhile(x => x > 0) + .Subscribe(x => { } + , () => + { + kitchenView.SetNormalAnimation(); + adButton.gameObject.SetActive(true); + }).AddTo(this); + } + private void OnDestroy() { if (SoundManager.ExistsInstance) diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenView.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenView.cs index 739210f0..0e37b392 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenView.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenView.cs @@ -8,14 +8,17 @@ public class KitchenView : MonoBehaviour // blue private static readonly int Normal = Animator.StringToHash("Normal"); private static readonly int Tired = Animator.StringToHash("Tired"); + private static readonly int Flame = Animator.StringToHash("Flame"); // pink private static readonly int Walk = Animator.StringToHash("Walk"); private static readonly int Stay = Animator.StringToHash("Stay"); private static readonly int Sleep = Animator.StringToHash("Sleep"); + private static readonly int Vitality = Animator.StringToHash("Vitality"); [SerializeField] private Animator blueBrotherAnimator; [SerializeField] private Animator pinkBrotherAnimator; [SerializeField] private Transform pinkTransform; - [SerializeField] private float pinkWalkspeed = .8f; + [SerializeField] private float pinkWalkSpeed = .8f; + [SerializeField] private float pinkLivelySpeed = .8f; private readonly (int trigger, Vector2 wayPoint, float wait)[] pinkMoves = { (Walk, new Vector2(3.28f,0.726f), 0f), @@ -27,22 +30,27 @@ public class KitchenView : MonoBehaviour (Walk, new Vector2(0f,0.726f), 0f), (Stay, new Vector2(0f,0.726f), 3f), }; + + private readonly (int trigger, Vector2 wayPoint, float wait)[] livelyPinkMoves = + { + (Vitality, new Vector2(3.28f,0.726f), 0f), + (Vitality, new Vector2(-3.28f,0.726f), 0f), + }; private int moveIndex; private Vector2 wayPoint; private float durationDelta; private float completedDuration; - private bool isTired; + private bool isLively; + private (int trigger, Vector2 wayPoint, float wait)[] selectedMoves; + private void Start() { this.UpdateAsObservable().Subscribe(_ => { - if (isTired) - { - return; - } + var pinkSpeed = isLively ? pinkLivelySpeed : pinkWalkSpeed; var localPosition = pinkTransform.localPosition; - localPosition = Vector2.MoveTowards(localPosition, wayPoint, pinkWalkspeed * Time.deltaTime); + localPosition = Vector2.MoveTowards(localPosition, wayPoint, pinkSpeed * Time.deltaTime); pinkTransform.localPosition = localPosition; if (Vector2.Distance(localPosition, wayPoint) < .01f) { @@ -53,7 +61,7 @@ public class KitchenView : MonoBehaviour } durationDelta = 0; moveIndex++; - if (moveIndex == pinkMoves.Length) + if (moveIndex >= selectedMoves.Length) { moveIndex = 0; } @@ -67,9 +75,15 @@ public class KitchenView : MonoBehaviour moveIndex = 0; } + private void ChangeAnimation() + { + moveIndex = 0; + selectedMoves = isLively ? livelyPinkMoves : pinkMoves; + } + private void SetPinkMove() { - var move = pinkMoves[moveIndex]; + var move = selectedMoves[moveIndex]; wayPoint = move.wayPoint; completedDuration = move.wait; pinkBrotherAnimator.SetTrigger(move.trigger); @@ -88,15 +102,17 @@ public class KitchenView : MonoBehaviour public void SetNormalAnimation() { - isTired = false; + isLively = false; + ChangeAnimation(); SetPinkMove(); blueBrotherAnimator.SetTrigger(Normal); } - public void SetTiredAnimation() + public void SetLivelyAnimation() { - isTired = true; - blueBrotherAnimator.SetTrigger(Tired); - pinkBrotherAnimator.SetTrigger(Sleep); + isLively = true; + ChangeAnimation(); + SetPinkMove(); + blueBrotherAnimator.SetTrigger(Flame); } }