Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop

This commit is contained in:
koya_15 2021-09-08 12:43:28 +09:00
commit 59fcc652d7
7 changed files with 201 additions and 96 deletions

View File

@ -5301,6 +5301,7 @@ GameObject:
m_Component:
- component: {fileID: 4886416728471897984}
- component: {fileID: 4886416728471897985}
- component: {fileID: 5450916343452979085}
m_Layer: 0
m_Name: customer_normal
m_TagString: Untagged
@ -5346,6 +5347,21 @@ Animator:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
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
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,5 +1,16 @@
%YAML 1.1
%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
GameObject:
m_ObjectHideFlags: 0
@ -46,6 +57,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
animator: {fileID: 5409985851491668857}
customerDirection: {fileID: 4855338754077236085}
orderPopup: {fileID: 5409985850085678672}
leftPopcorn: {fileID: 1950136324582499262}
rightPopcorn: {fileID: 1950136324150437342}
@ -79,7 +91,17 @@ MonoBehaviour:
m_EditorClassIdentifier:
bigHeart: {fileID: 7988005957398545984}
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
BoxCollider2D:
m_ObjectHideFlags: 0
@ -106,17 +128,6 @@ BoxCollider2D:
serializedVersion: 2
m_Size: {x: 2, y: 2}
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
PrefabInstance:
m_ObjectHideFlags: 0
@ -204,6 +215,16 @@ PrefabInstance:
propertyPath: m_IsActive
value: 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,
type: 3}
propertyPath: m_IsActive
@ -234,12 +255,36 @@ Animator:
type: 3}
m_PrefabInstance: {fileID: 631677504613307640}
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
SpriteRenderer:
m_CorrespondingSourceObject: {fileID: 1428887861354145305, guid: db654393793a67d45a7d0b70a68b73a6,
type: 3}
m_PrefabInstance: {fileID: 631677504613307640}
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
SpriteRenderer:
m_CorrespondingSourceObject: {fileID: 1428887861146841382, guid: db654393793a67d45a7d0b70a68b73a6,

View File

@ -21,6 +21,7 @@ public enum CustomerMovingType
public enum CustomerState
{
Walk,
WalkShop,
Wait,
Order,
Leave,
@ -37,6 +38,7 @@ public class CustomerController : MonoBehaviour
private static readonly int WalkSideEat = Animator.StringToHash("WalkSideEat");
[SerializeField] private Animator animator;
[SerializeField] private CustomerDirection customerDirection;
[SerializeField] private GameObject orderPopup;
[SerializeField] private SpriteRenderer leftPopcorn;
@ -67,6 +69,7 @@ public class CustomerController : MonoBehaviour
private Vector3 beginPos;
private Vector3 wayPoint;
private CustomerMovingType currentMovingType;
private bool isMoveOverride;
private List<(CustomerMovingType type, float duration)> moves = new List<(CustomerMovingType, float)>();
private float speed = 0f;
private float completedDuration;
@ -84,16 +87,23 @@ public class CustomerController : MonoBehaviour
durationDelta = 0f;
this.UpdateAsObservable().Subscribe(_ =>
{
transform.localPosition = Vector3.MoveTowards(transform.localPosition, wayPoint, speed * Time.deltaTime);
if (Vector3.Distance(transform.localPosition, wayPoint) < .01f)
var localPosition = transform.localPosition;
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)
{
durationDelta += Time.deltaTime;
return;
}
durationDelta = 0f;
moveEndSubject.Value = currentMovingType;
if (isMoveOverride)
{
isMoveOverride = false;
return;
}
if (moves.Count > 0)
{
var move = moves[0];
@ -111,7 +121,9 @@ public class CustomerController : MonoBehaviour
beginPos.x = leftEndPosision * walkSideDirection;
beginPos.y = Random.Range(walkSideMidPos, walkSideBottomPos);
transform.localPosition = beginPos;
currentMovingType = CustomerMovingType.StayBackOrder;
currentMovingType = CustomerMovingType.StayBack;
moveEndSubject.Value = CustomerMovingType.StayBack;
isMoveOverride = false;
SetWayPoint(beginPos);
}
@ -122,25 +134,19 @@ public class CustomerController : MonoBehaviour
switch (state)
{
case CustomerState.Walk:
SetMove(CustomerMovingType.WalkCenter);
ForceSetMove(CustomerMovingType.WalkCenter);
// 数秒立ち止まる
AddMove(CustomerMovingType.StayBack, 2f);
AddMove(CustomerMovingType.WalkSide);
break;
case CustomerState.WalkShop:
ForceSetMove(CustomerMovingType.WalkCenter);
break;
case CustomerState.Wait:
// 店に向かう&順番待ち
// 近くの場合その場に待機
// まだ遠い場合待機場所に移動
moves.Clear();
if (currentMovingType == CustomerMovingType.StayBack)
{
SetMove(CustomerMovingType.WalkBackHalf);
}
else
{
SetMove(CustomerMovingType.WalkCenter);
AddMove(CustomerMovingType.WalkBackHalf);
}
ForceSetMove(CustomerMovingType.WalkBackHalf);
AddMove(CustomerMovingType.StayBack);
break;
case CustomerState.Order:
@ -149,8 +155,7 @@ public class CustomerController : MonoBehaviour
AddMove(CustomerMovingType.StayBackOrder);
break;
case CustomerState.Leave:
moves.Clear();
SetMove(CustomerMovingType.WalkSide);
ForceSetMove(CustomerMovingType.WalkSide);
break;
case CustomerState.EatingLeave:
AddMove(CustomerMovingType.WalkFrontEat);
@ -166,6 +171,13 @@ public class CustomerController : MonoBehaviour
moves.Add((type, duration));
}
private void ForceSetMove(CustomerMovingType type, float duration = 0f)
{
moves.Clear();
isMoveOverride = true;
SetMove(type, duration);
}
// キャラの奥行き描画順のため、y方向に対応したz軸を設定
private void SetMove(CustomerMovingType type, float duration = 0f)
{
@ -174,10 +186,11 @@ public class CustomerController : MonoBehaviour
return;
}
completedDuration = duration;
durationDelta = 0f;
switch (type)
{
case CustomerMovingType.WalkSide:
SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, wayPoint.y));
SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, transform.localPosition.y));
speed = walkSideSpeed;
// アニメーション違和感回避
if (currentMovingType == CustomerMovingType.WalkCenter)
@ -187,13 +200,11 @@ public class CustomerController : MonoBehaviour
animator.SetTrigger(WalkSide);
break;
case CustomerMovingType.WalkSideEat:
SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, wayPoint.y));
SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, transform.localPosition.y));
speed = walkSideSpeed;
animator.SetTrigger(WalkSideEat);
break;
case CustomerMovingType.WalkCenter:
// 通り過ぎた人はwalkSideDirection基準にするとあるき過ぎるので改善したい
// 立ち止まったあと戻ってしまう場合があるので、中央付近だと戻りがないようにする
if (Mathf.Abs(transform.localPosition.x - stopPosision) <= stopPositionRange)
{
SetWayPoint(new Vector3(transform.localPosition.x, beginPos.y));
@ -220,18 +231,25 @@ public class CustomerController : MonoBehaviour
animator.SetTrigger(StayBack);
break;
case CustomerMovingType.WalkBack:
// 購入場所に行く
SetWayPoint(new Vector3(Random.value * orderPositionRange * walkSideDirection, orderPosision));
speed = walkFrontBackSpeed;
animator.SetTrigger(WalkBack);
break;
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;
animator.SetTrigger(WalkBack);
break;
case CustomerMovingType.WalkFront:
// 購入場所に行く
SetWayPoint(new Vector3(wayPoint.x, Random.Range(walkSideLeavePos, walkSideTopPosition)));
speed = walkFrontBackSpeed;
animator.SetTrigger(WalkFront);
@ -250,8 +268,14 @@ public class CustomerController : MonoBehaviour
private void SetWayPoint(Vector3 point)
{
wayPoint = point;
wayPoint.z = wayPoint.y + Mathf.Abs(walkSideBottomPos);
transform.localRotation = Quaternion.Euler((wayPoint - transform.localPosition).x >= 0 ? Vector3.zero : Vector3.up * 180);
if ((wayPoint - transform.localPosition).x >= 0)
{
customerDirection.SetDefaultSide();
}
else
{
customerDirection.SetFlipSide();
}
}
public void ShowWantFlavor(int flavor)

View File

@ -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);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0eb44b30c9454383898faae0c3666b94
timeCreated: 1631070899

