diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs index c0f99ead..7f84349a 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs @@ -8,19 +8,19 @@ using UnityEngine; public class Market : MonoBehaviour { public static readonly int ShopStockCount = 21; + + [SerializeField] private ShopStockView stockView; // Start is called before the first frame update void Start() { var gameData = GameDataManager.GameData; CoinManager.Instance.ChangeCoin(gameData.coin); // 在庫数表示 - var totalCapacity = gameData.StorageTanks.Sum(x => x.Capacity); - var totalStock = gameData.StorageTanks.Sum(x => x.Stock); + stockView.SetStock(gameData.StorageTanks); // 全レシピ var allRecipe = RecipeData.GetAllRecipe(); - - Debug.Log($"Tank:{totalStock}/{totalCapacity}"); + StockFlavorLog(); // お客さんの出現タイミング(10秒間に1回) @@ -43,6 +43,7 @@ public class Market : MonoBehaviour GameDataManager.SaveGameData(); // 自動補充 refill RefillProduct(); + stockView.SetStock(gameData.StorageTanks); StockFlavorLog(); }).AddTo(this); } diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopStockView.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopStockView.cs new file mode 100644 index 00000000..fbabd628 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopStockView.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +public class ShopStockView : MonoBehaviour +{ + [SerializeField] private SpriteRenderer popcornImage; + [SerializeField] private float maxPosision = 0.16f; + [SerializeField] private float minPosision = -0.8f; + + public void SetStock(List tanks) + { + var totalCapacity = tanks.Sum(x => x.Capacity); + var totalStock = tanks.Sum(x => x.Stock); + Debug.Log($"Tank:{totalStock}/{totalCapacity}"); + var newPos = popcornImage.transform.localPosition; + newPos.y = Mathf.Lerp(minPosision, maxPosision, (float) totalStock / totalCapacity); + popcornImage.transform.localPosition = newPos; + } +} diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopStockView.cs.meta b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopStockView.cs.meta new file mode 100644 index 00000000..54299865 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopStockView.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 09160a6dafe240cba728f15df3973935 +timeCreated: 1628584292 \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/marketing/marketing.unity b/popcorn/Assets/MyGame/Scenes/marketing/marketing.unity index b2dceb5d..44497aeb 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/marketing.unity +++ b/popcorn/Assets/MyGame/Scenes/marketing/marketing.unity @@ -227,7 +227,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 53013340} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.0029997826, y: 0.49900007, z: 0} + m_LocalPosition: {x: 0.0029997826, y: 0.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 438315599} @@ -1026,6 +1026,7 @@ GameObject: m_Component: - component: {fileID: 438315599} - component: {fileID: 438315600} + - component: {fileID: 438315601} m_Layer: 0 m_Name: StockMeter m_TagString: Untagged @@ -1099,6 +1100,21 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!114 &438315601 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 438315598} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 09160a6dafe240cba728f15df3973935, type: 3} + m_Name: + m_EditorClassIdentifier: + popcornImage: {fileID: 53013342} + maxPosision: 0.5 + minPosision: -1.47 --- !u!1 &471454546 GameObject: m_ObjectHideFlags: 0 @@ -2304,6 +2320,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: cf4a253e4bfcb47f18e7d6f28af64b01, type: 3} m_Name: m_EditorClassIdentifier: + stockView: {fileID: 438315601} --- !u!1 &1035509476 GameObject: m_ObjectHideFlags: 0