diff --git a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs index afb2501a..04a75498 100644 --- a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs +++ b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs @@ -94,7 +94,7 @@ public class RecipeDetailView : MonoBehaviour }).AddTo(this); SetRecipe(data, viewType); - var isPassedAmount = CheckAmount(data); + var isPassedAmount = CheckAmountAndChangeTextColor(data); var isPassedTank = CheckTank(data); switch (viewType) @@ -167,29 +167,44 @@ public class RecipeDetailView : MonoBehaviour flavor2View.SetActive(data.GetMaterialCount() == 3); } - private bool CheckAmount(ProductData productData) + private bool CheckAmountAndChangeTextColor(ProductData productData) { - var flag = true; + var checkResult = CheckAmount(productData); + if (!checkResult.material1) + { + cornAmountText.color = redColor; + } + if (!checkResult.material2) + { + flavor1AmountText.color = redColor; + } + if (!checkResult.material3) + { + flavor2AmountText.color = redColor; + } + return checkResult.material1 && checkResult.material2 && checkResult.material3; + } + + public static (bool material1, bool material2, bool material3) CheckAmount(ProductData productData) + { + (bool a, bool b, bool c) flags = (true, true, true); var gameData = GameDataManager.GameData; if (gameData.CornSeed < productData.MaterialList[0].amount) { - flag = false; - cornAmountText.color = redColor; + flags.a = false; } if ((gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[1].id)?.Amount ?? 0) < productData.MaterialList[1].amount) { - flag = false; - flavor1AmountText.color = redColor; + flags.b = false; } 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; + flags.c = false; } - return flag; + return flags; } - private bool CheckTank(ProductData data) + public static bool CheckTank(ProductData data) { var gameData = GameDataManager.GameData; // 店頭の空き確認