From 3873bd7f15669405d52e3cc34423dc2d34559798 Mon Sep 17 00:00:00 2001 From: kimura Date: Thu, 9 Dec 2021 15:24:42 +0900 Subject: [PATCH] =?UTF-8?q?=E8=B2=A9=E5=A3=B2=E3=81=8A=E5=AE=A2=E3=81=95?= =?UTF-8?q?=E3=82=93=E3=81=AE=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF=E3=81=A8?= =?UTF-8?q?=E3=82=A2=E3=83=8B=E3=83=A1=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=81=AE=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/Title/Scripts/Title.cs | 2 +- .../marketing/Scripts/CustomerAnimator.cs | 42 +++++++++++++++---- .../Scenes/marketing/Scripts/MarketManager.cs | 11 +++-- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Title/Scripts/Title.cs b/popcorn/Assets/MyGame/Scenes/Title/Scripts/Title.cs index 477083da..2e1d0a4a 100644 --- a/popcorn/Assets/MyGame/Scenes/Title/Scripts/Title.cs +++ b/popcorn/Assets/MyGame/Scenes/Title/Scripts/Title.cs @@ -89,7 +89,7 @@ public class Title : MonoBehaviour var customerAnimator = Instantiate(customerController.CustomerPrefab, customerObject.transform); customerController.CurrentMovingType.Subscribe(x => { - customerAnimator.SetTrigger(x); + customerAnimator.SetTrigger(x, customerController.DurationDelta); }).AddTo(customerAnimator); customerController.IsDefaultSide.Subscribe(x => { diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerAnimator.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerAnimator.cs index 5cd39b7c..2af282a0 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerAnimator.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerAnimator.cs @@ -5,14 +5,18 @@ using UnityEngine; public class CustomerAnimator : MonoBehaviour { - public static readonly string WantFlavorAmountFormat = "x{0}"; + private static readonly string WantFlavorAmountFormat = "x{0}"; - public static readonly int WalkFront = Animator.StringToHash("WalkFront"); - public static readonly int WalkSide = Animator.StringToHash("WalkSide"); - public static readonly int WalkBack = Animator.StringToHash("WalkBack"); - public static readonly int StayBack = Animator.StringToHash("StayBack"); - public static readonly int WalkFrontEat = Animator.StringToHash("WalkFrontEat"); - public static readonly int WalkSideEat = Animator.StringToHash("WalkSideEat"); + private static readonly int WalkFront = Animator.StringToHash("WalkFront"); + private static readonly int WalkSide = Animator.StringToHash("WalkSide"); + private static readonly int WalkBack = Animator.StringToHash("WalkBack"); + private static readonly int StayBack = Animator.StringToHash("StayBack"); + private static readonly int WalkFrontEat = Animator.StringToHash("WalkFrontEat"); + private static readonly int WalkSideEat = Animator.StringToHash("WalkSideEat"); + private static readonly int TouchNotice = Animator.StringToHash("TouchNotice"); + private static readonly int TouchQuestion = Animator.StringToHash("TouchQuestion"); + private static readonly int HashTouchNoticeState = Animator.StringToHash("Base Layer.customer_nomal_touch_notice"); + private static readonly int HashTouchQuestionState = Animator.StringToHash("Base Layer.customer_nomal_touch_Question"); private static readonly int Complain = Animator.StringToHash("ComplainTrigger"); @@ -38,7 +42,7 @@ public class CustomerAnimator : MonoBehaviour }).AddTo(this); } - public void SetTrigger(CustomerMovingType movingType) + public void SetTrigger(CustomerMovingType movingType, float duration) { switch (movingType) { @@ -51,6 +55,14 @@ public class CustomerAnimator : MonoBehaviour case CustomerMovingType.WalkCenter: triggerName.Value = WalkSide; break; + case CustomerMovingType.TouchNotice: + // Durationをもとに途中再生 + PlayResumeAnimation(HashTouchNoticeState, duration); + break; + case CustomerMovingType.TouchQuestion: + // Durationをもとに途中再生 + PlayResumeAnimation(HashTouchQuestionState, duration); + break; case CustomerMovingType.StayBackOrder: triggerName.Value = StayBack; break; @@ -75,6 +87,20 @@ public class CustomerAnimator : MonoBehaviour } + private void PlayResumeAnimation(int stateHashName, float duration) + { + /* + * durationをNormalizedTimeに変換するために + * State指定して1フレーム後にGetCurrentAnimatorClipInfoしている + */ + animator.Play(stateHashName); + Observable.NextFrame().Subscribe(_ => + { + var length = animator.GetCurrentAnimatorClipInfo(0)[0].clip.length; + animator.Play(stateHashName, 0, Mathf.Clamp01(duration/length)); + }).AddTo(this); + } + public void SetSide(bool isDefaultSide) { if (isDefaultSide) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs index 1e9cb61e..2b64fc5f 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs @@ -309,7 +309,7 @@ public class MarketManager : MonoBehaviour var customerAnimator = Instantiate(controller.CustomerPrefab, customerObject.transform); controller.CurrentMovingType.Subscribe(x => { - customerAnimator.SetTrigger(x); + customerAnimator.SetTrigger(x, controller.DurationDelta); }).AddTo(customerAnimator); controller.IsDefaultSide.Subscribe(x => { @@ -355,7 +355,6 @@ public class MarketManager : MonoBehaviour }).AddTo(customerAnimator); var eventTrigger = customerAnimator.gameObject.AddComponent(); eventTrigger.OnPointerClickAsObservable() - .Where(_ => market.CurrentShopState.Value != ShopState.Close) .Take(1) .Subscribe(_ => { @@ -364,14 +363,14 @@ public class MarketManager : MonoBehaviour Destroy(target); } - if (controller.State.Value != CustomerState.Walk && - controller.State.Value != CustomerState.WalkShop && - controller.State.Value != CustomerState.CenterStop) + if (!(controller.State.Value == CustomerState.Walk || + controller.State.Value == CustomerState.WalkShop || + controller.State.Value == CustomerState.CenterStop)) { return; } + controller.Tapped(); - customerAnimator.ShowTapReaction(); VibrationManager.Instance.PlayVibrationOnce(); }).AddTo(customerAnimator); }