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