View File

@ -5,10 +5,16 @@ public class HeartAnimation : MonoBehaviour
{
[SerializeField] private GameObject bigHeart;
[SerializeField] private GameObject smallHeart;
[SerializeField] private Transform target;
private Transform target;
private float animationDelay = .3f;
private float animationDuration = .5f;
private float heartToMeterDuration = .4f;
public void SetTarget(Transform transform)
{
target = transform;
}
public void GetHeart(Action callback = null)
{
smallHeart.SetActive(false);

View File

@ -115,38 +115,31 @@ public class Market : MonoBehaviour
.Select(x => x.Value)
.Subscribe(customerController =>
{
customerController.State.Subscribe(c =>
{
if (c == CustomerState.EatingLeave)
customerController.State
.Where(x => x == CustomerState.EatingLeave)
.Subscribe(c =>
{
Debug.Log($"aa order:{customerList.Count(x => x.State.Value == CustomerState.Order)} EatingLeave");
orderSubject.OnNext(default);
}
}).AddTo(customerController);
}).AddTo(customerController);
if (shopState.Value == ShopState.Close)
{
customerController.ChangeCustomerState(CustomerState.Leave);
return;
}
// 店に向かう
customerController.ChangeCustomerState(CustomerState.Wait);
shopState.Subscribe(x =>
{
switch (x)
shopState
.Where(x => x == ShopState.Close)
.Subscribe(x =>
{
case ShopState.Open:
case ShopState.Busy:
break;
case ShopState.Close:
// 売り切れの場合帰る
if (customerController.State.Value == CustomerState.Order)
{
return;
}
this.CallWaitForSeconds(Random.Range(0f, .4f), () =>
{
customerController.ChangeCustomerState(CustomerState.Leave);
});
break;
default:
throw new ArgumentOutOfRangeException(nameof(x), x, null);
}
}).AddTo(customerController);
// 売り切れの場合帰る
if (customerController.State.Value == CustomerState.Order)
{
return;
}
customerController.ChangeCustomerState(CustomerState.Leave);
}).AddTo(customerController);
}).AddTo(this);
requestSubject.BatchFrame().Subscribe(customers =>
@ -246,6 +239,7 @@ public class Market : MonoBehaviour
{
customerController.HideOrderPopup();
var heartAnimation = customerController.GetComponent<HeartAnimation>();
heartAnimation.SetTarget(HeartMeter.Instance.transform);
heartAnimation.GetHeart(() =>
{
HeartMeter.Instance.AddHeart(1);
@ -355,6 +349,16 @@ public class Market : MonoBehaviour
customerList.Remove(customerController);
Destroy(customer);
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:
waitCustomerList.Add(customerController);
break;
@ -367,20 +371,27 @@ public class Market : MonoBehaviour
}).AddTo(customerController);
var customerObject = customer.transform.GetChild(0).gameObject;
var eventTrigger = customerObject.AddComponent<ObservableEventTrigger>();
if (x.isCustomer)
{
// 購入客リスト追加
customerList.Add(customerController);
if (customerObject.TryGetComponent(typeof(Collider2D), out var target))
{
Destroy(target);
}
// 近くまで歩く(タップされたらcustomerList.Add()
customerController.ChangeCustomerState(CustomerState.WalkShop);
eventTrigger.OnPointerClickAsObservable()
.TakeUntil(customerController.MoveEndObservable.Where(type => type == CustomerMovingType.WalkCenter))
.Take(1)
.Subscribe(_ =>
{
customerList.Add(customerController);
if (customerObject.TryGetComponent(typeof(Collider2D), out var target))
{
Destroy(target);
}
}).AddTo(customerController);
}
else
{
// 歩行者はタップ後購入客
// 歩行者はタップ後customerList.Add()
customerController.ChangeCustomerState(CustomerState.Walk);
var eventTrigger = customerObject.AddComponent<ObservableEventTrigger>();
eventTrigger.OnPointerClickAsObservable().Take(1).Subscribe(_ =>
{
customerList.Add(customerController);
@ -421,24 +432,6 @@ public class Market : MonoBehaviour
.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()
{
// 手前のタンクから出し多分stockをへらす
@ -487,10 +480,4 @@ public class Market : MonoBehaviour
}
Debug.Log(shopStockString);
}
// Update is called once per frame
void Update()
{
}
}