From 980ed76a58e9668ba2c4bdeb5ec6b48fac19c7c9 Mon Sep 17 00:00:00 2001 From: kimura Date: Tue, 19 Apr 2022 17:57:31 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../marketing/Scripts/ProductManagement.cs | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs index ef8f87b2..c8f908c5 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ProductManagement.cs @@ -84,16 +84,11 @@ public class ProductManagement : MonoBehaviour if (tankView.TankNumber > gameData.StorageTanks.Count) { // 価格の一番小さいタンクのみ購入できるようにする - if (tankView.TankNumber == gameData.StorageTanks.Count + 1) - { - tankView.SetState(TankState.Lock); - } - else - { - tankView.SetState(TankState.Unavailable); - } + var isSmallest = tankView.TankNumber == gameData.StorageTanks.Count + 1; + tankView.SetState(isSmallest ? TankState.Lock : TankState.Unavailable); // タンク購入 var shopData = shopDataList.First(data => data.id == Const.ShopTankId); + shopData.price = PriceList[tankView.TankNumber - 1]; // 購入可否 tankView.SetCanBuy(shopData.price <= CoinManager.Instance.OwnCoin); @@ -103,10 +98,10 @@ public class ProductManagement : MonoBehaviour .TakeWhile(_ => tankView.State.Value == TankState.Lock || tankView.State.Value == TankState.Unavailable) .Subscribe(_ => { - Action purchaseAction = amount => + void PurchaseAction(int amount) { // タンク追加 - gameData.StorageTanks.Add(new StorageTank() {Capacity = Const.TankCapacity}); + gameData.StorageTanks.Add(new StorageTank { Capacity = Const.TankCapacity }); tankView.SetData(gameData.StorageTanks[tankView.TankNumber - 1]); tankView.SetState(TankState.Unlock); CoinManager.Instance.SubCoin(shopData.price); @@ -118,9 +113,10 @@ public class ProductManagement : MonoBehaviour tankList[tankView.TankNumber].SetState(TankState.Lock); tankList[tankView.TankNumber].SetCanBuy(PriceList[tankView.TankNumber] <= CoinManager.Instance.OwnCoin); } - }; + } + shopData.price = PriceList[tankView.TankNumber - 1]; - ShopItemPurchaseView.ShowDialog((shopData, 0), purchaseAction); + ShopItemPurchaseView.ShowDialog((shopData, 0), PurchaseAction); }).AddTo(tankView); } else