From b7967a58aac1c5f574d45349c7d66b662eefbd1c Mon Sep 17 00:00:00 2001 From: kimura Date: Mon, 16 Aug 2021 13:29:27 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=83=96=E6=A7=8B?= =?UTF-8?q?=E9=80=A0=E5=A4=89=E6=9B=B4=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/CornField/Scripts/CornField.cs | 10 ++++---- .../CornField/Scripts/FacilityExpantion.cs | 4 ++-- .../Scenes/Main/Scripts/KitchenManager.cs | 12 +++++----- .../Scenes/recipe/Scripts/RecipeDetailView.cs | 24 +++++++++---------- .../Assets/MyGame/Scripts/GameDataManager.cs | 12 ++++++---- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs index 10a4e60b..dbdec506 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs @@ -74,16 +74,16 @@ public class CornField : MonoBehaviour gameData.SeedlingDataList = new List(); } availableLines.Clear(); - foreach (var line in gameData.PlantLineTypes) + foreach (var line in gameData.PlantLines) { - var plantLine = plantLines.First(x => x.LineName == line.type); + var plantLine = plantLines.First(x => x.LineName == line.Type); plantLine.gameObject.SetActive(true); - plantLine.SetFieldLevel(line.level); + plantLine.SetFieldLevel(line.Level); availableLines.Add(plantLine); // コーン株の進行度初回データ作成 - if (!gameData.SeedlingDataList.Exists(x => x.type == line.type)) + if (!gameData.SeedlingDataList.Exists(x => x.type == line.Type)) { - gameData.SeedlingDataList.Add(GenerateSeedlingData(line.type, line.level)); + gameData.SeedlingDataList.Add(GenerateSeedlingData(line.Type, line.Level)); } } GameDataManager.SaveGameData(); diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/FacilityExpantion.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/FacilityExpantion.cs index 515585f5..f7b0ee8e 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.PlantLineTypes.Exists(x => x.type == item.Type)) + if (!GameDataManager.GameData.PlantLines.Exists(x => x.Type == item.Type)) { item.SetItem(false, CornFieldRank.Rank1); return; } - item.SetItem(true, GameDataManager.GameData.PlantLineTypes.First(x => x.type == item.Type).level); + item.SetItem(true, GameDataManager.GameData.PlantLines.First(x => x.Type == item.Type).Level); item.ClickObservable.Subscribe(_ => { // 購入時コイン比較後、コイン減算(ここコイン増加と処理がかぶるとややこしい(Batchとかで処理するといいかも diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs index 5c08d8d8..17768392 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/KitchenManager.cs @@ -58,20 +58,20 @@ public class KitchenManager : MonoBehaviour // 所持素材 if (gameData.Material == null || gameData.Material.Count == 0) { - gameData.Material = new List<(int id, int amount)> + gameData.Material = new List { - (1, 10), - (2, 10), - (6, 10), + new MaterialData(1, 10), + new MaterialData(2, 10), + new MaterialData(6, 10), }; } // 素材の補充 - var materialStockIndex = gameData.Material.FindIndex(x => x.amount == 0); + var materialStockIndex = gameData.Material.FindIndex(x => x.Amount == 0); if (materialStockIndex != -1) { var temp = gameData.Material[materialStockIndex]; - temp.amount += 10; + temp.Amount += 10; gameData.Material[materialStockIndex] = temp; } diff --git a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs index 2005421d..4f10c08d 100644 --- a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs +++ b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs @@ -48,15 +48,15 @@ public class RecipeDetailView : MonoBehaviour { var gameData = GameDataManager.GameData; gameData.cornSeed -= data.CornAmount; - var flavorIndex1 = gameData.Material.FindIndex(x => x.id == data.Flavors[0].id); + var flavorIndex1 = gameData.Material.FindIndex(x => x.Id == data.Flavors[0].id); var stockMaterial1 = gameData.Material[flavorIndex1]; - stockMaterial1.amount -= data.Flavors[0].amount; + stockMaterial1.Amount -= data.Flavors[0].amount; gameData.Material[flavorIndex1] = stockMaterial1; if (data.Flavors.Count == 2) { - var flavorIndex2 = gameData.Material.FindIndex(x => x.id == data.Flavors[1].id); + var flavorIndex2 = gameData.Material.FindIndex(x => x.Id == data.Flavors[1].id); var stockMaterial2 = gameData.Material[flavorIndex2]; - stockMaterial2.amount -= data.Flavors[1].amount; + stockMaterial2.Amount -= data.Flavors[1].amount; gameData.Material[flavorIndex2] = stockMaterial2; } @@ -85,20 +85,20 @@ public class RecipeDetailView : MonoBehaviour cornAmountText.text = string.Format(cornAmountFormat, gameData.cornSeed, data.CornAmount); var flavor1Amount = 0; - var flavorIndex1 = gameData.Material.FindIndex(x => x.id == data.Flavors[0].id); + var flavorIndex1 = gameData.Material.FindIndex(x => x.Id == data.Flavors[0].id); if (flavorIndex1 != -1) { - flavor1Amount = gameData.Material[flavorIndex1].amount; + flavor1Amount = gameData.Material[flavorIndex1].Amount; } flavor1AmountText.text = string.Format(flavorAmountFormat, flavor1Amount, data.Flavors[0].amount); var flavor2Amount = 0; if (data.Flavors.Count == 2) { - var flavorIndex2 = gameData.Material.FindIndex(x => x.id == data.Flavors[1].id); + var flavorIndex2 = gameData.Material.FindIndex(x => x.Id == data.Flavors[1].id); if (flavorIndex2 != -1) { - flavor2Amount = gameData.Material[flavorIndex2].amount; + flavor2Amount = gameData.Material[flavorIndex2].Amount; } flavor2View.SetActive(true); flavor2AmountText.text = string.Format(flavorAmountFormat, flavor2Amount, data.Flavors[1].amount); @@ -118,16 +118,16 @@ public class RecipeDetailView : MonoBehaviour 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.Flavors[0].id); + if (flavorIndex1 == -1 || gameData.Material[flavorIndex1].Amount < data.Flavors[0].amount) { flag = false; flavor1AmountText.color = Color.red; } if (data.Flavors.Count == 2) { - 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.Flavors[1].id); + if (flavorIndex2 == -1 || gameData.Material[flavorIndex2].Amount < data.Flavors[1].amount) { flag = false; flavor2AmountText.color = Color.red; diff --git a/popcorn/Assets/MyGame/Scripts/GameDataManager.cs b/popcorn/Assets/MyGame/Scripts/GameDataManager.cs index 30b4bf50..150aeca8 100644 --- a/popcorn/Assets/MyGame/Scripts/GameDataManager.cs +++ b/popcorn/Assets/MyGame/Scripts/GameDataManager.cs @@ -53,9 +53,8 @@ public sealed class GameData { // public bool isRandomAvatar; // CornField [DataMember(Name = "Data12")] - public List<(PlantLineType type, CornFieldRank level)> PlantLineTypes; - [DataMember(Name = "Data13")] - public CornFieldRank FieldLevel = CornFieldRank.Rank1; + public List PlantLines = new List(); + // [DataMember(Name = "Data13")] [DataMember(Name = "Data14")] public int MachineLevel = 1; [DataMember(Name = "Data15")] @@ -68,9 +67,10 @@ public sealed class GameData { public int[] MyRecipes; // 所持素材 [DataMember(Name = "Data18")] - public List<(int id, int amount)> Material = new List<(int id, int amount)>(); + public List Material = new List(); // 店頭ポップコーン在庫 - [DataMember(Name = "Data19")] + [DataMember(Name = "Data19")] + private int[] shopStock; public List ShopStock; // タンクポップコーン在庫 [DataMember(Name = "Data20")] @@ -111,6 +111,7 @@ public sealed class GameData { // avatarIdList = avatarIdArray == null ? new List() : avatarIdArray.ToList(); // newAvatarIdList = newAvatarIdArray == null ? new List() : newAvatarIdArray.ToList(); // lastAdRewardTimeList = lastAdRewardTimeArray == null ? new List() : lastAdRewardTimeArray.ToList(); + ShopStock = shopStock?.ToList() ?? new List(); } private Dictionary ArrayToDictionary(KeyValueOfintint[] array){ var dictionary = new Dictionary(); @@ -125,6 +126,7 @@ public sealed class GameData { // avatarIdArray = avatarIdList.ToArray(); // newAvatarIdArray = newAvatarIdList.ToArray(); // lastAdRewardTimeArray = lastAdRewardTimeList.ToArray(); + shopStock = ShopStock.ToArray(); } private KeyValueOfintint[] DictionaryToArray(Dictionary dictionary){ var array = new KeyValueOfintint[dictionary.Count]; From 4a7295aef970a2510d19555dd9792695f351024e Mon Sep 17 00:00:00 2001 From: kimura Date: Mon, 16 Aug 2021 13:29:46 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/CornField/Scripts/CornField.cs | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs index dbdec506..fd0f2158 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs @@ -42,24 +42,7 @@ public class CornField : MonoBehaviour // データ var gameData = GameDataManager.GameData; CoinManager.Instance.ChangeCoin(gameData.coin); - // 解放済みの畑 - gameData.PlantLineTypes = new List<(PlantLineType type, CornFieldRank level)>() - { - (PlantLineType.Top, CornFieldRank.Rank2), - (PlantLineType.Center, CornFieldRank.Rank1), - (PlantLineType.Bottom, CornFieldRank.Rank3) - }; - if (gameData.PlantLineTypes == null || gameData.PlantLineTypes.Count == 0) - { - gameData.PlantLineTypes = new List<(PlantLineType type, CornFieldRank level)>() - { - (PlantLineType.Center, CornFieldRank.Rank1), - }; - } - // 畑の質 - // gameData.FieldLevel = CornFieldRank.Rank3; - // 収穫機レベル - gameData.MachineLevel = 1; + SetData(); // 畑リセット foreach (var line in plantLines) @@ -68,11 +51,6 @@ public class CornField : MonoBehaviour } // セーブデータから畑を復元 - // gameData.SeedlingDataList = new List(); - if (gameData.SeedlingDataList == null || gameData.SeedlingDataList.Count == 0) - { - gameData.SeedlingDataList = new List(); - } availableLines.Clear(); foreach (var line in gameData.PlantLines) { @@ -164,6 +142,32 @@ public class CornField : MonoBehaviour }).AddTo(compositeDisposable); } + private void SetData() + { + var gameData = GameDataManager.GameData; + // 解放済みの畑 + gameData.PlantLines = new List + { + new PlantLineData(PlantLineType.Top, CornFieldRank.Rank2), + new PlantLineData(PlantLineType.Center, CornFieldRank.Rank1), + new PlantLineData(PlantLineType.Bottom, CornFieldRank.Rank3) + }; + if (gameData.PlantLines == null || gameData.PlantLines.Count == 0) + { + gameData.PlantLines = new List + { + new PlantLineData(PlantLineType.Center, CornFieldRank.Rank1), + }; + } + if (gameData.SeedlingDataList == null || gameData.SeedlingDataList.Count == 0) + { + gameData.SeedlingDataList = new List(); + } + // 収穫機レベル + gameData.MachineLevel = 1; + GameDataManager.SaveGameData(); + } + private SeedlingProgressData GenerateSeedlingData(PlantLineType type, CornFieldRank level) { switch (type) From 126b301abc919bbc9bf25a5677dc7cd55446c290 Mon Sep 17 00:00:00 2001 From: kimura Date: Mon, 16 Aug 2021 14:10:54 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E3=82=B7=E3=83=AA=E3=82=A2=E3=83=A9?= =?UTF-8?q?=E3=82=A4=E3=82=BA=E3=82=A8=E3=83=A9=E3=83=BC=E8=A7=A3=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/CornField/Scripts/CornField.cs | 20 +++++++++---------- .../Scenes/CornField/Scripts/SeedlingData.cs | 19 ++++++++++++++++++ .../CornField/Scripts/SeedlingData.cs.meta | 3 +++ .../CornField/Scripts/SeedlingProgressData.cs | 2 +- 4 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingData.cs create mode 100644 popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingData.cs.meta diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs index fd0f2158..ceb56ead 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs @@ -76,12 +76,12 @@ public class CornField : MonoBehaviour { var index = i; i++; - seedling.SetSeedlingGene(lineData.Seedlings[index].firstTime, lineData.Seedlings[index].period, lineData.Seedlings[index].level); + seedling.SetSeedlingGene(lineData.Seedlings[index].FirstTime, lineData.Seedlings[index].Period, lineData.Seedlings[index].Level); seedling.Harvested.Subscribe(_ => { // 収穫 VibrationManager.Instance.PlayVibrationOnce(); - var harvestCount = GetHarvestCount(lineData.Seedlings[index].level); + var harvestCount = GetHarvestCount(lineData.Seedlings[index].Level); var harvestedCorn = GetHarvestedCornCount(gameData.MachineLevel); gameData.cornSeed += harvestedCorn * harvestCount; var seedlingTransform = seedling.transform; @@ -112,7 +112,7 @@ public class CornField : MonoBehaviour } // 新しい苗 var newGene = GenerateSeedlingGene(line.FieldLevel); - seedling.SetSeedlingGene(newGene.firstTime, newGene.period, newGene.level); + seedling.SetSeedlingGene(newGene.FirstTime, newGene.Period, newGene.Level); gameData.SeedlingDataList[seedlingDataIndex].Seedlings[index] = newGene; GameDataManager.SaveGameData(); }).AddTo(compositeDisposable); @@ -131,8 +131,8 @@ public class CornField : MonoBehaviour if (Random.Range(0, 2) == 0) { var tmpData = gameData.SeedlingDataList[seedlingDataIndex].Seedlings[i]; - tmpData.firstTime = tmpData.firstTime.AddSeconds(-1); - line.Seedlings[i].PromoteGrowth(tmpData.firstTime); + tmpData.FirstTime = tmpData.FirstTime.AddSeconds(-1); + line.Seedlings[i].PromoteGrowth(tmpData.FirstTime); gameData.SeedlingDataList[seedlingDataIndex].Seedlings[i] = tmpData; } } @@ -176,7 +176,7 @@ public class CornField : MonoBehaviour return new SeedlingProgressData { type = PlantLineType.Top, - Seedlings = new List<(DateTime firstTime, int period, CornFieldRank rank)>() + Seedlings = new List() { GenerateSeedlingGene(level), GenerateSeedlingGene(level), @@ -188,7 +188,7 @@ public class CornField : MonoBehaviour return new SeedlingProgressData { type = PlantLineType.Center, - Seedlings = new List<(DateTime firstTime, int period, CornFieldRank rank)>() + Seedlings = new List() { GenerateSeedlingGene(level), GenerateSeedlingGene(level), @@ -199,7 +199,7 @@ public class CornField : MonoBehaviour return new SeedlingProgressData { type = PlantLineType.Bottom, - Seedlings = new List<(DateTime firstTime, int period, CornFieldRank rank)>() + Seedlings = new List() { GenerateSeedlingGene(level), GenerateSeedlingGene(level), @@ -212,10 +212,10 @@ public class CornField : MonoBehaviour } } - private (DateTime firstTime, int period, CornFieldRank level) GenerateSeedlingGene(CornFieldRank level) + private SeedlingData GenerateSeedlingGene(CornFieldRank level) { // return (DateTime.Now, Random.Range(minPeriod, maxPeriod + 1)); - return (DateTime.Now.AddSeconds(-Random.Range(0, 15)), 15 + Random.Range(0, 15), level); + return new SeedlingData(DateTime.Now.AddSeconds(-Random.Range(0, 15)), 15 + Random.Range(0, 15), level); } private int GetHarvestCount(CornFieldRank rank) diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingData.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingData.cs new file mode 100644 index 00000000..14b36cc2 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingData.cs @@ -0,0 +1,19 @@ +using System; + +public class SeedlingData +{ + public DateTime FirstTime; + public int Period; + public CornFieldRank Level; + + public SeedlingData() + { + } + + public SeedlingData(DateTime firstTime, int period, CornFieldRank level) + { + this.FirstTime = firstTime; + this.Period = period; + this.Level = level; + } +} diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingData.cs.meta b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingData.cs.meta new file mode 100644 index 00000000..fad64f87 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 75f5330a759540399e645faea986ac87 +timeCreated: 1629089702 \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingProgressData.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingProgressData.cs index fd6112c9..41a1eec3 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingProgressData.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/SeedlingProgressData.cs @@ -4,5 +4,5 @@ using System.Collections.Generic; public class SeedlingProgressData { public PlantLineType type; - public List<(DateTime firstTime, int period, CornFieldRank level)> Seedlings; + public List Seedlings; } \ No newline at end of file