From db6da0f6eb932f92af37bd7cb4951a5bcb697356 Mon Sep 17 00:00:00 2001 From: kimura Date: Tue, 12 Oct 2021 13:15:35 +0900 Subject: [PATCH] =?UTF-8?q?=E7=B4=A0=E6=9D=90=E4=B8=8D=E8=B6=B3=E6=99=82?= =?UTF-8?q?=E3=81=AE=E8=B5=A4=E8=89=B2=E5=AF=BE=E5=BF=9C=E3=82=92=E3=83=AC?= =?UTF-8?q?=E3=82=B7=E3=83=94=E3=81=AB=E8=BF=BD=E5=8A=A0/=20=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E8=89=B2=20fb6346=20=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Main/Scripts/BulkOrderItemView.cs | 13 ++++++--- .../Scenes/recipe/Scripts/RecipeDetailView.cs | 9 ++++--- .../Scenes/recipe/Scripts/RecipeView.cs | 27 ++++++++++++++++++- .../shopping/Scripts/ShopItemPurchaseView.cs | 3 +-- popcorn/Assets/MyGame/Scripts/Const.cs | 1 + 5 files changed, 44 insertions(+), 9 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrderItemView.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrderItemView.cs index fb6afd1c..0875ca0d 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrderItemView.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrderItemView.cs @@ -20,9 +20,16 @@ public class BulkOrderItemView : MonoBehaviour [SerializeField] private Transform material1IconTarget; [SerializeField] private Transform material2IconTarget; [SerializeField] private Transform packageIconTarget; + + private Color redColor; public IObservable CookingButton => cookingButton.OnClickAsObservable().TakeUntilDestroy(this); + private void Awake() + { + ColorUtility.TryParseHtmlString(Const.RedColorString, out redColor); + } + public void SetData(ProductData data) { stockText.text = data.volume.ToString(); @@ -57,17 +64,17 @@ public class BulkOrderItemView : MonoBehaviour if (gameData.CornSeed < productData.MaterialList[0].amount) { flag = false; - cornText.color = Color.red; + cornText.color = redColor; } if ((gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[1].id)?.Amount ?? 0) < productData.MaterialList[1].amount) { flag = false; - material1Text.color = Color.red; + material1Text.color = redColor; } if (productData.GetMaterialCount() == 3 && (gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[2].id)?.Amount ?? 0) < productData.MaterialList[2].amount) { flag = false; - material2Text.color = Color.red; + material2Text.color = redColor; } return flag; } diff --git a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs index 0f22d23e..9f44621b 100644 --- a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs +++ b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs @@ -31,9 +31,12 @@ public class RecipeDetailView : MonoBehaviour [SerializeField] private Transform flavor1IconTarget; [SerializeField] private Transform flavor2IconTarget; [SerializeField] private GameObject flavor2View; + + private Color redColor; private void Start() { + ColorUtility.TryParseHtmlString(Const.RedColorString, out redColor); var viewType = LocalCacheManager.Load(Const.ProductViewTypeTag, ProductViewType.Default); var data = LocalCacheManager.Load(PopcornGameManager.CookingDataTag); @@ -146,17 +149,17 @@ public class RecipeDetailView : MonoBehaviour if (gameData.CornSeed < productData.MaterialList[0].amount) { flag = false; - cornAmountText.color = Color.red; + cornAmountText.color = redColor; } if ((gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[1].id)?.Amount ?? 0) < productData.MaterialList[1].amount) { flag = false; - flavor1AmountText.color = Color.red; + flavor1AmountText.color = redColor; } if (productData.GetMaterialCount() == 3 && (gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[2].id)?.Amount ?? 0) < productData.MaterialList[2].amount) { flag = false; - flavor2AmountText.color = Color.red; + flavor2AmountText.color = redColor; } return flag; } diff --git a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeView.cs b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeView.cs index f444f2fe..285c07df 100644 --- a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeView.cs +++ b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeView.cs @@ -21,10 +21,12 @@ public class RecipeView : MonoBehaviour private static readonly string amountFormat = "x{0}"; private static readonly string lockPanelTextFormat = "店舗レベル{0}で開放"; private static readonly string lockPanelTextShopFormat = "仕入れから購入可能"; + private Color redColor; public IObservable RecipeClickObservable => detailButton.OnClickAsObservable().TakeUntilDestroy(this); - private void Start() + private void Awake() { + ColorUtility.TryParseHtmlString(Const.RedColorString, out redColor); } public void SetRecipe(ProductData data) @@ -55,6 +57,7 @@ public class RecipeView : MonoBehaviour { flavor2View.SetActive(false); } + CheckAmount(data); if (data.shopLevel == Const.SpecialShopLevel) { @@ -65,6 +68,28 @@ public class RecipeView : MonoBehaviour lockPanelText.text = string.Format(lockPanelTextFormat, data.shopLevel); } } + + private bool CheckAmount(ProductData productData) + { + var flag = true; + var gameData = GameDataManager.GameData; + if (gameData.CornSeed < productData.MaterialList[0].amount) + { + flag = false; + cornAmountText.color = redColor; + } + if ((gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[1].id)?.Amount ?? 0) < productData.MaterialList[1].amount) + { + flag = false; + flavor1AmountText.color = redColor; + } + if (productData.GetMaterialCount() == 3 && (gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[2].id)?.Amount ?? 0) < productData.MaterialList[2].amount) + { + flag = false; + flavor2AmountText.color = redColor; + } + return flag; + } public void SetLockPanel(bool hasRecipe) { diff --git a/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemPurchaseView.cs b/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemPurchaseView.cs index 134d919d..02b8853a 100644 --- a/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemPurchaseView.cs +++ b/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemPurchaseView.cs @@ -6,7 +6,6 @@ using UnityEngine.UI; public class ShopItemPurchaseView : MonoBehaviour { public static readonly string ItemPurchaseTag = "ItemPurcahse"; - private static readonly string redColorString= "#fb6346"; private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger"); private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger"); private static readonly int MaxPurchaseCount = 999; @@ -36,7 +35,7 @@ public class ShopItemPurchaseView : MonoBehaviour { currentCount.AddTo(this); defaultColor = totalPrice.color; - ColorUtility.TryParseHtmlString(redColorString, out redColor); + ColorUtility.TryParseHtmlString(Const.RedColorString, out redColor); // 表示データを受け取る var data = LocalCacheManager.Load<(ShopData shopData, int stockCount, Action callback)>(ItemPurchaseTag); LocalCacheManager.Remove(ItemPurchaseTag); diff --git a/popcorn/Assets/MyGame/Scripts/Const.cs b/popcorn/Assets/MyGame/Scripts/Const.cs index cb5c27d3..857bd8b3 100644 --- a/popcorn/Assets/MyGame/Scripts/Const.cs +++ b/popcorn/Assets/MyGame/Scripts/Const.cs @@ -12,6 +12,7 @@ public static class Const { public static readonly int DefaultPanId = 1; public static readonly int SpecialShopLevel = 9999; public static readonly int NotSetMaterialId = 0; + public static readonly string RedColorString = "#fb6346"; // tag public static readonly string GameDataTag = "GameData";