レシピ選択にフライパンを追加
This commit is contained in:
parent
314ba8ecd7
commit
9b3af3217b
|
|
@ -30,9 +30,9 @@ public class CookingResult : MonoBehaviour
|
|||
|
||||
private void Start()
|
||||
{
|
||||
var (recipe, rarityData, resultData, successAction) = LocalCacheManager.Load<(RecipeData, RarityData, CornResult, Action)>(PopcornGameManager.CookingResultDataTag);
|
||||
var (productData, rarityData, resultData, successAction) = LocalCacheManager.Load<(ProductData, RarityData, CornResult, Action)>(PopcornGameManager.CookingResultDataTag);
|
||||
var result = new ReactiveProperty<CornResult>(resultData).AddTo(this);
|
||||
SetData(recipe, rarityData);
|
||||
SetData(productData, rarityData);
|
||||
result.Subscribe(r =>
|
||||
{
|
||||
SetUI(r);
|
||||
|
|
@ -46,13 +46,13 @@ public class CookingResult : MonoBehaviour
|
|||
centerOkButton.OnClickAsObservable().Subscribe(_ =>
|
||||
{
|
||||
// 獲得、遷移
|
||||
AddStock(recipe, rarityData.Rarity);
|
||||
AddStock(productData, rarityData.Rarity);
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||
}).AddTo(this);
|
||||
leftOkButton.OnClickAsObservable().Subscribe(_ =>
|
||||
{
|
||||
// 獲得、遷移
|
||||
AddStock(recipe);
|
||||
AddStock(productData);
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||
}).AddTo(this);
|
||||
perfectButton.OnClickAsObservable().Subscribe(_ =>
|
||||
|
|
@ -67,12 +67,12 @@ public class CookingResult : MonoBehaviour
|
|||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private void SetData(RecipeData recipe, RarityData rarity)
|
||||
private void SetData(ProductData recipe, RarityData rarity)
|
||||
{
|
||||
// popcornImage
|
||||
popcornText.text = recipe.Name;
|
||||
popcornTextPerfect.text = recipe.Name;
|
||||
quantityText.text = string.Format(QuantityTextFormat, recipe.Volume);
|
||||
popcornText.text = recipe.name;
|
||||
popcornTextPerfect.text = recipe.name;
|
||||
quantityText.text = string.Format(QuantityTextFormat, recipe.volume);
|
||||
rarityText.text = string.Format(RarityTextFormat, rarity.rate - 100);
|
||||
rarityView.SetRarity(rarity.Rarity);
|
||||
}
|
||||
|
|
@ -104,14 +104,14 @@ public class CookingResult : MonoBehaviour
|
|||
explainWithRarityObject.SetActive(result == CornResult.Perfect);
|
||||
}
|
||||
|
||||
private void AddStock(RecipeData recipe, ProductRarity rarity = ProductRarity.Normal)
|
||||
private void AddStock(ProductData productData, ProductRarity rarity = ProductRarity.Normal)
|
||||
{
|
||||
var gameData = GameDataManager.GameData;
|
||||
// 店頭の空きに追加
|
||||
var remain = recipe.Volume;
|
||||
var remain = productData.volume;
|
||||
var shopSpace = Market.ShopStockCount - gameData.ShopStock.Count;
|
||||
var stockCount = Mathf.Min(shopSpace, remain);
|
||||
gameData.ShopStock.AddRange(Enumerable.Repeat(recipe.RecipeId, stockCount));
|
||||
gameData.ShopStock.AddRange(Enumerable.Repeat(productData.id, stockCount));
|
||||
remain -= stockCount;
|
||||
|
||||
// 空タンク並び替え
|
||||
|
|
@ -119,7 +119,7 @@ public class CookingResult : MonoBehaviour
|
|||
// 空きのタンクを確認
|
||||
gameData.StorageTanks
|
||||
.Select((tank, i) => (tank, i))
|
||||
.Where(x => x.tank.IsEmpty || x.tank.FlavorId == recipe.RecipeId && !x.tank.IsFull)
|
||||
.Where(x => x.tank.IsEmpty || x.tank.FlavorId == productData.id && !x.tank.IsFull)
|
||||
.Select(x => (x.i, space: x.tank.Capacity - x.tank.Stock))
|
||||
.OrderBy(x => x.space)
|
||||
.ToList()
|
||||
|
|
@ -132,7 +132,7 @@ public class CookingResult : MonoBehaviour
|
|||
// タンクが空ならフレーバー設定
|
||||
if (gameData.StorageTanks[x.i].IsEmpty)
|
||||
{
|
||||
gameData.StorageTanks[x.i].FlavorId = recipe.RecipeId;
|
||||
gameData.StorageTanks[x.i].FlavorId = productData.id;
|
||||
}
|
||||
// タンクに追加
|
||||
stockCount = Mathf.Min(x.space, remain);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
|
|
@ -16,6 +17,7 @@ public enum GameState
|
|||
public class PopcornGameManager : MonoBehaviour
|
||||
{
|
||||
public static readonly string CookingDataTag = "CookingData";
|
||||
public static readonly string PanDataTag = "PanData";
|
||||
public static readonly string CookingResultDataTag = "CookingResultData";
|
||||
// View
|
||||
[SerializeField] private PopcornGameView gameView;
|
||||
|
|
@ -101,6 +103,8 @@ public class PopcornGameManager : MonoBehaviour
|
|||
|
||||
private void ResetGame()
|
||||
{
|
||||
// フライパン設定
|
||||
var panData = LocalCacheManager.Load<PanData>(PanDataTag);
|
||||
cornManager.SetCornsActive(true);
|
||||
compositeDisposable.Clear();
|
||||
cornManager.Result.SkipLatestValueOnSubscribe()
|
||||
|
|
@ -112,8 +116,10 @@ public class PopcornGameManager : MonoBehaviour
|
|||
// リザルト表示遅延
|
||||
this.CallWaitForSeconds(1.2f, () =>
|
||||
{
|
||||
var recipe = LocalCacheManager.Load<RecipeData>(CookingDataTag);
|
||||
LocalCacheManager.Save(CookingResultDataTag, (recipe, new RarityData{id = 5, rate = 120}, result, new Action(() => cornManager.SetCornsActive(false))));
|
||||
var rarityList = SpreadsheetDataManager.Instance.GetBaseDataList<RarityData>(Const.RarityDataSheet);
|
||||
var rarityData = rarityList.First(data => data.Rarity == panData.Rarity);
|
||||
var productData = LocalCacheManager.Load<ProductData>(CookingDataTag);
|
||||
LocalCacheManager.Save(CookingResultDataTag, (productData, rarityData, result, new Action(() => cornManager.SetCornsActive(false))));
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.CookingResults);
|
||||
});
|
||||
}).AddTo(compositeDisposable);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class DebugOptionManager : MonoBehaviour
|
|||
gameData.ShopStock.AddRange(Enumerable.Repeat(2, 10).ToList());
|
||||
gameData.StorageTanks = new List<StorageTank>
|
||||
{
|
||||
new StorageTank(){Id = 1, Capacity = 50, FlavorId = 1, Stocks = new List<ProductStockData>{new ProductStockData{Rarity = ProductRarity.Normal, Stock = 0}}},
|
||||
// new StorageTank(){Id = 1, Capacity = 50, FlavorId = 1, Stocks = new List<ProductStockData>{new ProductStockData{Rarity = ProductRarity.Normal, Stock = 0}}},
|
||||
new StorageTank(){Id = 2, Capacity = 50, FlavorId = 2, Stocks = new List<ProductStockData>
|
||||
{
|
||||
new ProductStockData{Rarity = ProductRarity.Normal, Stock = 1},
|
||||
|
|
@ -74,7 +74,9 @@ public class DebugOptionManager : MonoBehaviour
|
|||
}},
|
||||
new StorageTank(){Id = 3, Capacity = 50, FlavorId = 1, Stocks = new List<ProductStockData>
|
||||
{
|
||||
new ProductStockData{Rarity = ProductRarity.Copper, Stock = 1},
|
||||
new ProductStockData{Rarity = ProductRarity.Normal, Stock = 1},
|
||||
new ProductStockData{Rarity = ProductRarity.Yellow, Stock = 9},
|
||||
new ProductStockData{Rarity = ProductRarity.Copper, Stock = 5},
|
||||
new ProductStockData{Rarity = ProductRarity.Silver, Stock = 5},
|
||||
new ProductStockData{Rarity = ProductRarity.Gold, Stock = 10},
|
||||
new ProductStockData{Rarity = ProductRarity.Rainbow, Stock = 20},
|
||||
|
|
|
|||
|
|
@ -664,6 +664,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
lockPanel: {fileID: 3261803197014340250}
|
||||
lockPanelText: {fileID: 1139637482908115965}
|
||||
detailButton: {fileID: 8320108874302735811}
|
||||
flavorName: {fileID: 2929932626752093611}
|
||||
flavorPrice: {fileID: 2929932627123125673}
|
||||
|
|
@ -671,6 +672,7 @@ MonoBehaviour:
|
|||
flavor1AmountText: {fileID: 2929932625557648441}
|
||||
flavor2AmountText: {fileID: 367551539734858426}
|
||||
flavor2View: {fileID: 367551539495355422}
|
||||
lockPanelTextFormat: "\u5E97\u8217\u30EC\u30D9\u30EB{0}\u3067\u958B\u653E"
|
||||
--- !u!1 &2997770120253274331
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
|
@ -11,11 +12,38 @@ public class PanSelector : MonoBehaviour
|
|||
[SerializeField] private Text panName;
|
||||
[SerializeField] private Text panText;
|
||||
[SerializeField] private Image panIcon;
|
||||
public IReadOnlyReactiveProperty<PanData> SelectedPanData => selectedPanData;
|
||||
private readonly ReactiveProperty<PanData> selectedPanData = new ReactiveProperty<PanData>();
|
||||
private readonly ReactiveProperty<int> selectedIndex = new ReactiveProperty<int>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 所持フライパン読み込み
|
||||
// 設定中のフライパン表示
|
||||
// フライパン変更通知
|
||||
selectedPanData.AddTo(this);
|
||||
selectedIndex.AddTo(this);
|
||||
var panList = SpreadsheetDataManager.Instance.GetBaseDataList<PanData>(Const.PanDataSheet);
|
||||
var panCount = panList.Count;
|
||||
selectedPanData.Value = panList[0];
|
||||
selectedPanData.Subscribe(data =>
|
||||
{
|
||||
SetData(data);
|
||||
}).AddTo(this);
|
||||
selectedIndex.Subscribe(x =>
|
||||
{
|
||||
selectedPanData.Value = panList[x];
|
||||
}).AddTo(this);
|
||||
prevPanButton.OnClickAsObservable().Subscribe(_ =>
|
||||
{
|
||||
selectedIndex.Value = selectedIndex.Value == 0 ? panCount - 1 : selectedIndex.Value - 1;
|
||||
}).AddTo(this);
|
||||
nextPanButton.OnClickAsObservable().Subscribe(_ =>
|
||||
{
|
||||
selectedIndex.Value = selectedIndex.Value == panCount - 1 ? 0 : selectedIndex.Value + 1;
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private void SetData(PanData data)
|
||||
{
|
||||
panName.text = data.name;
|
||||
panText.text = data.text;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,57 +18,14 @@ public class RecipeData
|
|||
|
||||
public static List<RecipeData> GetAllRecipe()
|
||||
{
|
||||
return new List<RecipeData>
|
||||
return SpreadsheetDataManager.Instance.GetBaseDataList<ProductData>(Const.ProductDataSheet).Select(data => new RecipeData
|
||||
{
|
||||
new RecipeData
|
||||
{
|
||||
RecipeId = 1,
|
||||
Name = "塩コケコーン",
|
||||
Price = 5,
|
||||
Volume = 10,
|
||||
CornAmount = 150,
|
||||
Flavors = new List<(int id, int amount)>
|
||||
{
|
||||
(2, 1)
|
||||
}
|
||||
},
|
||||
new RecipeData
|
||||
{
|
||||
RecipeId = 2,
|
||||
Name = "キャラメルコケコーン",
|
||||
Price = 15,
|
||||
Volume = 10,
|
||||
CornAmount = 150,
|
||||
Flavors = new List<(int id, int amount)>
|
||||
{
|
||||
(7, 1)
|
||||
}
|
||||
},
|
||||
new RecipeData
|
||||
{
|
||||
RecipeId = 3,
|
||||
Name = "ブラックペッパーコケコーン",
|
||||
Price = 9,
|
||||
Volume = 10,
|
||||
CornAmount = 150,
|
||||
Flavors = new List<(int id, int amount)>
|
||||
{
|
||||
(3, 1)
|
||||
}
|
||||
},
|
||||
new RecipeData
|
||||
{
|
||||
RecipeId = 13,
|
||||
Name = "塩キャラメルコケコーン",
|
||||
Price = 19,
|
||||
Volume = 10,
|
||||
CornAmount = 150,
|
||||
Flavors = new List<(int id, int amount)>
|
||||
{
|
||||
(2, 1),
|
||||
(7, 1),
|
||||
}
|
||||
},
|
||||
};
|
||||
RecipeId = data.id,
|
||||
Name = data.name,
|
||||
Price = data.price,
|
||||
Volume = data.volume,
|
||||
CornAmount = data.MaterialList[0].amount,
|
||||
Flavors = data.MaterialList
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class RecipeDetailView : MonoBehaviour
|
|||
|
||||
private void Start()
|
||||
{
|
||||
var data = LocalCacheManager.Load<RecipeData>(PopcornGameManager.CookingDataTag);
|
||||
var data = LocalCacheManager.Load<ProductData>(PopcornGameManager.CookingDataTag);
|
||||
|
||||
cancelButton.OnClickAsObservable().Subscribe(_ =>
|
||||
{
|
||||
|
|
@ -42,20 +42,17 @@ public class RecipeDetailView : MonoBehaviour
|
|||
|
||||
nextButton.OnClickAsObservable().Subscribe(_ =>
|
||||
{
|
||||
LocalCacheManager.Save(PopcornGameManager.PanDataTag, panSelector.SelectedPanData.Value);
|
||||
// 消費
|
||||
var gameData = GameDataManager.GameData;
|
||||
gameData.cornSeed -= data.CornAmount;
|
||||
var flavorIndex1 = gameData.Material.FindIndex(x => x.Id == data.Flavors[0].id);
|
||||
var stockMaterial1 = gameData.Material[flavorIndex1];
|
||||
stockMaterial1.Amount -= data.Flavors[0].amount;
|
||||
gameData.Material[flavorIndex1] = stockMaterial1;
|
||||
if (data.Flavors.Count == 2)
|
||||
gameData.cornSeed -= data.MaterialList[0].amount;
|
||||
var flavorIndex1 = gameData.Material.FindIndex(x => x.Id == data.MaterialList[1].id);
|
||||
gameData.Material[flavorIndex1].Amount -= data.MaterialList[1].amount;
|
||||
if (data.GetMaterialCount() == 3)
|
||||
{
|
||||
var flavorIndex2 = gameData.Material.FindIndex(x => x.Id == data.Flavors[1].id);
|
||||
var stockMaterial2 = gameData.Material[flavorIndex2];
|
||||
stockMaterial2.Amount -= data.Flavors[1].amount;
|
||||
gameData.Material[flavorIndex2] = stockMaterial2;
|
||||
var flavorIndex2 = gameData.Material.FindIndex(x => x.Id == data.MaterialList[2].id);
|
||||
gameData.Material[flavorIndex2].Amount -= data.MaterialList[2].amount;
|
||||
}
|
||||
|
||||
GameDataManager.SaveGameData();
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Cooking);
|
||||
}).AddTo(this);
|
||||
|
|
@ -69,37 +66,36 @@ public class RecipeDetailView : MonoBehaviour
|
|||
tankCaution.SetActive(!isPassedTank);
|
||||
}
|
||||
|
||||
public void SetRecipe(RecipeData data)
|
||||
public void SetRecipe(ProductData data)
|
||||
{
|
||||
var gameData = GameDataManager.GameData;
|
||||
|
||||
// 在庫
|
||||
// 店頭の空きがない
|
||||
var shopStock = gameData.ShopStock.FindAll(x => x == data.RecipeId).Count;
|
||||
var tankStock = gameData.StorageTanks.FindAll(x => x.FlavorId == data.RecipeId).Sum(x => x.Stock);
|
||||
var shopStock = gameData.ShopStock.FindAll(x => x == data.id).Count;
|
||||
var tankStock = gameData.StorageTanks.FindAll(x => x.FlavorId == data.id).Sum(x => x.Stock);
|
||||
flavorStock.text = string.Format(flavorStockFormat, shopStock + tankStock);
|
||||
flavorName.text = data.Name;
|
||||
flavorPrice.text = data.Price.ToString();
|
||||
cornAmountText.text = string.Format(cornAmountFormat, gameData.cornSeed, data.CornAmount);
|
||||
flavorName.text = data.name;
|
||||
flavorPrice.text = data.price.ToString();
|
||||
cornAmountText.text = string.Format(cornAmountFormat, gameData.cornSeed, data.MaterialList[0].amount);
|
||||
|
||||
var flavor1Amount = 0;
|
||||
var flavorIndex1 = gameData.Material.FindIndex(x => x.Id == data.Flavors[0].id);
|
||||
var flavorIndex1 = gameData.Material.FindIndex(x => x.Id == data.MaterialList[1].id);
|
||||
if (flavorIndex1 != -1)
|
||||
{
|
||||
flavor1Amount = gameData.Material[flavorIndex1].Amount;
|
||||
}
|
||||
flavor1AmountText.text = string.Format(flavorAmountFormat, flavor1Amount, data.Flavors[0].amount);
|
||||
flavor1AmountText.text = string.Format(flavorAmountFormat, flavor1Amount, data.MaterialList[1].amount);
|
||||
|
||||
var flavor2Amount = 0;
|
||||
if (data.Flavors.Count == 2)
|
||||
if (data.GetMaterialCount() == 3)
|
||||
{
|
||||
var flavorIndex2 = gameData.Material.FindIndex(x => x.Id == data.Flavors[1].id);
|
||||
var flavorIndex2 = gameData.Material.FindIndex(x => x.Id == data.MaterialList[2].id);
|
||||
if (flavorIndex2 != -1)
|
||||
{
|
||||
flavor2Amount = gameData.Material[flavorIndex2].Amount;
|
||||
}
|
||||
flavor2View.SetActive(true);
|
||||
flavor2AmountText.text = string.Format(flavorAmountFormat, flavor2Amount, data.Flavors[1].amount);
|
||||
flavor2AmountText.text = string.Format(flavorAmountFormat, flavor2Amount, data.MaterialList[2].amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -107,25 +103,25 @@ public class RecipeDetailView : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private bool CheckAmount(RecipeData data)
|
||||
private bool CheckAmount(ProductData data)
|
||||
{
|
||||
var flag = true;
|
||||
var gameData = GameDataManager.GameData;
|
||||
if (gameData.cornSeed < data.CornAmount)
|
||||
if (gameData.cornSeed < data.MaterialList[0].amount)
|
||||
{
|
||||
flag = false;
|
||||
cornAmountText.color = Color.red;
|
||||
}
|
||||
var flavorIndex1 = gameData.Material.FindIndex(x => x.Id == data.Flavors[0].id);
|
||||
if (flavorIndex1 == -1 || gameData.Material[flavorIndex1].Amount < data.Flavors[0].amount)
|
||||
var flavorIndex1 = gameData.Material.FindIndex(x => x.Id == data.MaterialList[1].id);
|
||||
if (flavorIndex1 == -1 || gameData.Material[flavorIndex1].Amount < data.MaterialList[1].amount)
|
||||
{
|
||||
flag = false;
|
||||
flavor1AmountText.color = Color.red;
|
||||
}
|
||||
if (data.Flavors.Count == 2)
|
||||
if (data.GetMaterialCount() == 3)
|
||||
{
|
||||
var flavorIndex2 = gameData.Material.FindIndex(x => x.Id == data.Flavors[1].id);
|
||||
if (flavorIndex2 == -1 || gameData.Material[flavorIndex2].Amount < data.Flavors[1].amount)
|
||||
var flavorIndex2 = gameData.Material.FindIndex(x => x.Id == data.MaterialList[2].id);
|
||||
if (flavorIndex2 == -1 || gameData.Material[flavorIndex2].Amount < data.MaterialList[2].amount)
|
||||
{
|
||||
flag = false;
|
||||
flavor2AmountText.color = Color.red;
|
||||
|
|
@ -134,18 +130,18 @@ public class RecipeDetailView : MonoBehaviour
|
|||
return flag;
|
||||
}
|
||||
|
||||
private bool CheckTank(RecipeData data)
|
||||
private bool CheckTank(ProductData data)
|
||||
{
|
||||
var gameData = GameDataManager.GameData;
|
||||
// 店頭の空き確認
|
||||
if (data.Volume <= Market.ShopStockCount - gameData.ShopStock.Count)
|
||||
if (data.volume <= Market.ShopStockCount - gameData.ShopStock.Count)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 空のタンク、同じフレーバーのタンク空き確認
|
||||
return gameData.StorageTanks
|
||||
.Where(tank => tank.IsEmpty || tank.FlavorId == data.RecipeId && !tank.IsFull)
|
||||
.Any(tank => data.Volume <= tank.Capacity - tank.Stock);
|
||||
.Where(tank => tank.IsEmpty || tank.FlavorId == data.id && !tank.IsFull)
|
||||
.Any(tank => data.volume <= tank.Capacity - tank.Stock);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,17 +21,18 @@ public class RecipeSelectDialog : MonoBehaviour
|
|||
// レシピ一覧生成
|
||||
var content = scrollRect.content;
|
||||
content.transform.DestroyAllChildrens();
|
||||
foreach (var recipeData in RecipeData.GetAllRecipe())
|
||||
var data = SpreadsheetDataManager.Instance.GetBaseDataList<ProductData>(Const.ProductDataSheet);
|
||||
foreach (var productData in data)
|
||||
{
|
||||
var view = Instantiate(recipePrefab, content.transform);
|
||||
view.SetRecipe(recipeData);
|
||||
view.SetRecipe(productData);
|
||||
// 所持レシピ確認
|
||||
if (GameDataManager.GameData.MyRecipes.Contains(recipeData.RecipeId))
|
||||
if (GameDataManager.GameData.MyRecipes.Contains(productData.id))
|
||||
{
|
||||
view.SetLockPanel(false);
|
||||
view.RecipeClickObservable.Subscribe(_ =>
|
||||
{
|
||||
LocalCacheManager.Save(PopcornGameManager.CookingDataTag, recipeData);
|
||||
LocalCacheManager.Save(PopcornGameManager.CookingDataTag, productData);
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.RecipeChoice);
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -6,6 +7,7 @@ using UnityEngine.UI;
|
|||
public class RecipeView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject lockPanel;
|
||||
[SerializeField] private Text lockPanelText;
|
||||
[SerializeField] private Button detailButton;
|
||||
[SerializeField] private Text flavorName;
|
||||
[SerializeField] private Text flavorPrice;
|
||||
|
|
@ -14,27 +16,38 @@ public class RecipeView : MonoBehaviour
|
|||
[SerializeField] private Text flavor2AmountText;
|
||||
[SerializeField] private GameObject flavor2View;
|
||||
private static readonly string amountFormat = "x{0}";
|
||||
private static readonly string lockPanelTextFormat = "店舗レベル{0}で開放";
|
||||
private static readonly string lockPanelTextShopFormat = "仕入れから購入可能";
|
||||
public IObservable<Unit> RecipeClickObservable => detailButton.OnClickAsObservable().TakeUntilDestroy(this);
|
||||
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetRecipe(RecipeData data)
|
||||
public void SetRecipe(ProductData data)
|
||||
{
|
||||
flavorName.text = data.Name;
|
||||
flavorPrice.text = data.Price.ToString();
|
||||
cornAmountText.text = string.Format(amountFormat, data.CornAmount);
|
||||
flavor1AmountText.text = string.Format(amountFormat, data.Flavors[0].amount);
|
||||
if (data.Flavors.Count == 2)
|
||||
flavorName.text = data.name;
|
||||
flavorPrice.text = data.price.ToString();
|
||||
cornAmountText.text = string.Format(amountFormat, data.MaterialList[0].amount);
|
||||
flavor1AmountText.text = string.Format(amountFormat, data.MaterialList[1].amount);
|
||||
if (data.GetMaterialCount() == 3)
|
||||
{
|
||||
flavor2View.SetActive(true);
|
||||
flavor2AmountText.text = string.Format(amountFormat, data.Flavors[1].amount);
|
||||
flavor2AmountText.text = string.Format(amountFormat, data.MaterialList[2].amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
flavor2View.SetActive(false);
|
||||
}
|
||||
|
||||
if (data.shopLevel == Const.SpecialShopLevel)
|
||||
{
|
||||
lockPanelText.text = string.Format(lockPanelTextShopFormat, data.shopLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
lockPanelText.text = string.Format(lockPanelTextFormat, data.shopLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLockPanel(bool hasRecipe)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ public static class Const {
|
|||
|
||||
// parameter
|
||||
public static readonly int DefaultPanId = 1;
|
||||
public static readonly int SpecialShopLevel = 9999;
|
||||
public static readonly int NotSetMaterialId = 0;
|
||||
|
||||
// tag
|
||||
public static readonly string GameDataTag = "GameData";
|
||||
|
|
|
|||
Loading…
Reference in New Issue