タンク不足表示対応
This commit is contained in:
parent
e88777f1e2
commit
dc0abb20ff
|
|
@ -1867,6 +1867,8 @@ MonoBehaviour:
|
||||||
cancelButton: {fileID: 843133640}
|
cancelButton: {fileID: 843133640}
|
||||||
nextButton: {fileID: 1853630204}
|
nextButton: {fileID: 1853630204}
|
||||||
disabledNextButton: {fileID: 1037294270}
|
disabledNextButton: {fileID: 1037294270}
|
||||||
|
tankCaution: {fileID: 1464412873}
|
||||||
|
panSelector: {fileID: 1160535648}
|
||||||
flavorName: {fileID: 707887860}
|
flavorName: {fileID: 707887860}
|
||||||
flavorPrice: {fileID: 498799267}
|
flavorPrice: {fileID: 498799267}
|
||||||
flavorStock: {fileID: 1109202679}
|
flavorStock: {fileID: 1109202679}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,16 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
{
|
{
|
||||||
private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger");
|
private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger");
|
||||||
private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger");
|
private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger");
|
||||||
|
private static readonly string flavorStockFormat = "所持数 :{0}";
|
||||||
|
private static readonly string cornAmountFormat = "{0}/{1}";
|
||||||
|
private static readonly string flavorAmountFormat = "{0} / {1}";
|
||||||
|
|
||||||
[SerializeField] private Animator backgroundAnimator;
|
[SerializeField] private Animator backgroundAnimator;
|
||||||
[SerializeField] private Button cancelButton;
|
[SerializeField] private Button cancelButton;
|
||||||
[SerializeField] private Button nextButton;
|
[SerializeField] private Button nextButton;
|
||||||
[SerializeField] private GameObject disabledNextButton;
|
[SerializeField] private GameObject disabledNextButton;
|
||||||
|
[SerializeField] private GameObject tankCaution;
|
||||||
|
[SerializeField] private PanSelector panSelector;
|
||||||
[SerializeField] private Text flavorName;
|
[SerializeField] private Text flavorName;
|
||||||
[SerializeField] private Text flavorPrice;
|
[SerializeField] private Text flavorPrice;
|
||||||
[SerializeField] private Text flavorStock;
|
[SerializeField] private Text flavorStock;
|
||||||
|
|
@ -21,9 +25,6 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
[SerializeField] private Text flavor1AmountText;
|
[SerializeField] private Text flavor1AmountText;
|
||||||
[SerializeField] private Text flavor2AmountText;
|
[SerializeField] private Text flavor2AmountText;
|
||||||
[SerializeField] private GameObject flavor2View;
|
[SerializeField] private GameObject flavor2View;
|
||||||
private static readonly string flavorStockFormat = "所持数 :{0}";
|
|
||||||
private static readonly string cornAmountFormat = "{0}/{1}";
|
|
||||||
private static readonly string flavorAmountFormat = "{0} / {1}";
|
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
|
@ -39,10 +40,6 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
});
|
});
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
|
||||||
SetRecipe(data);
|
|
||||||
if (CheckAmount(data))
|
|
||||||
{
|
|
||||||
disabledNextButton.SetActive(false);
|
|
||||||
nextButton.OnClickAsObservable().Subscribe(_ =>
|
nextButton.OnClickAsObservable().Subscribe(_ =>
|
||||||
{
|
{
|
||||||
var gameData = GameDataManager.GameData;
|
var gameData = GameDataManager.GameData;
|
||||||
|
|
@ -62,12 +59,14 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
GameDataManager.SaveGameData();
|
GameDataManager.SaveGameData();
|
||||||
TransitionManager.Instance.LoadScene(GameScenes.Cooking);
|
TransitionManager.Instance.LoadScene(GameScenes.Cooking);
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
}
|
|
||||||
else
|
SetRecipe(data);
|
||||||
{
|
var isPassedAmount = CheckAmount(data);
|
||||||
nextButton.interactable = false;
|
var isPassedTank = CheckTank(data);
|
||||||
disabledNextButton.SetActive(true);
|
nextButton.interactable = isPassedAmount && isPassedTank;
|
||||||
}
|
panSelector.gameObject.SetActive(isPassedTank);
|
||||||
|
disabledNextButton.SetActive(!isPassedAmount || !isPassedTank);
|
||||||
|
tankCaution.SetActive(!isPassedTank);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRecipe(RecipeData data)
|
public void SetRecipe(RecipeData data)
|
||||||
|
|
@ -132,35 +131,21 @@ public class RecipeDetailView : MonoBehaviour
|
||||||
flavor2AmountText.color = Color.red;
|
flavor2AmountText.color = Color.red;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return flag;
|
||||||
if (!flag)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 店頭の空きがない
|
private bool CheckTank(RecipeData data)
|
||||||
// 店頭の空きに追加
|
{
|
||||||
if (Market.ShopStockCount >= gameData.ShopStock.Count + data.Volume)
|
var gameData = GameDataManager.GameData;
|
||||||
|
// 店頭の空き確認
|
||||||
|
if (data.Volume <= Market.ShopStockCount - gameData.ShopStock.Count)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 空のタンクに追加
|
|
||||||
if (gameData.StorageTanks.FindIndex(x => x.Stock == 0) != -1)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// 同じフレーバーのタンクを確認
|
|
||||||
var index = gameData.StorageTanks.FindIndex(x => x.FlavorId == data.RecipeId);
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
// 同じフレーバーのタンクの空きに追加
|
|
||||||
var tank = gameData.StorageTanks[index];
|
|
||||||
if (tank.Capacity >= tank.Stock + data.Volume)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
// 空のタンク、同じフレーバーのタンク空き確認
|
||||||
|
return gameData.StorageTanks
|
||||||
|
.Where(tank => tank.IsEmpty || tank.FlavorId == data.RecipeId && !tank.IsFull)
|
||||||
|
.Any(tank => data.Volume <= tank.Capacity - tank.Stock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue