diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/WorldMarketManager.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/WorldMarketManager.cs new file mode 100644 index 00000000..226163cb --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/WorldMarketManager.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniRx; +using UnityEngine; + +namespace MyGame.Scenes.marketing.Scripts +{ + /// + /// 各都市のバックグラウンドでの販売を制御 + /// + public class WorldMarketManager : SingletonMonoBehaviour + { + public static readonly int ShopStockCount = 20; + + [SerializeField] private Market marketPrefab; + public readonly ReactiveProperty IsPause = new(); + //cityIdごとにMarket保存 + private readonly Dictionary cityMarketDict = new(); + private void Start() + { + var market = Instantiate(marketPrefab, transform); + cityMarketDict.Add(Const.DefaultCityId, market); + } + + public Market GetMarket(int cityId) + { + return cityMarketDict[Const.DefaultCityId]; + } + + public Market GetCurrentCityMarket() + { + return cityMarketDict[Const.DefaultCityId]; + } + + /// + /// 全マーケットアップデート + /// + /// + public void UpdateBonus(Dictionary bonusList) + { + cityMarketDict[Const.DefaultCityId].UpdateBonus(bonusList); + } + + public void ResetGameData(GameData gameData) + { + cityMarketDict[Const.DefaultCityId].ResetGameData(gameData); + } + + public static void StockFlavorLog(int cityId = -1) + { + if (GameDataManager.GetCityGameData(cityId) is not {} cityGameData) + { + cityGameData = GameDataManager.GetCurrentCityGameData(); + } + + var shopStockString = ""; + shopStockString += $@"tank count:{cityGameData.StorageTanks.Count} +tank {cityGameData.StorageTanks.Aggregate("", (s, tank) => $"{s}, flavor:{tank.FlavorId}({tank.Stock})")} +"; + foreach (var data in SpreadsheetDataManager.Instance.GetBaseDataList(Const.ProductDataSheet)) + { + var shopStockCount = cityGameData.ShopStock.FindAll(x => x.FlavorId == data.id).Count; + var tank = cityGameData.StorageTanks.FindAll(x => x.FlavorId == data.id).Sum(x => x.Stock); + if (shopStockCount + tank == 0) + { + continue; + } + shopStockString += $"{data.Name} shop:{shopStockCount} tank:{tank}\n"; + } + Debug.Log(shopStockString); + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/WorldMarketManager.cs.meta b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/WorldMarketManager.cs.meta new file mode 100644 index 00000000..89f11104 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/WorldMarketManager.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 314dd9be490e4a168cc6b93170088eeb +timeCreated: 1664507764 \ No newline at end of file