diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs index 947462b3..0c0e1fcf 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using UniRx; using UnityEngine; using UnityEngine.UI; @@ -11,13 +12,76 @@ public class KitchenManager : MonoBehaviour // Start is called before the first frame update void Start() { + // レシピの表示 cookingButton.OnClickAsObservable().Subscribe(_ => { // TransitionManager.Instance.LoadScene(GameScenes.Cooking); TransitionManager.Instance.LoadSceneAdditive(GameScenes.Recipe); }); + // スプレッドシート対応 + // レシピIDが一覧で入っている + // データ var gameData = GameDataManager.GameData; CoinManager.Instance.ChangeCoin(gameData.coin); + + // 所持レシピ + gameData.MyRecipes = new[] + { + 1, + 2, + 13, + }; + + // 所持素材 + if (gameData.Material == null) + { + gameData.Material = new List<(int id, int amount)> + { + (1, 10), + (2, 10), + (6, 10), + }; + } + + // 素材の補充 + var materialStockIndex = gameData.Material.FindIndex(x => x.amount == 0); + if (materialStockIndex != -1) + { + var temp = gameData.Material[materialStockIndex]; + temp.amount += 10; + gameData.Material[materialStockIndex] = temp; + } + + // 店頭ストック + if (gameData.ShopStock == null) + { + gameData.ShopStock = new List(); + } + // 保存タンク + if (gameData.StorageTanks == null || gameData.StorageTanks.Count == 0) + { + gameData.StorageTanks = new List + { + new StorageTank + { + Id = 1, + Capacity = 50, + FlavorId = -1, + Stock = 0, + BonusRate = 0 + } + }; + } + GameDataManager.SaveGameData(); + + var shopStockString = ""; + foreach (var data in RecipeData.GetAllRecipe()) + { + var shopStockCount = gameData.ShopStock.FindAll(x => x == data.RecipeId).Count; + var tank = gameData.StorageTanks.FindAll(x => x.FlavorId == data.RecipeId).Sum(x => x.Stock); + shopStockString += $"{data.Name} shop:{shopStockCount} stock:{tank}\n"; + } + Debug.Log(shopStockString); } } diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/StorageTank.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/StorageTank.cs new file mode 100644 index 00000000..76349c4b --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/StorageTank.cs @@ -0,0 +1,11 @@ +using UnityEngine.Internal.VR; + +public class StorageTank +{ + // タンクID, タンク内のフレーバーID, フレーバーの個数 + public int Id; + public int Capacity; + public int FlavorId; + public int Stock; + public int BonusRate; +} \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/StorageTank.cs.meta b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/StorageTank.cs.meta new file mode 100644 index 00000000..7d10a682 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/StorageTank.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a842565a93614828bf8e8062120550f7 +timeCreated: 1628142406 \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeSelectDialog.cs b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeSelectDialog.cs index d2e824f0..49883323 100644 --- a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeSelectDialog.cs +++ b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeSelectDialog.cs @@ -18,24 +18,14 @@ public class RecipeSelectDialog : MonoBehaviour TransitionManager.Instance.UnloadScene(GameScenes.Recipe); }).AddTo(this); - // 所持レシピ取得 - var myRecipes = new[] - { - 1, - 2, - 13, - }; - - // 全レシピ - var allRecipe = RecipeData.GetAllRecipe(); - // レシピ一覧生成 content.transform.DestroyAllChildrens(); - foreach (var recipeData in allRecipe) + foreach (var recipeData in RecipeData.GetAllRecipe()) { var view = Instantiate(recipePrefab, content.transform); view.SetRecipe(recipeData); - if (myRecipes.Contains(recipeData.RecipeId)) + // 所持レシピ確認 + if (GameDataManager.GameData.MyRecipes.Contains(recipeData.RecipeId)) { view.SetLockPanel(false); view.RecipeClickObservable.Subscribe(_ => diff --git a/popcorn/Assets/MyGame/Scripts/GameDataManager.cs b/popcorn/Assets/MyGame/Scripts/GameDataManager.cs index ced32190..30b4bf50 100644 --- a/popcorn/Assets/MyGame/Scripts/GameDataManager.cs +++ b/popcorn/Assets/MyGame/Scripts/GameDataManager.cs @@ -51,6 +51,7 @@ public sealed class GameData { // public List newAvatarIdList; // [DataMember(Name = "Data11")] // public bool isRandomAvatar; + // CornField [DataMember(Name = "Data12")] public List<(PlantLineType type, CornFieldRank level)> PlantLineTypes; [DataMember(Name = "Data13")] @@ -59,7 +60,23 @@ public sealed class GameData { public int MachineLevel = 1; [DataMember(Name = "Data15")] public List SeedlingDataList = new List(); - [DataMember(Name = "Data16")] public int cornSeed; + [DataMember(Name = "Data16")] + public int cornSeed; + // Main + // 所持レシピ + [DataMember(Name = "Data17")] + public int[] MyRecipes; + // 所持素材 + [DataMember(Name = "Data18")] + public List<(int id, int amount)> Material = new List<(int id, int amount)>(); + // 店頭ポップコーン在庫 + [DataMember(Name = "Data19")] + public List ShopStock; + // タンクポップコーン在庫 + [DataMember(Name = "Data20")] + public List StorageTanks; + + // public void ChangeAvatar(AvatarData avatarData){ // newAvatarIdList.Remove(avatarData.id);