店舗在庫表示対応
This commit is contained in:
parent
445c614dd6
commit
bcf1320e4b
|
|
@ -8,19 +8,19 @@ using UnityEngine;
|
||||||
public class Market : MonoBehaviour
|
public class Market : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static readonly int ShopStockCount = 21;
|
public static readonly int ShopStockCount = 21;
|
||||||
|
|
||||||
|
[SerializeField] private ShopStockView stockView;
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
var gameData = GameDataManager.GameData;
|
var gameData = GameDataManager.GameData;
|
||||||
CoinManager.Instance.ChangeCoin(gameData.coin);
|
CoinManager.Instance.ChangeCoin(gameData.coin);
|
||||||
// 在庫数表示
|
// 在庫数表示
|
||||||
var totalCapacity = gameData.StorageTanks.Sum(x => x.Capacity);
|
stockView.SetStock(gameData.StorageTanks);
|
||||||
var totalStock = gameData.StorageTanks.Sum(x => x.Stock);
|
|
||||||
|
|
||||||
// 全レシピ
|
// 全レシピ
|
||||||
var allRecipe = RecipeData.GetAllRecipe();
|
var allRecipe = RecipeData.GetAllRecipe();
|
||||||
|
|
||||||
Debug.Log($"Tank:{totalStock}/{totalCapacity}");
|
|
||||||
StockFlavorLog();
|
StockFlavorLog();
|
||||||
|
|
||||||
// お客さんの出現タイミング(10秒間に1回)
|
// お客さんの出現タイミング(10秒間に1回)
|
||||||
|
|
@ -43,6 +43,7 @@ public class Market : MonoBehaviour
|
||||||
GameDataManager.SaveGameData();
|
GameDataManager.SaveGameData();
|
||||||
// 自動補充 refill
|
// 自動補充 refill
|
||||||
RefillProduct();
|
RefillProduct();
|
||||||
|
stockView.SetStock(gameData.StorageTanks);
|
||||||
StockFlavorLog();
|
StockFlavorLog();
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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<StorageTank> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 09160a6dafe240cba728f15df3973935
|
||||||
|
timeCreated: 1628584292
|
||||||
|
|
@ -227,7 +227,7 @@ Transform:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 53013340}
|
m_GameObject: {fileID: 53013340}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
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_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 438315599}
|
m_Father: {fileID: 438315599}
|
||||||
|
|
@ -1026,6 +1026,7 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 438315599}
|
- component: {fileID: 438315599}
|
||||||
- component: {fileID: 438315600}
|
- component: {fileID: 438315600}
|
||||||
|
- component: {fileID: 438315601}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: StockMeter
|
m_Name: StockMeter
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -1099,6 +1100,21 @@ SpriteRenderer:
|
||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 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
|
--- !u!1 &471454546
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -2304,6 +2320,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: cf4a253e4bfcb47f18e7d6f28af64b01, type: 3}
|
m_Script: {fileID: 11500000, guid: cf4a253e4bfcb47f18e7d6f28af64b01, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
stockView: {fileID: 438315601}
|
||||||
--- !u!1 &1035509476
|
--- !u!1 &1035509476
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue