販売シーン試食中制御追加
This commit is contained in:
parent
d7e9172635
commit
f9ceb4bde8
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<BrotherPinkView>
|
|||
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<BrotherPinkView>
|
|||
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<BrotherPinkView>
|
|||
(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<int> setTrigger = new Subject<int>();
|
||||
|
||||
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<BrotherPinkView>
|
|||
}
|
||||
durationDelta = 0;
|
||||
moveIndex++;
|
||||
if (moveIndex == pinkMoves.Length)
|
||||
if (moveIndex == selectedMoves.Length)
|
||||
{
|
||||
if (isTasting)
|
||||
{
|
||||
moveIndex = 0;
|
||||
SetPinkMove();
|
||||
return;
|
||||
}
|
||||
ResetMove();
|
||||
isLocked = true;
|
||||
this.CallWaitForSeconds(coolTime, () =>
|
||||
{
|
||||
isLocked = false;
|
||||
});
|
||||
LockMove(coolTime);
|
||||
return;
|
||||
}
|
||||
SetPinkMove();
|
||||
|
|
@ -81,10 +114,21 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
|||
}).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<BrotherPinkView>
|
|||
{
|
||||
target.DestroyAllChildrens();
|
||||
animator = Instantiate(animatorPrefab, target);
|
||||
basketView = animator.GetComponent<TastingBasketView>();
|
||||
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<BrotherPinkView>
|
|||
|
||||
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<BrotherPinkView>
|
|||
}
|
||||
}
|
||||
|
||||
// お客さんが多い場合に使用するアニメーション切替え
|
||||
private void SetTrigger(int id)
|
||||
{
|
||||
nextId = id;
|
||||
if (isManyCustomer)
|
||||
if (waitMove)
|
||||
{
|
||||
animator.SetTrigger(id);
|
||||
}
|
||||
|
|
@ -160,35 +207,51 @@ public class BrotherPinkView : SingletonMonoBehaviour<BrotherPinkView>
|
|||
public void StopPromotion()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
isManyCustomer = false;
|
||||
isTasting = false;
|
||||
selectedMoves = pinkMoves;
|
||||
SetPinkMove();
|
||||
}
|
||||
|
||||
public void SetTastingCount(int count)
|
||||
{
|
||||
if (basketView != null)
|
||||
{
|
||||
basketView.SetItem(count);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetWalk()
|
||||
{
|
||||
if (!waitMove || isMoveLocked || isPromotion || isTasting)
|
||||
{
|
||||
return;
|
||||
}
|
||||
waitMove = false;
|
||||
SetPinkMove();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue