販売お客さんのロジックとアニメーションの対応
This commit is contained in:
parent
2435cfbc92
commit
3873bd7f15
|
|
@ -89,7 +89,7 @@ public class Title : MonoBehaviour
|
||||||
var customerAnimator = Instantiate(customerController.CustomerPrefab, customerObject.transform);
|
var customerAnimator = Instantiate(customerController.CustomerPrefab, customerObject.transform);
|
||||||
customerController.CurrentMovingType.Subscribe(x =>
|
customerController.CurrentMovingType.Subscribe(x =>
|
||||||
{
|
{
|
||||||
customerAnimator.SetTrigger(x);
|
customerAnimator.SetTrigger(x, customerController.DurationDelta);
|
||||||
}).AddTo(customerAnimator);
|
}).AddTo(customerAnimator);
|
||||||
customerController.IsDefaultSide.Subscribe(x =>
|
customerController.IsDefaultSide.Subscribe(x =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,18 @@ using UnityEngine;
|
||||||
|
|
||||||
public class CustomerAnimator : MonoBehaviour
|
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");
|
private static readonly int WalkFront = Animator.StringToHash("WalkFront");
|
||||||
public static readonly int WalkSide = Animator.StringToHash("WalkSide");
|
private static readonly int WalkSide = Animator.StringToHash("WalkSide");
|
||||||
public static readonly int WalkBack = Animator.StringToHash("WalkBack");
|
private static readonly int WalkBack = Animator.StringToHash("WalkBack");
|
||||||
public static readonly int StayBack = Animator.StringToHash("StayBack");
|
private static readonly int StayBack = Animator.StringToHash("StayBack");
|
||||||
public static readonly int WalkFrontEat = Animator.StringToHash("WalkFrontEat");
|
private static readonly int WalkFrontEat = Animator.StringToHash("WalkFrontEat");
|
||||||
public static readonly int WalkSideEat = Animator.StringToHash("WalkSideEat");
|
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");
|
private static readonly int Complain = Animator.StringToHash("ComplainTrigger");
|
||||||
|
|
||||||
|
|
@ -38,7 +42,7 @@ public class CustomerAnimator : MonoBehaviour
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTrigger(CustomerMovingType movingType)
|
public void SetTrigger(CustomerMovingType movingType, float duration)
|
||||||
{
|
{
|
||||||
switch (movingType)
|
switch (movingType)
|
||||||
{
|
{
|
||||||
|
|
@ -51,6 +55,14 @@ public class CustomerAnimator : MonoBehaviour
|
||||||
case CustomerMovingType.WalkCenter:
|
case CustomerMovingType.WalkCenter:
|
||||||
triggerName.Value = WalkSide;
|
triggerName.Value = WalkSide;
|
||||||
break;
|
break;
|
||||||
|
case CustomerMovingType.TouchNotice:
|
||||||
|
// Durationをもとに途中再生
|
||||||
|
PlayResumeAnimation(HashTouchNoticeState, duration);
|
||||||
|
break;
|
||||||
|
case CustomerMovingType.TouchQuestion:
|
||||||
|
// Durationをもとに途中再生
|
||||||
|
PlayResumeAnimation(HashTouchQuestionState, duration);
|
||||||
|
break;
|
||||||
case CustomerMovingType.StayBackOrder:
|
case CustomerMovingType.StayBackOrder:
|
||||||
triggerName.Value = StayBack;
|
triggerName.Value = StayBack;
|
||||||
break;
|
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)
|
public void SetSide(bool isDefaultSide)
|
||||||
{
|
{
|
||||||
if (isDefaultSide)
|
if (isDefaultSide)
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,7 @@ public class MarketManager : MonoBehaviour
|
||||||
var customerAnimator = Instantiate(controller.CustomerPrefab, customerObject.transform);
|
var customerAnimator = Instantiate(controller.CustomerPrefab, customerObject.transform);
|
||||||
controller.CurrentMovingType.Subscribe(x =>
|
controller.CurrentMovingType.Subscribe(x =>
|
||||||
{
|
{
|
||||||
customerAnimator.SetTrigger(x);
|
customerAnimator.SetTrigger(x, controller.DurationDelta);
|
||||||
}).AddTo(customerAnimator);
|
}).AddTo(customerAnimator);
|
||||||
controller.IsDefaultSide.Subscribe(x =>
|
controller.IsDefaultSide.Subscribe(x =>
|
||||||
{
|
{
|
||||||
|
|
@ -355,7 +355,6 @@ public class MarketManager : MonoBehaviour
|
||||||
}).AddTo(customerAnimator);
|
}).AddTo(customerAnimator);
|
||||||
var eventTrigger = customerAnimator.gameObject.AddComponent<ObservableEventTrigger>();
|
var eventTrigger = customerAnimator.gameObject.AddComponent<ObservableEventTrigger>();
|
||||||
eventTrigger.OnPointerClickAsObservable()
|
eventTrigger.OnPointerClickAsObservable()
|
||||||
.Where(_ => market.CurrentShopState.Value != ShopState.Close)
|
|
||||||
.Take(1)
|
.Take(1)
|
||||||
.Subscribe(_ =>
|
.Subscribe(_ =>
|
||||||
{
|
{
|
||||||
|
|
@ -364,14 +363,14 @@ public class MarketManager : MonoBehaviour
|
||||||
Destroy(target);
|
Destroy(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller.State.Value != CustomerState.Walk &&
|
if (!(controller.State.Value == CustomerState.Walk ||
|
||||||
controller.State.Value != CustomerState.WalkShop &&
|
controller.State.Value == CustomerState.WalkShop ||
|
||||||
controller.State.Value != CustomerState.CenterStop)
|
controller.State.Value == CustomerState.CenterStop))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.Tapped();
|
controller.Tapped();
|
||||||
customerAnimator.ShowTapReaction();
|
|
||||||
VibrationManager.Instance.PlayVibrationOnce();
|
VibrationManager.Instance.PlayVibrationOnce();
|
||||||
}).AddTo(customerAnimator);
|
}).AddTo(customerAnimator);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue