Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop
This commit is contained in:
commit
59fcc652d7
|
|
@ -5301,6 +5301,7 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 4886416728471897984}
|
- component: {fileID: 4886416728471897984}
|
||||||
- component: {fileID: 4886416728471897985}
|
- component: {fileID: 4886416728471897985}
|
||||||
|
- component: {fileID: 5450916343452979085}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: customer_normal
|
m_Name: customer_normal
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -5346,6 +5347,21 @@ Animator:
|
||||||
m_HasTransformHierarchy: 1
|
m_HasTransformHierarchy: 1
|
||||||
m_AllowConstantClipSamplingOptimization: 1
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
m_KeepAnimatorControllerStateOnDisable: 0
|
m_KeepAnimatorControllerStateOnDisable: 0
|
||||||
|
--- !u!114 &5450916343452979085
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4886416728471897999}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 0eb44b30c9454383898faae0c3666b94, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
bodySides:
|
||||||
|
- {fileID: 4886416730379292501}
|
||||||
|
- {fileID: 4886416728696845434}
|
||||||
--- !u!1 &4886416728477582529
|
--- !u!1 &4886416728477582529
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,16 @@
|
||||||
%YAML 1.1
|
%YAML 1.1
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!210 &1027147620336589506
|
||||||
|
SortingGroup:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5409985849609444268}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 23
|
||||||
--- !u!1 &5409985849651702440
|
--- !u!1 &5409985849651702440
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -46,6 +57,7 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
animator: {fileID: 5409985851491668857}
|
animator: {fileID: 5409985851491668857}
|
||||||
|
customerDirection: {fileID: 4855338754077236085}
|
||||||
orderPopup: {fileID: 5409985850085678672}
|
orderPopup: {fileID: 5409985850085678672}
|
||||||
leftPopcorn: {fileID: 1950136324582499262}
|
leftPopcorn: {fileID: 1950136324582499262}
|
||||||
rightPopcorn: {fileID: 1950136324150437342}
|
rightPopcorn: {fileID: 1950136324150437342}
|
||||||
|
|
@ -79,7 +91,17 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
bigHeart: {fileID: 7988005957398545984}
|
bigHeart: {fileID: 7988005957398545984}
|
||||||
smallHeart: {fileID: 992423202615605163}
|
smallHeart: {fileID: 992423202615605163}
|
||||||
target: {fileID: 0}
|
--- !u!210 &3225622249943924906
|
||||||
|
SortingGroup:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5409985851148247169}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 23
|
||||||
--- !u!61 &3337152902562194938
|
--- !u!61 &3337152902562194938
|
||||||
BoxCollider2D:
|
BoxCollider2D:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -106,17 +128,6 @@ BoxCollider2D:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2}
|
m_Size: {x: 2, y: 2}
|
||||||
m_EdgeRadius: 0
|
m_EdgeRadius: 0
|
||||||
--- !u!210 &7449452199590198578
|
|
||||||
SortingGroup:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 5409985851491668855}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_SortingLayerID: 0
|
|
||||||
m_SortingLayer: 0
|
|
||||||
m_SortingOrder: 23
|
|
||||||
--- !u!1001 &631677504613307640
|
--- !u!1001 &631677504613307640
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -204,6 +215,16 @@ PrefabInstance:
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 6511433195714067906, guid: db654393793a67d45a7d0b70a68b73a6,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_IsActive
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7358655632798716600, guid: db654393793a67d45a7d0b70a68b73a6,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_IsActive
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8422870931014696725, guid: db654393793a67d45a7d0b70a68b73a6,
|
- target: {fileID: 8422870931014696725, guid: db654393793a67d45a7d0b70a68b73a6,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
|
|
@ -234,12 +255,36 @@ Animator:
|
||||||
type: 3}
|
type: 3}
|
||||||
m_PrefabInstance: {fileID: 631677504613307640}
|
m_PrefabInstance: {fileID: 631677504613307640}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &4855338754077236085 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 5450916343452979085, guid: db654393793a67d45a7d0b70a68b73a6,
|
||||||
|
type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 631677504613307640}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5409985851491668855}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 0eb44b30c9454383898faae0c3666b94, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!1 &5409985849609444268 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 4886416730379292500, guid: db654393793a67d45a7d0b70a68b73a6,
|
||||||
|
type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 631677504613307640}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!212 &1950136324089803489 stripped
|
--- !u!212 &1950136324089803489 stripped
|
||||||
SpriteRenderer:
|
SpriteRenderer:
|
||||||
m_CorrespondingSourceObject: {fileID: 1428887861354145305, guid: db654393793a67d45a7d0b70a68b73a6,
|
m_CorrespondingSourceObject: {fileID: 1428887861354145305, guid: db654393793a67d45a7d0b70a68b73a6,
|
||||||
type: 3}
|
type: 3}
|
||||||
m_PrefabInstance: {fileID: 631677504613307640}
|
m_PrefabInstance: {fileID: 631677504613307640}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!1 &5409985851148247169 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 4886416728696845433, guid: db654393793a67d45a7d0b70a68b73a6,
|
||||||
|
type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 631677504613307640}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!212 &1950136324150437342 stripped
|
--- !u!212 &1950136324150437342 stripped
|
||||||
SpriteRenderer:
|
SpriteRenderer:
|
||||||
m_CorrespondingSourceObject: {fileID: 1428887861146841382, guid: db654393793a67d45a7d0b70a68b73a6,
|
m_CorrespondingSourceObject: {fileID: 1428887861146841382, guid: db654393793a67d45a7d0b70a68b73a6,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ public enum CustomerMovingType
|
||||||
public enum CustomerState
|
public enum CustomerState
|
||||||
{
|
{
|
||||||
Walk,
|
Walk,
|
||||||
|
WalkShop,
|
||||||
Wait,
|
Wait,
|
||||||
Order,
|
Order,
|
||||||
Leave,
|
Leave,
|
||||||
|
|
@ -37,6 +38,7 @@ public class CustomerController : MonoBehaviour
|
||||||
private static readonly int WalkSideEat = Animator.StringToHash("WalkSideEat");
|
private static readonly int WalkSideEat = Animator.StringToHash("WalkSideEat");
|
||||||
|
|
||||||
[SerializeField] private Animator animator;
|
[SerializeField] private Animator animator;
|
||||||
|
[SerializeField] private CustomerDirection customerDirection;
|
||||||
|
|
||||||
[SerializeField] private GameObject orderPopup;
|
[SerializeField] private GameObject orderPopup;
|
||||||
[SerializeField] private SpriteRenderer leftPopcorn;
|
[SerializeField] private SpriteRenderer leftPopcorn;
|
||||||
|
|
@ -67,6 +69,7 @@ public class CustomerController : MonoBehaviour
|
||||||
private Vector3 beginPos;
|
private Vector3 beginPos;
|
||||||
private Vector3 wayPoint;
|
private Vector3 wayPoint;
|
||||||
private CustomerMovingType currentMovingType;
|
private CustomerMovingType currentMovingType;
|
||||||
|
private bool isMoveOverride;
|
||||||
private List<(CustomerMovingType type, float duration)> moves = new List<(CustomerMovingType, float)>();
|
private List<(CustomerMovingType type, float duration)> moves = new List<(CustomerMovingType, float)>();
|
||||||
private float speed = 0f;
|
private float speed = 0f;
|
||||||
private float completedDuration;
|
private float completedDuration;
|
||||||
|
|
@ -84,16 +87,23 @@ public class CustomerController : MonoBehaviour
|
||||||
durationDelta = 0f;
|
durationDelta = 0f;
|
||||||
this.UpdateAsObservable().Subscribe(_ =>
|
this.UpdateAsObservable().Subscribe(_ =>
|
||||||
{
|
{
|
||||||
transform.localPosition = Vector3.MoveTowards(transform.localPosition, wayPoint, speed * Time.deltaTime);
|
var localPosition = transform.localPosition;
|
||||||
if (Vector3.Distance(transform.localPosition, wayPoint) < .01f)
|
localPosition = Vector2.MoveTowards(localPosition, wayPoint, speed * Time.deltaTime);
|
||||||
|
localPosition = localPosition + Vector3.forward * (localPosition.y + Mathf.Abs(walkSideBottomPos));
|
||||||
|
transform.localPosition = localPosition;
|
||||||
|
if (Vector2.Distance(localPosition, wayPoint) < .01f)
|
||||||
{
|
{
|
||||||
if (durationDelta < completedDuration)
|
if (durationDelta < completedDuration)
|
||||||
{
|
{
|
||||||
durationDelta += Time.deltaTime;
|
durationDelta += Time.deltaTime;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
durationDelta = 0f;
|
|
||||||
moveEndSubject.Value = currentMovingType;
|
moveEndSubject.Value = currentMovingType;
|
||||||
|
if (isMoveOverride)
|
||||||
|
{
|
||||||
|
isMoveOverride = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (moves.Count > 0)
|
if (moves.Count > 0)
|
||||||
{
|
{
|
||||||
var move = moves[0];
|
var move = moves[0];
|
||||||
|
|
@ -111,7 +121,9 @@ public class CustomerController : MonoBehaviour
|
||||||
beginPos.x = leftEndPosision * walkSideDirection;
|
beginPos.x = leftEndPosision * walkSideDirection;
|
||||||
beginPos.y = Random.Range(walkSideMidPos, walkSideBottomPos);
|
beginPos.y = Random.Range(walkSideMidPos, walkSideBottomPos);
|
||||||
transform.localPosition = beginPos;
|
transform.localPosition = beginPos;
|
||||||
currentMovingType = CustomerMovingType.StayBackOrder;
|
currentMovingType = CustomerMovingType.StayBack;
|
||||||
|
moveEndSubject.Value = CustomerMovingType.StayBack;
|
||||||
|
isMoveOverride = false;
|
||||||
SetWayPoint(beginPos);
|
SetWayPoint(beginPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,25 +134,19 @@ public class CustomerController : MonoBehaviour
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case CustomerState.Walk:
|
case CustomerState.Walk:
|
||||||
SetMove(CustomerMovingType.WalkCenter);
|
ForceSetMove(CustomerMovingType.WalkCenter);
|
||||||
// 数秒立ち止まる
|
// 数秒立ち止まる
|
||||||
AddMove(CustomerMovingType.StayBack, 2f);
|
AddMove(CustomerMovingType.StayBack, 2f);
|
||||||
AddMove(CustomerMovingType.WalkSide);
|
AddMove(CustomerMovingType.WalkSide);
|
||||||
break;
|
break;
|
||||||
|
case CustomerState.WalkShop:
|
||||||
|
ForceSetMove(CustomerMovingType.WalkCenter);
|
||||||
|
break;
|
||||||
case CustomerState.Wait:
|
case CustomerState.Wait:
|
||||||
// 店に向かう&順番待ち
|
// 店に向かう&順番待ち
|
||||||
// 近くの場合その場に待機
|
// 近くの場合その場に待機
|
||||||
// まだ遠い場合待機場所に移動
|
// まだ遠い場合待機場所に移動
|
||||||
moves.Clear();
|
ForceSetMove(CustomerMovingType.WalkBackHalf);
|
||||||
if (currentMovingType == CustomerMovingType.StayBack)
|
|
||||||
{
|
|
||||||
SetMove(CustomerMovingType.WalkBackHalf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetMove(CustomerMovingType.WalkCenter);
|
|
||||||
AddMove(CustomerMovingType.WalkBackHalf);
|
|
||||||
}
|
|
||||||
AddMove(CustomerMovingType.StayBack);
|
AddMove(CustomerMovingType.StayBack);
|
||||||
break;
|
break;
|
||||||
case CustomerState.Order:
|
case CustomerState.Order:
|
||||||
|
|
@ -149,8 +155,7 @@ public class CustomerController : MonoBehaviour
|
||||||
AddMove(CustomerMovingType.StayBackOrder);
|
AddMove(CustomerMovingType.StayBackOrder);
|
||||||
break;
|
break;
|
||||||
case CustomerState.Leave:
|
case CustomerState.Leave:
|
||||||
moves.Clear();
|
ForceSetMove(CustomerMovingType.WalkSide);
|
||||||
SetMove(CustomerMovingType.WalkSide);
|
|
||||||
break;
|
break;
|
||||||
case CustomerState.EatingLeave:
|
case CustomerState.EatingLeave:
|
||||||
AddMove(CustomerMovingType.WalkFrontEat);
|
AddMove(CustomerMovingType.WalkFrontEat);
|
||||||
|
|
@ -166,6 +171,13 @@ public class CustomerController : MonoBehaviour
|
||||||
moves.Add((type, duration));
|
moves.Add((type, duration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ForceSetMove(CustomerMovingType type, float duration = 0f)
|
||||||
|
{
|
||||||
|
moves.Clear();
|
||||||
|
isMoveOverride = true;
|
||||||
|
SetMove(type, duration);
|
||||||
|
}
|
||||||
|
|
||||||
// キャラの奥行き描画順のため、y方向に対応したz軸を設定
|
// キャラの奥行き描画順のため、y方向に対応したz軸を設定
|
||||||
private void SetMove(CustomerMovingType type, float duration = 0f)
|
private void SetMove(CustomerMovingType type, float duration = 0f)
|
||||||
{
|
{
|
||||||
|
|
@ -174,10 +186,11 @@ public class CustomerController : MonoBehaviour
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
completedDuration = duration;
|
completedDuration = duration;
|
||||||
|
durationDelta = 0f;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case CustomerMovingType.WalkSide:
|
case CustomerMovingType.WalkSide:
|
||||||
SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, wayPoint.y));
|
SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, transform.localPosition.y));
|
||||||
speed = walkSideSpeed;
|
speed = walkSideSpeed;
|
||||||
// アニメーション違和感回避
|
// アニメーション違和感回避
|
||||||
if (currentMovingType == CustomerMovingType.WalkCenter)
|
if (currentMovingType == CustomerMovingType.WalkCenter)
|
||||||
|
|
@ -187,13 +200,11 @@ public class CustomerController : MonoBehaviour
|
||||||
animator.SetTrigger(WalkSide);
|
animator.SetTrigger(WalkSide);
|
||||||
break;
|
break;
|
||||||
case CustomerMovingType.WalkSideEat:
|
case CustomerMovingType.WalkSideEat:
|
||||||
SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, wayPoint.y));
|
SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, transform.localPosition.y));
|
||||||
speed = walkSideSpeed;
|
speed = walkSideSpeed;
|
||||||
animator.SetTrigger(WalkSideEat);
|
animator.SetTrigger(WalkSideEat);
|
||||||
break;
|
break;
|
||||||
case CustomerMovingType.WalkCenter:
|
case CustomerMovingType.WalkCenter:
|
||||||
// 通り過ぎた人はwalkSideDirection基準にするとあるき過ぎるので改善したい
|
|
||||||
// 立ち止まったあと戻ってしまう場合があるので、中央付近だと戻りがないようにする
|
|
||||||
if (Mathf.Abs(transform.localPosition.x - stopPosision) <= stopPositionRange)
|
if (Mathf.Abs(transform.localPosition.x - stopPosision) <= stopPositionRange)
|
||||||
{
|
{
|
||||||
SetWayPoint(new Vector3(transform.localPosition.x, beginPos.y));
|
SetWayPoint(new Vector3(transform.localPosition.x, beginPos.y));
|
||||||
|
|
@ -220,18 +231,25 @@ public class CustomerController : MonoBehaviour
|
||||||
animator.SetTrigger(StayBack);
|
animator.SetTrigger(StayBack);
|
||||||
break;
|
break;
|
||||||
case CustomerMovingType.WalkBack:
|
case CustomerMovingType.WalkBack:
|
||||||
|
// 購入場所に行く
|
||||||
SetWayPoint(new Vector3(Random.value * orderPositionRange * walkSideDirection, orderPosision));
|
SetWayPoint(new Vector3(Random.value * orderPositionRange * walkSideDirection, orderPosision));
|
||||||
speed = walkFrontBackSpeed;
|
speed = walkFrontBackSpeed;
|
||||||
animator.SetTrigger(WalkBack);
|
animator.SetTrigger(WalkBack);
|
||||||
break;
|
break;
|
||||||
case CustomerMovingType.WalkBackHalf:
|
case CustomerMovingType.WalkBackHalf:
|
||||||
// 待機列に入る
|
// 待機列に入る
|
||||||
SetWayPoint(new Vector3(wayPoint.x, waitOrderPosision));
|
if (Mathf.Abs(transform.localPosition.x - stopPosision) <= stopPositionRange)
|
||||||
|
{
|
||||||
|
SetWayPoint(new Vector3(transform.localPosition.x, waitOrderPosision));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetWayPoint(new Vector3(stopPosision - Random.value * stopPositionRange * walkSideDirection, waitOrderPosision));
|
||||||
|
}
|
||||||
speed = walkFrontBackSpeed;
|
speed = walkFrontBackSpeed;
|
||||||
animator.SetTrigger(WalkBack);
|
animator.SetTrigger(WalkBack);
|
||||||
break;
|
break;
|
||||||
case CustomerMovingType.WalkFront:
|
case CustomerMovingType.WalkFront:
|
||||||
// 購入場所に行く
|
|
||||||
SetWayPoint(new Vector3(wayPoint.x, Random.Range(walkSideLeavePos, walkSideTopPosition)));
|
SetWayPoint(new Vector3(wayPoint.x, Random.Range(walkSideLeavePos, walkSideTopPosition)));
|
||||||
speed = walkFrontBackSpeed;
|
speed = walkFrontBackSpeed;
|
||||||
animator.SetTrigger(WalkFront);
|
animator.SetTrigger(WalkFront);
|
||||||
|
|
@ -250,8 +268,14 @@ public class CustomerController : MonoBehaviour
|
||||||
private void SetWayPoint(Vector3 point)
|
private void SetWayPoint(Vector3 point)
|
||||||
{
|
{
|
||||||
wayPoint = point;
|
wayPoint = point;
|
||||||
wayPoint.z = wayPoint.y + Mathf.Abs(walkSideBottomPos);
|
if ((wayPoint - transform.localPosition).x >= 0)
|
||||||
transform.localRotation = Quaternion.Euler((wayPoint - transform.localPosition).x >= 0 ? Vector3.zero : Vector3.up * 180);
|
{
|
||||||
|
customerDirection.SetDefaultSide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
customerDirection.SetFlipSide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowWantFlavor(int flavor)
|
public void ShowWantFlavor(int flavor)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class CustomerDirection : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private List<Transform> bodySides = new List<Transform>();
|
||||||
|
|
||||||
|
public void SetDefaultSide()
|
||||||
|
{
|
||||||
|
foreach (var bodySide in bodySides)
|
||||||
|
{
|
||||||
|
bodySide.localRotation = Quaternion.Euler(Vector3.zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFlipSide()
|
||||||
|
{
|
||||||
|
foreach (var bodySide in bodySides)
|
||||||
|
{
|
||||||
|
bodySide.localRotation = Quaternion.Euler(Vector3.up * 180);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0eb44b30c9454383898faae0c3666b94
|
||||||
|
timeCreated: 1631070899
|
||||||
|
|
@ -5,10 +5,16 @@ public class HeartAnimation : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private GameObject bigHeart;
|
[SerializeField] private GameObject bigHeart;
|
||||||
[SerializeField] private GameObject smallHeart;
|
[SerializeField] private GameObject smallHeart;
|
||||||
[SerializeField] private Transform target;
|
private Transform target;
|
||||||
private float animationDelay = .3f;
|
private float animationDelay = .3f;
|
||||||
private float animationDuration = .5f;
|
private float animationDuration = .5f;
|
||||||
private float heartToMeterDuration = .4f;
|
private float heartToMeterDuration = .4f;
|
||||||
|
|
||||||
|
public void SetTarget(Transform transform)
|
||||||
|
{
|
||||||
|
target = transform;
|
||||||
|
}
|
||||||
|
|
||||||
public void GetHeart(Action callback = null)
|
public void GetHeart(Action callback = null)
|
||||||
{
|
{
|
||||||
smallHeart.SetActive(false);
|
smallHeart.SetActive(false);
|
||||||
|
|
|
||||||
|
|
@ -115,37 +115,30 @@ public class Market : MonoBehaviour
|
||||||
.Select(x => x.Value)
|
.Select(x => x.Value)
|
||||||
.Subscribe(customerController =>
|
.Subscribe(customerController =>
|
||||||
{
|
{
|
||||||
customerController.State.Subscribe(c =>
|
customerController.State
|
||||||
{
|
.Where(x => x == CustomerState.EatingLeave)
|
||||||
if (c == CustomerState.EatingLeave)
|
.Subscribe(c =>
|
||||||
{
|
{
|
||||||
Debug.Log($"aa order:{customerList.Count(x => x.State.Value == CustomerState.Order)} EatingLeave");
|
Debug.Log($"aa order:{customerList.Count(x => x.State.Value == CustomerState.Order)} EatingLeave");
|
||||||
orderSubject.OnNext(default);
|
orderSubject.OnNext(default);
|
||||||
}
|
|
||||||
}).AddTo(customerController);
|
}).AddTo(customerController);
|
||||||
|
if (shopState.Value == ShopState.Close)
|
||||||
|
{
|
||||||
|
customerController.ChangeCustomerState(CustomerState.Leave);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 店に向かう
|
// 店に向かう
|
||||||
customerController.ChangeCustomerState(CustomerState.Wait);
|
customerController.ChangeCustomerState(CustomerState.Wait);
|
||||||
shopState.Subscribe(x =>
|
shopState
|
||||||
|
.Where(x => x == ShopState.Close)
|
||||||
|
.Subscribe(x =>
|
||||||
{
|
{
|
||||||
switch (x)
|
|
||||||
{
|
|
||||||
case ShopState.Open:
|
|
||||||
case ShopState.Busy:
|
|
||||||
break;
|
|
||||||
case ShopState.Close:
|
|
||||||
// 売り切れの場合帰る
|
// 売り切れの場合帰る
|
||||||
if (customerController.State.Value == CustomerState.Order)
|
if (customerController.State.Value == CustomerState.Order)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.CallWaitForSeconds(Random.Range(0f, .4f), () =>
|
|
||||||
{
|
|
||||||
customerController.ChangeCustomerState(CustomerState.Leave);
|
customerController.ChangeCustomerState(CustomerState.Leave);
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(x), x, null);
|
|
||||||
}
|
|
||||||
}).AddTo(customerController);
|
}).AddTo(customerController);
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
|
||||||
|
|
@ -246,6 +239,7 @@ public class Market : MonoBehaviour
|
||||||
{
|
{
|
||||||
customerController.HideOrderPopup();
|
customerController.HideOrderPopup();
|
||||||
var heartAnimation = customerController.GetComponent<HeartAnimation>();
|
var heartAnimation = customerController.GetComponent<HeartAnimation>();
|
||||||
|
heartAnimation.SetTarget(HeartMeter.Instance.transform);
|
||||||
heartAnimation.GetHeart(() =>
|
heartAnimation.GetHeart(() =>
|
||||||
{
|
{
|
||||||
HeartMeter.Instance.AddHeart(1);
|
HeartMeter.Instance.AddHeart(1);
|
||||||
|
|
@ -355,6 +349,16 @@ public class Market : MonoBehaviour
|
||||||
customerList.Remove(customerController);
|
customerList.Remove(customerController);
|
||||||
Destroy(customer);
|
Destroy(customer);
|
||||||
break;
|
break;
|
||||||
|
case CustomerMovingType.WalkCenter:
|
||||||
|
if (shopState.Value == ShopState.Close)
|
||||||
|
{
|
||||||
|
customerController.ChangeCustomerState(CustomerState.Leave);
|
||||||
|
}
|
||||||
|
if (customerController.State.Value == CustomerState.WalkShop)
|
||||||
|
{
|
||||||
|
customerList.Add(customerController);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CustomerMovingType.WalkBackHalf:
|
case CustomerMovingType.WalkBackHalf:
|
||||||
waitCustomerList.Add(customerController);
|
waitCustomerList.Add(customerController);
|
||||||
break;
|
break;
|
||||||
|
|
@ -367,20 +371,27 @@ public class Market : MonoBehaviour
|
||||||
}).AddTo(customerController);
|
}).AddTo(customerController);
|
||||||
|
|
||||||
var customerObject = customer.transform.GetChild(0).gameObject;
|
var customerObject = customer.transform.GetChild(0).gameObject;
|
||||||
|
var eventTrigger = customerObject.AddComponent<ObservableEventTrigger>();
|
||||||
if (x.isCustomer)
|
if (x.isCustomer)
|
||||||
{
|
{
|
||||||
// 購入客リスト追加
|
// 近くまで歩く(タップされたらcustomerList.Add()
|
||||||
|
customerController.ChangeCustomerState(CustomerState.WalkShop);
|
||||||
|
eventTrigger.OnPointerClickAsObservable()
|
||||||
|
.TakeUntil(customerController.MoveEndObservable.Where(type => type == CustomerMovingType.WalkCenter))
|
||||||
|
.Take(1)
|
||||||
|
.Subscribe(_ =>
|
||||||
|
{
|
||||||
customerList.Add(customerController);
|
customerList.Add(customerController);
|
||||||
if (customerObject.TryGetComponent(typeof(Collider2D), out var target))
|
if (customerObject.TryGetComponent(typeof(Collider2D), out var target))
|
||||||
{
|
{
|
||||||
Destroy(target);
|
Destroy(target);
|
||||||
}
|
}
|
||||||
|
}).AddTo(customerController);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 歩行者はタップ後購入客
|
// 歩行者はタップ後customerList.Add()
|
||||||
customerController.ChangeCustomerState(CustomerState.Walk);
|
customerController.ChangeCustomerState(CustomerState.Walk);
|
||||||
var eventTrigger = customerObject.AddComponent<ObservableEventTrigger>();
|
|
||||||
eventTrigger.OnPointerClickAsObservable().Take(1).Subscribe(_ =>
|
eventTrigger.OnPointerClickAsObservable().Take(1).Subscribe(_ =>
|
||||||
{
|
{
|
||||||
customerList.Add(customerController);
|
customerList.Add(customerController);
|
||||||
|
|
@ -421,24 +432,6 @@ public class Market : MonoBehaviour
|
||||||
.OrderBy(_ => Random.value).ToList();
|
.OrderBy(_ => Random.value).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefillOneProduct()
|
|
||||||
{
|
|
||||||
foreach (var tank in GameDataManager.GameData.StorageTanks)
|
|
||||||
{
|
|
||||||
if (tank.Stock == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (GameDataManager.GameData.ShopStock.Count == ShopStockCount)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
GameDataManager.GameData.ShopStock.Add(tank.FlavorId);
|
|
||||||
tank.Stock--;
|
|
||||||
}
|
|
||||||
GameDataManager.SaveGameData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RefillProduct()
|
private void RefillProduct()
|
||||||
{
|
{
|
||||||
// 手前のタンクから出し多分stockをへらす
|
// 手前のタンクから出し多分stockをへらす
|
||||||
|
|
@ -487,10 +480,4 @@ public class Market : MonoBehaviour
|
||||||
}
|
}
|
||||||
Debug.Log(shopStockString);
|
Debug.Log(shopStockString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue