レシピ必要量のチェック処理修正
This commit is contained in:
parent
61de57166b
commit
69ec5e2644
|
@ -59,24 +59,11 @@ public class BulkOrderItemView : MonoBehaviour
|
|||
|
||||
public bool CheckAmount(ProductData productData)
|
||||
{
|
||||
var flag = true;
|
||||
var gameData = GameDataManager.GameData;
|
||||
if (gameData.CornSeed < productData.MaterialList[0].amount)
|
||||
{
|
||||
flag = false;
|
||||
cornText.color = redColor;
|
||||
}
|
||||
if ((gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[1].id)?.Amount ?? 0) < productData.MaterialList[1].amount)
|
||||
{
|
||||
flag = false;
|
||||
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 = redColor;
|
||||
}
|
||||
return flag;
|
||||
var (corn, flavor1, flavor2) = RecipeView.CheckAmount(productData);
|
||||
if (!corn) cornText.color = redColor;
|
||||
if (!flavor1) material1Text.color = redColor;
|
||||
if (!flavor2) material2Text.color = redColor;
|
||||
return corn & flavor1 & flavor2;
|
||||
}
|
||||
|
||||
public void SetButtonActive(bool active)
|
||||
|
|
|
@ -56,7 +56,10 @@ public class RecipeView : MonoBehaviour
|
|||
{
|
||||
flavor2View.SetActive(false);
|
||||
}
|
||||
CheckAmount(data);
|
||||
var (corn, flavor1, flavor2) = CheckAmount(data);
|
||||
if (!corn) cornAmountText.color = redColor;
|
||||
if (!flavor1) flavor1AmountText.color = redColor;
|
||||
if (!flavor2) flavor2AmountText.color = redColor;
|
||||
|
||||
if (data.shopLevel == Const.SpecialShopLevel)
|
||||
{
|
||||
|
@ -68,26 +71,13 @@ public class RecipeView : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private bool CheckAmount(ProductData productData)
|
||||
public static (bool corn, bool flavor1, bool flavor2) 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;
|
||||
var cityGameData = GameDataManager.GetCurrentCityGameData();
|
||||
var corn = cityGameData.CornSeed >= productData.MaterialList[0].amount;
|
||||
var flavor1 = (cityGameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[1].id)?.Amount ?? 0) >= productData.MaterialList[1].amount;
|
||||
var flavor2 = productData.GetMaterialCount() == 3 && (cityGameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[2].id)?.Amount ?? 0) >= productData.MaterialList[2].amount;
|
||||
return (corn, flavor1, flavor2);
|
||||
}
|
||||
|
||||
public void SetLockPanel(bool hasRecipe)
|
||||
|
|
Loading…
Reference in New Issue