From 444a04ee6f84e5dd7132c807e1907efe257e922f Mon Sep 17 00:00:00 2001 From: kimura Date: Tue, 28 Sep 2021 12:51:39 +0900 Subject: [PATCH] rename/refactor --- .../Scenes/CornField/Scripts/CornField.cs | 67 ++++--------------- .../CornField/Scripts/FacilityExpantion.cs | 4 +- .../Assets/MyGame/Scripts/GameDataManager.cs | 2 +- 3 files changed, 17 insertions(+), 56 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs index 8e325005..47d1093b 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs @@ -64,16 +64,20 @@ public class CornField : MonoBehaviour // セーブデータから畑を復元 availableLines.Clear(); - foreach (var line in gameData.PlantLines) + foreach (var lineData in gameData.PlantLineDataList) { - var plantLine = plantLines.First(x => x.LineName == line.Type); + var plantLine = plantLines.First(x => x.LineName == lineData.Type); plantLine.gameObject.SetActive(true); - plantLine.SetFieldLevel(line.Level); + plantLine.SetFieldLevel(lineData.Level); availableLines.Add(plantLine); // コーン株の進行度初回データ作成 - if (!gameData.SeedlingDataList.Exists(x => x.type == line.Type)) + if (!gameData.SeedlingDataList.Exists(x => x.type == lineData.Type)) { - gameData.SeedlingDataList.Add(GenerateSeedlingData(line.Type, line.Level)); + gameData.SeedlingDataList.Add(new SeedlingProgressData + { + type = lineData.Type, + Seedlings = Enumerable.Repeat(GenerateSeedlingGene(lineData.Level), plantLine.Seedlings.Count).ToList() + }); } } GameDataManager.SaveGameData(); @@ -211,10 +215,9 @@ public class CornField : MonoBehaviour private void SetData() { var gameData = GameDataManager.GameData; - // 解放済みの畑 - // if (gameData.PlantLines == null || gameData.PlantLines.Count == 0) + if (gameData.PlantLineDataList == null || gameData.PlantLineDataList.Count == 0) { - gameData.PlantLines = new List + gameData.PlantLineDataList = new List { new PlantLineData(PlantLineType.Top, CornFieldRank.Rank3), new PlantLineData(PlantLineType.Center, CornFieldRank.Rank1), @@ -225,53 +228,11 @@ public class CornField : MonoBehaviour { gameData.SeedlingDataList = new List(); } - // 収穫機レベル - Debug.Log($"machineLevel {gameData.MachineLevel}"); - GameDataManager.SaveGameData(); - } - - private SeedlingProgressData GenerateSeedlingData(PlantLineType type, CornFieldRank level) - { - switch (type) + if (gameData.MachineLevel == 0) { - case PlantLineType.Top: - return new SeedlingProgressData - { - type = PlantLineType.Top, - Seedlings = new List() - { - GenerateSeedlingGene(level), - GenerateSeedlingGene(level), - GenerateSeedlingGene(level), - GenerateSeedlingGene(level), - } - }; - case PlantLineType.Center: - return new SeedlingProgressData - { - type = PlantLineType.Center, - Seedlings = new List() - { - GenerateSeedlingGene(level), - GenerateSeedlingGene(level), - GenerateSeedlingGene(level), - } - }; - case PlantLineType.Bottom: - return new SeedlingProgressData - { - type = PlantLineType.Bottom, - Seedlings = new List() - { - GenerateSeedlingGene(level), - GenerateSeedlingGene(level), - GenerateSeedlingGene(level), - GenerateSeedlingGene(level), - } - }; - default: - throw new ArgumentOutOfRangeException(nameof(type), type, null); + gameData.MachineLevel = 1; } + GameDataManager.SaveGameData(); } private SeedlingData GenerateSeedlingGene(CornFieldRank level) diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/FacilityExpantion.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/FacilityExpantion.cs index f7b0ee8e..2f1618b5 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/FacilityExpantion.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/FacilityExpantion.cs @@ -26,12 +26,12 @@ public class FacilityExpantion : MonoBehaviour // 適用できるかどうか判定 foreach (var item in items) { - if (!GameDataManager.GameData.PlantLines.Exists(x => x.Type == item.Type)) + if (!GameDataManager.GameData.PlantLineDataList.Exists(x => x.Type == item.Type)) { item.SetItem(false, CornFieldRank.Rank1); return; } - item.SetItem(true, GameDataManager.GameData.PlantLines.First(x => x.Type == item.Type).Level); + item.SetItem(true, GameDataManager.GameData.PlantLineDataList.First(x => x.Type == item.Type).Level); item.ClickObservable.Subscribe(_ => { // 購入時コイン比較後、コイン減算(ここコイン増加と処理がかぶるとややこしい(Batchとかで処理するといいかも diff --git a/popcorn/Assets/MyGame/Scripts/GameDataManager.cs b/popcorn/Assets/MyGame/Scripts/GameDataManager.cs index 7b59f3f3..35f6199d 100644 --- a/popcorn/Assets/MyGame/Scripts/GameDataManager.cs +++ b/popcorn/Assets/MyGame/Scripts/GameDataManager.cs @@ -53,7 +53,7 @@ public sealed class GameData { // public bool isRandomAvatar; // CornField [DataMember(Name = "Data12")] - public List PlantLines = new List(); + public List PlantLineDataList = new List(); // [DataMember(Name = "Data13")] [DataMember(Name = "Data14")] public int MachineLevel = 1;