お客さんの吹き出しに買う個数を表示

This commit is contained in:
kimura 2021-11-22 14:30:05 +09:00
parent 2f986d19b5
commit 9504909bcc
3 changed files with 18 additions and 6 deletions

View File

@ -5624,6 +5624,7 @@ MonoBehaviour:
rightPopcornTarget: {fileID: 8759972247495498057}
frontPopcornTarget: {fileID: 2262857044639259982}
wantFlavorSpriteTarget: {fileID: 4886416730275037410}
wantFlavorAmountText: {fileID: 364609804150918069}
--- !u!114 &7213583640106143312
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -1,9 +1,12 @@
using System;
using TMPro;
using UniRx;
using UnityEngine;
public class CustomerAnimator : MonoBehaviour
{
public static readonly string WantFlavorAmountFormat = "x{0}";
public static readonly int WalkFront = Animator.StringToHash("WalkFront");
public static readonly int WalkSide = Animator.StringToHash("WalkSide");
public static readonly int WalkBack = Animator.StringToHash("WalkBack");
@ -22,6 +25,7 @@ public class CustomerAnimator : MonoBehaviour
[SerializeField] private Transform rightPopcornTarget;
[SerializeField] private Transform frontPopcornTarget;
[SerializeField] private Transform wantFlavorSpriteTarget;
[SerializeField] private TextMeshPro wantFlavorAmountText;
private readonly ReactiveProperty<int> triggerName = new ReactiveProperty<int>();
@ -83,7 +87,7 @@ public class CustomerAnimator : MonoBehaviour
}
}
public void SetWantFlavor(MarketPopcornView prefab, ProductRarity rarity)
public void SetWantFlavor(MarketPopcornView prefab, ProductRarity rarity, int amount)
{
leftPopcornTarget.DestroyAllChildrens();
rightPopcornTarget.DestroyAllChildrens();
@ -93,6 +97,8 @@ public class CustomerAnimator : MonoBehaviour
Instantiate(prefab, rightPopcornTarget).ChangeRarity(rarity);
Instantiate(prefab, frontPopcornTarget).ChangeRarity(rarity);
Instantiate(prefab, wantFlavorSpriteTarget).ChangeRarity(rarity);
wantFlavorAmountText.text = String.Format(WantFlavorAmountFormat, amount);
}
public void ShowWantFlavor()

View File

@ -302,17 +302,22 @@ public class MarketManager : MonoBehaviour
customerAnimator.SetSide(x);
}).AddTo(customerAnimator);
// フレーバー設定
if (productDataList.FirstOrDefault(data => data.id == (controller.WantFlavor.Value?.FlavorId ?? -1))?.GetMarketPrefab() is MarketPopcornView initialPrefab)
controller.WantFlavor
.FirstOrDefault()
.Subscribe(wantData =>
{
customerAnimator.SetWantFlavor(initialPrefab, controller.WantFlavor.Value.Rarity);
if (productDataList.FirstOrDefault(data => data.id == wantData?.FlavorId)?.GetMarketPrefab() is MarketPopcornView prefab)
{
customerAnimator.SetWantFlavor(prefab, wantData.Rarity, controller.OrderCount);
}
}).AddTo(customerAnimator);
controller.WantFlavor
.SkipLatestValueOnSubscribe()
.Subscribe(wantData =>
{
if (productDataList.FirstOrDefault(data => data.id == wantData.FlavorId)?.GetMarketPrefab() is MarketPopcornView prefab)
{
customerAnimator.SetWantFlavor(prefab, wantData.Rarity);
customerAnimator.SetWantFlavor(prefab, wantData.Rarity, controller.OrderCount);
customerAnimator.ShowWantFlavor();
}
}).AddTo(customerAnimator);