add WorldMarketManager.cs
This commit is contained in:
parent
ab19a2a70c
commit
25fc181b44
|
|
@ -0,0 +1,74 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UniRx;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace MyGame.Scenes.marketing.Scripts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 各都市のバックグラウンドでの販売を制御
|
||||||
|
/// </summary>
|
||||||
|
public class WorldMarketManager : SingletonMonoBehaviour<WorldMarketManager>
|
||||||
|
{
|
||||||
|
public static readonly int ShopStockCount = 20;
|
||||||
|
|
||||||
|
[SerializeField] private Market marketPrefab;
|
||||||
|
public readonly ReactiveProperty<bool> IsPause = new();
|
||||||
|
//cityIdごとにMarket保存
|
||||||
|
private readonly Dictionary<int, Market> 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];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 全マーケットアップデート
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bonusList"></param>
|
||||||
|
public void UpdateBonus(Dictionary<ShopCustomizeBonusCategory, (int bonusLevel, int value)> 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<ProductData>(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 314dd9be490e4a168cc6b93170088eeb
|
||||||
|
timeCreated: 1664507764
|
||||||
Loading…
Reference in New Issue