データ構造変更
This commit is contained in:
parent
c6e73b0975
commit
33924293b7
|
|
@ -65,7 +65,7 @@ public class DebugOptionManager : MonoBehaviour
|
|||
gameData.ShopStock = Enumerable.Repeat(1, 10).ToList();
|
||||
gameData.ShopStock.AddRange(Enumerable.Repeat(2, 10).ToList());
|
||||
gameData.StorageTanks[0].FlavorId = 2;
|
||||
gameData.StorageTanks[0].Stock = 50;
|
||||
gameData.StorageTanks[0].AddStock(ProductRarity.Normal, 50);
|
||||
}).AddTo(this);
|
||||
|
||||
refillLittleProductButton.OnClickAsObservable().Subscribe(_ =>
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ public class KitchenManager : MonoBehaviour
|
|||
Capacity = 50,
|
||||
FlavorId = -1,
|
||||
Stock = 0,
|
||||
BonusRate = 0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine.Internal.VR;
|
||||
|
||||
public class StorageTank
|
||||
|
|
@ -6,6 +8,33 @@ public class StorageTank
|
|||
public int Id;
|
||||
public int Capacity;
|
||||
public int FlavorId;
|
||||
public int Stock
|
||||
{
|
||||
get => Stocks.Sum(x => x.Stock);
|
||||
set => SetStock(ProductRarity.Normal, value);
|
||||
}
|
||||
public List<ProductStockData> Stocks = new List<ProductStockData>();
|
||||
|
||||
public void SetStock(ProductRarity rarity, int stock)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void AddStock(ProductRarity rarity, int stock)
|
||||
{
|
||||
var stockData = Stocks.First(x => x.Rarity == rarity);
|
||||
if (stockData is null)
|
||||
{
|
||||
Stocks.Add(new ProductStockData{FlavorId = FlavorId, Rarity = rarity, Stock = stock});
|
||||
return;
|
||||
}
|
||||
stockData.Stock += stock;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProductStockData
|
||||
{
|
||||
public int FlavorId;
|
||||
public ProductRarity Rarity;
|
||||
public int Stock;
|
||||
public int BonusRate;
|
||||
}
|
||||
Loading…
Reference in New Issue