販売シーン試食中制御追加
This commit is contained in:
parent
d7e9172635
commit
f9ceb4bde8
|
|
@ -91,6 +91,8 @@ AnimatorStateMachine:
|
||||||
- {fileID: 51081042415013300}
|
- {fileID: 51081042415013300}
|
||||||
- {fileID: 4394378192515912696}
|
- {fileID: 4394378192515912696}
|
||||||
- {fileID: -4201787685094799525}
|
- {fileID: -4201787685094799525}
|
||||||
|
- {fileID: 1938256483501769669}
|
||||||
|
- {fileID: 265964369079198928}
|
||||||
m_EntryTransitions: []
|
m_EntryTransitions: []
|
||||||
m_StateMachineTransitions: {}
|
m_StateMachineTransitions: {}
|
||||||
m_StateMachineBehaviours: []
|
m_StateMachineBehaviours: []
|
||||||
|
|
@ -242,25 +244,37 @@ AnimatorController:
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
- m_Name: Promotion
|
- m_Name: Promotion
|
||||||
m_Type: 9
|
m_Type: 9
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
- m_Name: Sleepy
|
- m_Name: Sleepy
|
||||||
m_Type: 9
|
m_Type: 9
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
- m_Name: Walk
|
- m_Name: Walk
|
||||||
m_Type: 9
|
m_Type: 9
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 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:
|
m_AnimatorLayers:
|
||||||
- serializedVersion: 5
|
- serializedVersion: 5
|
||||||
m_Name: Base Layer
|
m_Name: Base Layer
|
||||||
|
|
@ -299,6 +313,56 @@ AnimatorStateTransition:
|
||||||
m_InterruptionSource: 0
|
m_InterruptionSource: 0
|
||||||
m_OrderedInterruption: 1
|
m_OrderedInterruption: 1
|
||||||
m_CanTransitionToSelf: 0
|
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
|
--- !u!1102 &4390197982913342166
|
||||||
AnimatorState:
|
AnimatorState:
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using MyGame.Scenes.marketing.Scripts;
|
||||||
using UniRx;
|
using UniRx;
|
||||||
using UniRx.Triggers;
|
using UniRx.Triggers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -9,6 +10,8 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
||||||
private static readonly int Promotion = Animator.StringToHash("Promotion");
|
private static readonly int Promotion = Animator.StringToHash("Promotion");
|
||||||
private static readonly int Sleepy = Animator.StringToHash("Sleepy");
|
private static readonly int Sleepy = Animator.StringToHash("Sleepy");
|
||||||
private static readonly int Walk = Animator.StringToHash("Walk");
|
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 RightPos = new Vector2(4.96f, -0.26f);
|
||||||
private static readonly Vector2 LeftPos = 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<BrotherPinkView>
|
||||||
public int FewerBorder => fewerBorder;
|
public int FewerBorder => fewerBorder;
|
||||||
|
|
||||||
private Animator animator;
|
private Animator animator;
|
||||||
private bool isManyCustomer;
|
private TastingBasketView basketView;
|
||||||
private bool isLocked;
|
private bool waitMove;
|
||||||
|
private bool isMoveLocked;
|
||||||
private bool isPromotion;
|
private bool isPromotion;
|
||||||
|
private bool isEndingPromotion;
|
||||||
|
private bool isTasting;
|
||||||
private int nextId;
|
private int nextId;
|
||||||
private readonly (int trigger, Vector2 wayPoint, float wait)[] pinkMoves =
|
private readonly (int trigger, Vector2 wayPoint, float wait)[] pinkMoves =
|
||||||
{
|
{
|
||||||
|
|
@ -33,23 +39,48 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
||||||
(Walk, RightPos, 0f),
|
(Walk, RightPos, 0f),
|
||||||
(Promotion, RightPos + Vector2.left * .03f, 5.35f),
|
(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 int moveIndex;
|
||||||
private Vector2 wayPoint;
|
private Vector2 wayPoint;
|
||||||
private float durationDelta;
|
private float durationDelta;
|
||||||
private float completedDuration;
|
private float completedDuration;
|
||||||
|
private (int trigger, Vector2 wayPoint, float wait)[] selectedMoves;
|
||||||
|
private IDisposable moveLockDispose;
|
||||||
|
private Subject<int> setTrigger = new Subject<int>();
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
setTrigger.AddTo(this);
|
||||||
nextId = Normal;
|
nextId = Normal;
|
||||||
isManyCustomer = true;
|
waitMove = true;
|
||||||
|
selectedMoves = pinkMoves;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
pinkTransform.localPosition = RightPos;
|
pinkTransform.localPosition = RightPos;
|
||||||
|
/*
|
||||||
|
* 1フレーム内で最後に受け取った値をSetする
|
||||||
|
* アニメーター挙動考慮
|
||||||
|
*/
|
||||||
|
setTrigger
|
||||||
|
.ThrottleFrame(1)
|
||||||
|
.Subscribe(x =>
|
||||||
|
{
|
||||||
|
if (animator != null)
|
||||||
|
{
|
||||||
|
animator.SetTrigger(x);
|
||||||
|
}
|
||||||
|
}).AddTo(this);
|
||||||
this.UpdateAsObservable().Subscribe(_ =>
|
this.UpdateAsObservable().Subscribe(_ =>
|
||||||
{
|
{
|
||||||
if (isManyCustomer || isLocked || isPromotion)
|
if (waitMove || isMoveLocked || isPromotion)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -66,14 +97,16 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
||||||
}
|
}
|
||||||
durationDelta = 0;
|
durationDelta = 0;
|
||||||
moveIndex++;
|
moveIndex++;
|
||||||
if (moveIndex == pinkMoves.Length)
|
if (moveIndex == selectedMoves.Length)
|
||||||
{
|
{
|
||||||
|
if (isTasting)
|
||||||
|
{
|
||||||
|
moveIndex = 0;
|
||||||
|
SetPinkMove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
ResetMove();
|
ResetMove();
|
||||||
isLocked = true;
|
LockMove(coolTime);
|
||||||
this.CallWaitForSeconds(coolTime, () =>
|
|
||||||
{
|
|
||||||
isLocked = false;
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetPinkMove();
|
SetPinkMove();
|
||||||
|
|
@ -81,10 +114,21 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
||||||
}).AddTo(this);
|
}).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()
|
private void ResetMove()
|
||||||
{
|
{
|
||||||
|
waitMove = true;
|
||||||
moveIndex = 0;
|
moveIndex = 0;
|
||||||
isManyCustomer = true;
|
|
||||||
if (animator != null) animator.SetTrigger(nextId);
|
if (animator != null) animator.SetTrigger(nextId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,12 +136,13 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
||||||
{
|
{
|
||||||
target.DestroyAllChildrens();
|
target.DestroyAllChildrens();
|
||||||
animator = Instantiate(animatorPrefab, target);
|
animator = Instantiate(animatorPrefab, target);
|
||||||
|
basketView = animator.GetComponent<TastingBasketView>();
|
||||||
this.UpdateAsObservable().Subscribe(_ =>
|
this.UpdateAsObservable().Subscribe(_ =>
|
||||||
{
|
{
|
||||||
target.localPosition = pinkTransform.localPosition;
|
target.localPosition = pinkTransform.localPosition;
|
||||||
target.localRotation = pinkTransform.localRotation;
|
target.localRotation = pinkTransform.localRotation;
|
||||||
}).AddTo(animator);
|
}).AddTo(animator);
|
||||||
if (isManyCustomer || isPromotion)
|
if (waitMove || isPromotion || isTasting)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -106,13 +151,14 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
||||||
|
|
||||||
private void SetPinkMove()
|
private void SetPinkMove()
|
||||||
{
|
{
|
||||||
var move = pinkMoves[moveIndex];
|
var move = selectedMoves[moveIndex];
|
||||||
wayPoint = move.wayPoint;
|
wayPoint = move.wayPoint;
|
||||||
completedDuration = move.wait;
|
completedDuration = move.wait;
|
||||||
if (animator != null)
|
if (animator != null)
|
||||||
{
|
{
|
||||||
animator.ResetTrigger(Normal);
|
animator.ResetTrigger(Normal);
|
||||||
animator.SetTrigger(move.trigger);
|
// animator.SetTrigger(move.trigger);
|
||||||
|
setTrigger.OnNext(move.trigger);
|
||||||
}
|
}
|
||||||
if (Vector2.Distance(wayPoint, pinkTransform.localPosition.ToVector2()) < .01f)
|
if (Vector2.Distance(wayPoint, pinkTransform.localPosition.ToVector2()) < .01f)
|
||||||
{
|
{
|
||||||
|
|
@ -127,10 +173,11 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// お客さんが多い場合に使用するアニメーション切替え
|
||||||
private void SetTrigger(int id)
|
private void SetTrigger(int id)
|
||||||
{
|
{
|
||||||
nextId = id;
|
nextId = id;
|
||||||
if (isManyCustomer)
|
if (waitMove)
|
||||||
{
|
{
|
||||||
animator.SetTrigger(id);
|
animator.SetTrigger(id);
|
||||||
}
|
}
|
||||||
|
|
@ -160,35 +207,51 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
||||||
public void StopPromotion()
|
public void StopPromotion()
|
||||||
{
|
{
|
||||||
if (animator != null)
|
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);
|
animator.ResetTrigger(Promotion);
|
||||||
ResetMove();
|
|
||||||
isPromotion = false;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ResetMove();
|
ResetMove();
|
||||||
isPromotion = false;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (isManyCustomer)
|
isTasting = false;
|
||||||
|
selectedMoves = pinkMoves;
|
||||||
|
SetPinkMove();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTastingCount(int count)
|
||||||
{
|
{
|
||||||
isManyCustomer = false;
|
if (basketView != null)
|
||||||
|
{
|
||||||
|
basketView.SetItem(count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetWalk()
|
||||||
|
{
|
||||||
|
if (!waitMove || isMoveLocked || isPromotion || isTasting)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
waitMove = false;
|
||||||
SetPinkMove();
|
SetPinkMove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue