ワールド対応(ポップコーン在庫
This commit is contained in:
parent
10cb205ca5
commit
81dad01d08
|
|
@ -44,19 +44,21 @@ public class CookingResult : MonoBehaviour
|
||||||
var viewType = LocalCacheManager.Load(Const.ProductViewTypeTag, ProductViewType.Default);
|
var viewType = LocalCacheManager.Load(Const.ProductViewTypeTag, ProductViewType.Default);
|
||||||
var productData = LocalCacheManager.Load<ProductData>(PopcornGameManager.CookingDataTag);
|
var productData = LocalCacheManager.Load<ProductData>(PopcornGameManager.CookingDataTag);
|
||||||
var (rarityData, resultData, successAction) = LocalCacheManager.Load<(RarityData, CornResult, Action)>(PopcornGameManager.CookingResultDataTag);
|
var (rarityData, resultData, successAction) = LocalCacheManager.Load<(RarityData, CornResult, Action)>(PopcornGameManager.CookingResultDataTag);
|
||||||
|
var cityGameData = GameDataManager.GetCurrentCityGameData();
|
||||||
|
var globalGameData = GameDataManager.GameData;
|
||||||
result.Value = resultData;
|
result.Value = resultData;
|
||||||
SetData(productData, rarityData, viewType);
|
SetData(productData, rarityData, viewType);
|
||||||
|
|
||||||
// 材料消費&仮獲得
|
// 材料消費&仮獲得
|
||||||
RecipeDetailView.ConsumeMaterial(productData);
|
RecipeDetailView.ConsumeMaterial(productData, GameDataManager.GameData.CurrentCityId);
|
||||||
if (viewType == ProductViewType.Default)
|
if (viewType == ProductViewType.Default)
|
||||||
{
|
{
|
||||||
result.Subscribe(cornResult =>
|
result.Subscribe(cornResult =>
|
||||||
{
|
{
|
||||||
// 仮獲得データ登録
|
// 仮獲得データ登録
|
||||||
GameDataManager.GameData.WaitAddStock.FlavorId = productData.id;
|
cityGameData.WaitAddStock.FlavorId = productData.id;
|
||||||
GameDataManager.GameData.WaitAddStock.Stock = cornResult == CornResult.Failure ? 0 : productData.volume;
|
cityGameData.WaitAddStock.Stock = cornResult == CornResult.Failure ? 0 : productData.volume;
|
||||||
GameDataManager.GameData.WaitAddStock.Rarity = cornResult == CornResult.Perfect ? rarityData.Rarity : ProductRarity.Normal;
|
cityGameData.WaitAddStock.Rarity = cornResult == CornResult.Perfect ? rarityData.Rarity : ProductRarity.Normal;
|
||||||
GameDataManager.SaveGameData();
|
GameDataManager.SaveGameData();
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
}
|
}
|
||||||
|
|
@ -66,13 +68,13 @@ public class CookingResult : MonoBehaviour
|
||||||
var materialNumber = LocalCacheManager.Load<int>(BulkOrder.MaterialNumberTag);
|
var materialNumber = LocalCacheManager.Load<int>(BulkOrder.MaterialNumberTag);
|
||||||
result.Where(x => x != CornResult.Failure ).Subscribe(cornResult =>
|
result.Where(x => x != CornResult.Failure ).Subscribe(cornResult =>
|
||||||
{
|
{
|
||||||
if (!(GameDataManager.GameData.CompletedProductList.FirstOrDefault(data => data.Number == materialNumber) is BulkOrderResultData bulkOrderResultData))
|
if (!(cityGameData.CompletedProductList.FirstOrDefault(data => data.Number == materialNumber) is BulkOrderResultData bulkOrderResultData))
|
||||||
{
|
{
|
||||||
bulkOrderResultData = new BulkOrderResultData
|
bulkOrderResultData = new BulkOrderResultData
|
||||||
{
|
{
|
||||||
Number = materialNumber
|
Number = materialNumber
|
||||||
};
|
};
|
||||||
GameDataManager.GameData.CompletedProductList.Add(bulkOrderResultData);
|
cityGameData.CompletedProductList.Add(bulkOrderResultData);
|
||||||
}
|
}
|
||||||
// レア上書き
|
// レア上書き
|
||||||
bulkOrderResultData.Rarity = cornResult == CornResult.Perfect ? rarityData.Rarity : ProductRarity.Normal;
|
bulkOrderResultData.Rarity = cornResult == CornResult.Perfect ? rarityData.Rarity : ProductRarity.Normal;
|
||||||
|
|
@ -81,7 +83,7 @@ public class CookingResult : MonoBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
// チュートリアル時
|
// チュートリアル時
|
||||||
if (!GameDataManager.GameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
if (!globalGameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
||||||
{
|
{
|
||||||
// ボタン非表示
|
// ボタン非表示
|
||||||
SetUI(resultData, viewType, CheckMakeOne(resultData, productData), true);
|
SetUI(resultData, viewType, CheckMakeOne(resultData, productData), true);
|
||||||
|
|
@ -107,7 +109,7 @@ public class CookingResult : MonoBehaviour
|
||||||
okButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
okButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||||
{
|
{
|
||||||
// 獲得、遷移
|
// 獲得、遷移
|
||||||
MoveStock(GameDataManager.GameData.WaitAddStock);
|
MoveStock(cityGameData.WaitAddStock, GameDataManager.GameData.CurrentCityId);
|
||||||
GameDataManager.SaveGameData();
|
GameDataManager.SaveGameData();
|
||||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
|
@ -141,11 +143,11 @@ public class CookingResult : MonoBehaviour
|
||||||
okButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
okButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||||
{
|
{
|
||||||
// 獲得、遷移
|
// 獲得、遷移
|
||||||
MoveStock(GameDataManager.GameData.WaitAddStock);
|
MoveStock(cityGameData.WaitAddStock, GameDataManager.GameData.CurrentCityId);
|
||||||
|
|
||||||
// 獲得後、確率でVip宣伝
|
// 獲得後、確率でVip宣伝
|
||||||
var shopStock = GameDataManager.GameData.ShopStock.Count;
|
var shopStock = cityGameData.ShopStock.Count;
|
||||||
var tankStock = GameDataManager.GameData.StorageTanks.Sum(x => x.Stock);
|
var tankStock = cityGameData.StorageTanks.Sum(x => x.Stock);
|
||||||
var totalStock = shopStock + tankStock;
|
var totalStock = shopStock + tankStock;
|
||||||
if (totalStock >= Const.VipCustomerRewardStock)
|
if (totalStock >= Const.VipCustomerRewardStock)
|
||||||
{
|
{
|
||||||
|
|
@ -154,8 +156,8 @@ public class CookingResult : MonoBehaviour
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
Debug.Log($"flag VipReward");
|
Debug.Log($"flag VipReward");
|
||||||
#endif
|
#endif
|
||||||
GameDataManager.GameData.vipCustomerFirstOpen = true;
|
globalGameData.vipCustomerFirstOpen = true;
|
||||||
GameDataManager.GameData.vipCustomerLimitTime = DateTime.UtcNow.AddSeconds(60).ToBinary();
|
globalGameData.vipCustomerLimitTime = DateTime.UtcNow.AddSeconds(60).ToBinary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GameDataManager.SaveGameData();
|
GameDataManager.SaveGameData();
|
||||||
|
|
@ -167,7 +169,7 @@ public class CookingResult : MonoBehaviour
|
||||||
makeOneButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
makeOneButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||||
{
|
{
|
||||||
// 獲得、遷移
|
// 獲得、遷移
|
||||||
MoveStock(GameDataManager.GameData.WaitAddStock);
|
MoveStock(cityGameData.WaitAddStock, GameDataManager.GameData.CurrentCityId);
|
||||||
GameDataManager.SaveGameData();
|
GameDataManager.SaveGameData();
|
||||||
WorldMarketManager.Instance.IsPause.Value = false;
|
WorldMarketManager.Instance.IsPause.Value = false;
|
||||||
SoundManager.Instance.ChangeVolumeUniqueBGM(1f);
|
SoundManager.Instance.ChangeVolumeUniqueBGM(1f);
|
||||||
|
|
@ -256,37 +258,40 @@ public class CookingResult : MonoBehaviour
|
||||||
// まだ在庫追加前なのでレシピvolumeを2倍にしてタンクの空きを確認
|
// まだ在庫追加前なのでレシピvolumeを2倍にしてタンクの空きを確認
|
||||||
doubleProductData = new ProductData(productData, 1){volume = productData.volume * 2};
|
doubleProductData = new ProductData(productData, 1){volume = productData.volume * 2};
|
||||||
}
|
}
|
||||||
var hasSpace = RecipeDetailView.CheckTank(doubleProductData);
|
var hasSpace = RecipeDetailView.CheckTank(doubleProductData, GameDataManager.GameData.CurrentCityId);
|
||||||
//素材確認
|
//素材確認
|
||||||
var checkResult = RecipeDetailView.CheckAmount(productData);
|
var checkResult = RecipeDetailView.CheckAmount(productData, GameDataManager.GameData.CurrentCityId);
|
||||||
var hasMaterials = checkResult.material1 && checkResult.material2 && checkResult.material3;
|
var hasMaterials = checkResult.material1 && checkResult.material2 && checkResult.material3;
|
||||||
return hasSpace && hasMaterials;
|
return hasSpace && hasMaterials;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MoveStock(ProductStockData productStockData)
|
public static void MoveStock(ProductStockData productStockData, int cityId)
|
||||||
{
|
{
|
||||||
AddStock(productStockData);
|
AddStock(productStockData, cityId);
|
||||||
productStockData.Stock = 0;
|
productStockData.Stock = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddStock(ProductData productData, ProductRarity rarity = ProductRarity.Normal)
|
public static void AddStock(ProductData productData, ProductRarity rarity = ProductRarity.Normal) =>
|
||||||
|
AddStock(productData, rarity, GameDataManager.GameData.CurrentCityId);
|
||||||
|
|
||||||
|
public static void AddStock(ProductData productData, ProductRarity rarity, int cityId)
|
||||||
{
|
{
|
||||||
AddStock(new ProductStockData{FlavorId = productData.id, Stock = productData.volume, Rarity = rarity});
|
AddStock(new ProductStockData{FlavorId = productData.id, Stock = productData.volume, Rarity = rarity}, cityId);
|
||||||
GameDataManager.SaveGameData();
|
GameDataManager.SaveGameData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddStock(ProductStockData productStockData)
|
public static void AddStock(ProductStockData productStockData, int cityId)
|
||||||
{
|
{
|
||||||
if (productStockData.Stock == 0)
|
if (productStockData.Stock == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var gameData = GameDataManager.GameData;
|
var cityGameData = GameDataManager.GetCityGameData(cityId);
|
||||||
// 店頭の空きに追加
|
// 店頭の空きに追加
|
||||||
var remain = productStockData.Stock;
|
var remain = productStockData.Stock;
|
||||||
var shopSpace = WorldMarketManager.ShopStockCount - gameData.ShopStock.Count;
|
var shopSpace = WorldMarketManager.ShopStockCount - cityGameData.ShopStock.Count;
|
||||||
var stockCount = Mathf.Min(shopSpace, remain);
|
var stockCount = Mathf.Min(shopSpace, remain);
|
||||||
gameData.ShopStock.AddRange(Enumerable.Repeat(new ProductStockData
|
cityGameData.ShopStock.AddRange(Enumerable.Repeat(new ProductStockData
|
||||||
{
|
{
|
||||||
FlavorId = productStockData.FlavorId,
|
FlavorId = productStockData.FlavorId,
|
||||||
Rarity = productStockData.Rarity,
|
Rarity = productStockData.Rarity,
|
||||||
|
|
@ -295,15 +300,16 @@ public class CookingResult : MonoBehaviour
|
||||||
// ShopStockに補充された場合、DisplayFlavors更新
|
// ShopStockに補充された場合、DisplayFlavors更新
|
||||||
if (stockCount > 0)
|
if (stockCount > 0)
|
||||||
{
|
{
|
||||||
var market = WorldMarketManager.Instance.GetCurrentCityMarket();
|
var market = WorldMarketManager.Instance.GetMarket(cityId);
|
||||||
market.RefillDisplayFlavors(gameData.ShopStock);
|
market.RefillDisplayFlavors();
|
||||||
market.CheckStock(gameData.ShopStock);
|
market.UpdateShopState();
|
||||||
|
market.CheckPartTimerMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 空タンク並び替え
|
// 空タンク並び替え
|
||||||
gameData.StorageTanks = gameData.StorageTanks.OrderBy(tank => tank.IsEmpty).ToList();
|
cityGameData.StorageTanks = cityGameData.StorageTanks.OrderBy(tank => tank.IsEmpty).ToList();
|
||||||
// 空きのタンクを確認
|
// 空きのタンクを確認
|
||||||
gameData.StorageTanks
|
cityGameData.StorageTanks
|
||||||
.Select((tank, i) => (tank, i))
|
.Select((tank, i) => (tank, i))
|
||||||
.Where(x => x.tank.IsEmpty || x.tank.FlavorId == productStockData.FlavorId && !x.tank.IsFull)
|
.Where(x => x.tank.IsEmpty || x.tank.FlavorId == productStockData.FlavorId && !x.tank.IsFull)
|
||||||
.Select(x => (x.i, space: x.tank.Capacity - x.tank.Stock))
|
.Select(x => (x.i, space: x.tank.Capacity - x.tank.Stock))
|
||||||
|
|
@ -316,13 +322,13 @@ public class CookingResult : MonoBehaviour
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// タンクが空ならフレーバー設定
|
// タンクが空ならフレーバー設定
|
||||||
if (gameData.StorageTanks[x.i].IsEmpty)
|
if (cityGameData.StorageTanks[x.i].IsEmpty)
|
||||||
{
|
{
|
||||||
gameData.StorageTanks[x.i].FlavorId = productStockData.FlavorId;
|
cityGameData.StorageTanks[x.i].FlavorId = productStockData.FlavorId;
|
||||||
}
|
}
|
||||||
// タンクに追加
|
// タンクに追加
|
||||||
stockCount = Mathf.Min(x.space, remain);
|
stockCount = Mathf.Min(x.space, remain);
|
||||||
gameData.StorageTanks[x.i].AddStock(productStockData.Rarity, stockCount);
|
cityGameData.StorageTanks[x.i].AddStock(productStockData.Rarity, stockCount);
|
||||||
remain -= stockCount;
|
remain -= stockCount;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,10 @@ public class PanSelector : MonoBehaviour
|
||||||
selectedPanData.AddTo(this);
|
selectedPanData.AddTo(this);
|
||||||
selectedIndex.AddTo(this);
|
selectedIndex.AddTo(this);
|
||||||
var panList = SpreadsheetDataManager.Instance.GetBaseDataList<PanData>(Const.PanDataSheet);
|
var panList = SpreadsheetDataManager.Instance.GetBaseDataList<PanData>(Const.PanDataSheet);
|
||||||
var myPanList = panList.Where(data => GameDataManager.GameData.Pans.Contains(data.id)).ToList();
|
var globalGameData = GameDataManager.GameData;
|
||||||
|
var myPanList = panList.Where(data => globalGameData.Pans.Contains(data.id)).ToList();
|
||||||
var panCount = myPanList.Count;
|
var panCount = myPanList.Count;
|
||||||
var initIndex = myPanList.FindIndex(data => data.id == GameDataManager.GameData.SelectedPanId);
|
var initIndex = myPanList.FindIndex(data => data.id == globalGameData.SelectedPanId);
|
||||||
if (initIndex == -1)
|
if (initIndex == -1)
|
||||||
{
|
{
|
||||||
initIndex = 0;
|
initIndex = 0;
|
||||||
|
|
@ -32,7 +33,7 @@ public class PanSelector : MonoBehaviour
|
||||||
selectedPanData.SkipLatestValueOnSubscribe().Subscribe(data =>
|
selectedPanData.SkipLatestValueOnSubscribe().Subscribe(data =>
|
||||||
{
|
{
|
||||||
SetData(data);
|
SetData(data);
|
||||||
GameDataManager.GameData.SelectedPanId = data.id;
|
globalGameData.SelectedPanId = data.id;
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
selectedIndex.Subscribe(x =>
|
selectedIndex.Subscribe(x =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -36,15 +36,17 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
[SerializeField] private GameObject flavor2View;
|
[SerializeField] private GameObject flavor2View;
|
||||||
|
|
||||||
private Color redColor;
|
private Color redColor;
|
||||||
|
private GameData cityGameData;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
ColorUtility.TryParseHtmlString(Const.RedColorString, out redColor);
|
ColorUtility.TryParseHtmlString(Const.RedColorString, out redColor);
|
||||||
var viewType = LocalCacheManager.Load(Const.ProductViewTypeTag, ProductViewType.Default);
|
var viewType = LocalCacheManager.Load(Const.ProductViewTypeTag, ProductViewType.Default);
|
||||||
var data = LocalCacheManager.Load<ProductData>(PopcornGameManager.CookingDataTag);
|
var data = LocalCacheManager.Load<ProductData>(PopcornGameManager.CookingDataTag);
|
||||||
var gameData = GameDataManager.GameData;
|
cityGameData = GameDataManager.GetCurrentCityGameData();
|
||||||
|
var globalGameData = GameDataManager.GameData;
|
||||||
|
|
||||||
if (!gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
if (!globalGameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
||||||
{
|
{
|
||||||
// マスク表示
|
// マスク表示
|
||||||
var go = TutorialManager.Instance.ShowTutorialMask(transform.parent.parent, nextButton.transform as RectTransform);
|
var go = TutorialManager.Instance.ShowTutorialMask(transform.parent.parent, nextButton.transform as RectTransform);
|
||||||
|
|
@ -73,7 +75,7 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
|
|
||||||
SetRecipe(data, viewType);
|
SetRecipe(data, viewType);
|
||||||
var isPassedAmount = CheckAmountAndChangeTextColor(data);
|
var isPassedAmount = CheckAmountAndChangeTextColor(data);
|
||||||
var isPassedTank = CheckTank(data);
|
var isPassedTank = CheckTank(data, GameDataManager.GameData.CurrentCityId);
|
||||||
|
|
||||||
switch (viewType)
|
switch (viewType)
|
||||||
{
|
{
|
||||||
|
|
@ -94,28 +96,26 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConsumeMaterial(ProductData productData)
|
public static void ConsumeMaterial(ProductData productData, int cityId)
|
||||||
{
|
{
|
||||||
var gameData = GameDataManager.GameData;
|
var cityGameData = GameDataManager.GetCityGameData(cityId);
|
||||||
gameData.CornSeed -= productData.MaterialList[0].amount;
|
cityGameData.CornSeed -= productData.MaterialList[0].amount;
|
||||||
if (gameData.Material.FirstOrDefault(x => x.Id == productData.MaterialList[1].id) is MaterialData material1)
|
if (cityGameData.Material.FirstOrDefault(x => x.Id == productData.MaterialList[1].id) is MaterialData material1)
|
||||||
{
|
{
|
||||||
material1.Amount -= productData.MaterialList[1].amount;
|
material1.Amount -= productData.MaterialList[1].amount;
|
||||||
}
|
}
|
||||||
if (productData.GetMaterialCount() == 3 && gameData.Material.FirstOrDefault(x => x.Id == productData.MaterialList[2].id) is MaterialData material2)
|
if (productData.GetMaterialCount() == 3 && cityGameData.Material.FirstOrDefault(x => x.Id == productData.MaterialList[2].id) is MaterialData material2)
|
||||||
{
|
{
|
||||||
material2.Amount -= productData.MaterialList[2].amount;
|
material2.Amount -= productData.MaterialList[2].amount;
|
||||||
}
|
}
|
||||||
GameDataManager.SaveGameData();
|
GameDataManager.SaveGameData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRecipe(ProductData data, ProductViewType viewType)
|
private void SetRecipe(ProductData data, ProductViewType viewType)
|
||||||
{
|
{
|
||||||
var gameData = GameDataManager.GameData;
|
|
||||||
|
|
||||||
// 在庫
|
// 在庫
|
||||||
var shopStock = gameData.ShopStock.Count(stockData => stockData.FlavorId == data.id);
|
var shopStock = cityGameData.ShopStock.Count(stockData => stockData.FlavorId == data.id);
|
||||||
var tankStock = gameData.StorageTanks.FindAll(x => x.FlavorId == data.id).Sum(x => x.Stock);
|
var tankStock = cityGameData.StorageTanks.FindAll(x => x.FlavorId == data.id).Sum(x => x.Stock);
|
||||||
flavorStock.text = $"{ScriptLocalization.UI.RecipeChoiceMyStockPrefix}{shopStock + tankStock}";
|
flavorStock.text = $"{ScriptLocalization.UI.RecipeChoiceMyStockPrefix}{shopStock + tankStock}";
|
||||||
flavorName.text = data.Name;
|
flavorName.text = data.Name;
|
||||||
flavorPrice.text = data.price.ToString();
|
flavorPrice.text = data.price.ToString();
|
||||||
|
|
@ -123,7 +123,7 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
flavorText.text = data.Text;
|
flavorText.text = data.Text;
|
||||||
flavorImageTarget.DestroyAllChildrens();
|
flavorImageTarget.DestroyAllChildrens();
|
||||||
Instantiate(data.GetIconPrefab(), flavorImageTarget);
|
Instantiate(data.GetIconPrefab(), flavorImageTarget);
|
||||||
cornAmountText.text = string.Format(cornAmountFormat, gameData.CornSeed, data.MaterialList[0].amount);
|
cornAmountText.text = string.Format(cornAmountFormat, cityGameData.CornSeed, data.MaterialList[0].amount);
|
||||||
|
|
||||||
switch (viewType)
|
switch (viewType)
|
||||||
{
|
{
|
||||||
|
|
@ -143,14 +143,14 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
var shopData = SpreadsheetDataManager.Instance.GetBaseDataList<ShopData>(Const.ShopDataSheet);
|
var shopData = SpreadsheetDataManager.Instance.GetBaseDataList<ShopData>(Const.ShopDataSheet);
|
||||||
var flavor1Amount = gameData.Material.FirstOrDefault(x => x.Id == data.MaterialList[1].id)?.Amount ?? 0;
|
var flavor1Amount = cityGameData.Material.FirstOrDefault(x => x.Id == data.MaterialList[1].id)?.Amount ?? 0;
|
||||||
flavor1AmountText.text = string.Format(flavorAmountFormat, flavor1Amount, data.MaterialList[1].amount);
|
flavor1AmountText.text = string.Format(flavorAmountFormat, flavor1Amount, data.MaterialList[1].amount);
|
||||||
if (shopData.FirstOrDefault(sData => sData.itemId == data.MaterialList[1].id)?.GetIconPrefab() is Transform prefab1)
|
if (shopData.FirstOrDefault(sData => sData.itemId == data.MaterialList[1].id)?.GetIconPrefab() is Transform prefab1)
|
||||||
{
|
{
|
||||||
flavor1IconTarget.DestroyAllChildrens();
|
flavor1IconTarget.DestroyAllChildrens();
|
||||||
Instantiate(prefab1, flavor1IconTarget);
|
Instantiate(prefab1, flavor1IconTarget);
|
||||||
}
|
}
|
||||||
var flavor2Amount = gameData.Material.FirstOrDefault(x => x.Id == data.MaterialList[2].id)?.Amount ?? 0;
|
var flavor2Amount = cityGameData.Material.FirstOrDefault(x => x.Id == data.MaterialList[2].id)?.Amount ?? 0;
|
||||||
flavor2AmountText.text = string.Format(flavorAmountFormat, flavor2Amount, data.MaterialList[2].amount);
|
flavor2AmountText.text = string.Format(flavorAmountFormat, flavor2Amount, data.MaterialList[2].amount);
|
||||||
if (shopData.FirstOrDefault(sData => sData.itemId == data.MaterialList[2].id)?.GetIconPrefab() is Transform prefab2)
|
if (shopData.FirstOrDefault(sData => sData.itemId == data.MaterialList[2].id)?.GetIconPrefab() is Transform prefab2)
|
||||||
{
|
{
|
||||||
|
|
@ -162,7 +162,7 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
|
|
||||||
private bool CheckAmountAndChangeTextColor(ProductData productData)
|
private bool CheckAmountAndChangeTextColor(ProductData productData)
|
||||||
{
|
{
|
||||||
var checkResult = CheckAmount(productData);
|
var checkResult = CheckAmount(productData, GameDataManager.GameData.CurrentCityId);
|
||||||
if (!checkResult.material1)
|
if (!checkResult.material1)
|
||||||
{
|
{
|
||||||
cornAmountText.color = redColor;
|
cornAmountText.color = redColor;
|
||||||
|
|
@ -178,36 +178,36 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
return checkResult.material1 && checkResult.material2 && checkResult.material3;
|
return checkResult.material1 && checkResult.material2 && checkResult.material3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (bool material1, bool material2, bool material3) CheckAmount(ProductData productData)
|
public static (bool material1, bool material2, bool material3) CheckAmount(ProductData productData, int cityId)
|
||||||
{
|
{
|
||||||
(bool a, bool b, bool c) flags = (true, true, true);
|
(bool a, bool b, bool c) flags = (true, true, true);
|
||||||
var gameData = GameDataManager.GameData;
|
var cityGameData = GameDataManager.GetCityGameData(cityId);
|
||||||
if (gameData.CornSeed < productData.MaterialList[0].amount)
|
if (cityGameData.CornSeed < productData.MaterialList[0].amount)
|
||||||
{
|
{
|
||||||
flags.a = false;
|
flags.a = false;
|
||||||
}
|
}
|
||||||
if ((gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[1].id)?.Amount ?? 0) < productData.MaterialList[1].amount)
|
if ((cityGameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[1].id)?.Amount ?? 0) < productData.MaterialList[1].amount)
|
||||||
{
|
{
|
||||||
flags.b = false;
|
flags.b = false;
|
||||||
}
|
}
|
||||||
if (productData.GetMaterialCount() == 3 && (gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[2].id)?.Amount ?? 0) < productData.MaterialList[2].amount)
|
if (productData.GetMaterialCount() == 3 && (cityGameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[2].id)?.Amount ?? 0) < productData.MaterialList[2].amount)
|
||||||
{
|
{
|
||||||
flags.c = false;
|
flags.c = false;
|
||||||
}
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CheckTank(ProductData data)
|
public static bool CheckTank(ProductData data, int cityId)
|
||||||
{
|
{
|
||||||
var gameData = GameDataManager.GameData;
|
var cityGameData = GameDataManager.GetCityGameData(cityId);
|
||||||
// 店頭の空き確認
|
// 店頭の空き確認
|
||||||
if (data.volume <= WorldMarketManager.ShopStockCount - gameData.ShopStock.Count)
|
if (data.volume <= WorldMarketManager.ShopStockCount - cityGameData.ShopStock.Count)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 空のタンク、同じフレーバーのタンク空き確認
|
// 空のタンク、同じフレーバーのタンク空き確認
|
||||||
return gameData.StorageTanks
|
return cityGameData.StorageTanks
|
||||||
.Where(tank => tank.IsEmpty || tank.FlavorId == data.id && !tank.IsFull)
|
.Where(tank => tank.IsEmpty || tank.FlavorId == data.id && !tank.IsFull)
|
||||||
.Any(tank => data.volume <= tank.Capacity - tank.Stock);
|
.Any(tank => data.volume <= tank.Capacity - tank.Stock);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public class RecipeSelectDialog : MonoBehaviour
|
||||||
// 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 globalGameData = GameDataManager.GameData;
|
||||||
closeButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
closeButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||||
{
|
{
|
||||||
transform.SetLocalScale(0);
|
transform.SetLocalScale(0);
|
||||||
|
|
@ -40,7 +40,7 @@ public class RecipeSelectDialog : MonoBehaviour
|
||||||
var ownedRecipesList = shopDataList.Where(data => data.Category == ItemCategory.Recipe).Select(data => data.itemId).ToList();
|
var ownedRecipesList = shopDataList.Where(data => data.Category == ItemCategory.Recipe).Select(data => data.itemId).ToList();
|
||||||
var targetList = productDataList
|
var targetList = productDataList
|
||||||
.Where(data => data.shopLevel != Const.SpecialShopLevel || ownedRecipesList.Contains(data.id))
|
.Where(data => data.shopLevel != Const.SpecialShopLevel || ownedRecipesList.Contains(data.id))
|
||||||
.OrderByDescending(data => gameData.MyRecipes.Contains(data.id))
|
.OrderByDescending(data => globalGameData.MyRecipes.Contains(data.id))
|
||||||
.ThenBy(data => ownedRecipesList.Contains(data.id))
|
.ThenBy(data => ownedRecipesList.Contains(data.id))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ public class RecipeSelectDialog : MonoBehaviour
|
||||||
var view = Instantiate(recipePrefab, content.transform);
|
var view = Instantiate(recipePrefab, content.transform);
|
||||||
view.SetRecipe(productData);
|
view.SetRecipe(productData);
|
||||||
// 所持レシピ確認
|
// 所持レシピ確認
|
||||||
if (gameData.MyRecipes.Contains(productData.id))
|
if (globalGameData.MyRecipes.Contains(productData.id))
|
||||||
{
|
{
|
||||||
view.SetLockPanel(false);
|
view.SetLockPanel(false);
|
||||||
view.RecipeClickObservable.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
view.RecipeClickObservable.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
||||||
|
|
@ -66,7 +66,7 @@ public class RecipeSelectDialog : MonoBehaviour
|
||||||
LayoutRebuilder.ForceRebuildLayoutImmediate(content);
|
LayoutRebuilder.ForceRebuildLayoutImmediate(content);
|
||||||
scrollRect.verticalNormalizedPosition = 1;
|
scrollRect.verticalNormalizedPosition = 1;
|
||||||
|
|
||||||
if (!gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
if (!globalGameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
||||||
{
|
{
|
||||||
scrollRect.vertical = false;
|
scrollRect.vertical = false;
|
||||||
// マスク表示
|
// マスク表示
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public sealed class InitializeUnitySettings : MonoBehaviour {
|
public sealed class InitializeUnitySettings : MonoBehaviour {
|
||||||
|
|
@ -28,10 +30,13 @@ public sealed class InitializeUnitySettings : MonoBehaviour {
|
||||||
|
|
||||||
Input.multiTouchEnabled = false;
|
Input.multiTouchEnabled = false;
|
||||||
|
|
||||||
// 遅延させていたパラメータを追加
|
foreach (var (cityId, cityGameData) in GameDataManager.GameData.CityGameDataDict.Prepend(new(Const.DefaultCityId, GameDataManager.GameData)))
|
||||||
GameDataManager.GameData.MoveAllWaitValue();
|
{
|
||||||
// 調理後リザルトでの仮獲得データを反映(タスクキル対策)
|
// 遅延させていたパラメータを追加
|
||||||
CookingResult.MoveStock(GameDataManager.GameData.WaitAddStock);
|
cityGameData.MoveAllWaitValue();
|
||||||
|
// 調理後リザルトでの仮獲得データを反映(タスクキル対策)
|
||||||
|
CookingResult.MoveStock(cityGameData.WaitAddStock, cityId);
|
||||||
|
}
|
||||||
GameDataManager.SaveGameData();
|
GameDataManager.SaveGameData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue