Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop
This commit is contained in:
commit
bc94654ff2
|
|
@ -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,22 +51,17 @@ public class CornField : MonoBehaviour
|
|||
}
|
||||
|
||||
// セーブデータから畑を復元
|
||||
// gameData.SeedlingDataList = new List<SeedlingProgressData>();
|
||||
if (gameData.SeedlingDataList == null || gameData.SeedlingDataList.Count == 0)
|
||||
{
|
||||
gameData.SeedlingDataList = new List<SeedlingProgressData>();
|
||||
}
|
||||
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();
|
||||
|
|
@ -98,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;
|
||||
|
|
@ -134,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);
|
||||
|
|
@ -153,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;
|
||||
}
|
||||
}
|
||||
|
|
@ -164,6 +142,32 @@ public class CornField : MonoBehaviour
|
|||
}).AddTo(compositeDisposable);
|
||||
}
|
||||
|
||||
private void SetData()
|
||||
{
|
||||
var gameData = GameDataManager.GameData;
|
||||
// 解放済みの畑
|
||||
gameData.PlantLines = new List<PlantLineData>
|
||||
{
|
||||
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<PlantLineData>
|
||||
{
|
||||
new PlantLineData(PlantLineType.Center, CornFieldRank.Rank1),
|
||||
};
|
||||
}
|
||||
if (gameData.SeedlingDataList == null || gameData.SeedlingDataList.Count == 0)
|
||||
{
|
||||
gameData.SeedlingDataList = new List<SeedlingProgressData>();
|
||||
}
|
||||
// 収穫機レベル
|
||||
gameData.MachineLevel = 1;
|
||||
GameDataManager.SaveGameData();
|
||||
}
|
||||
|
||||
private SeedlingProgressData GenerateSeedlingData(PlantLineType type, CornFieldRank level)
|
||||
{
|
||||
switch (type)
|
||||
|
|
@ -172,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<SeedlingData>()
|
||||
{
|
||||
GenerateSeedlingGene(level),
|
||||
GenerateSeedlingGene(level),
|
||||
|
|
@ -184,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<SeedlingData>()
|
||||
{
|
||||
GenerateSeedlingGene(level),
|
||||
GenerateSeedlingGene(level),
|
||||
|
|
@ -195,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<SeedlingData>()
|
||||
{
|
||||
GenerateSeedlingGene(level),
|
||||
GenerateSeedlingGene(level),
|
||||
|
|
@ -208,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)
|
||||
|
|
|
|||
|
|
@ -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とかで処理するといいかも
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 75f5330a759540399e645faea986ac87
|
||||
timeCreated: 1629089702
|
||||
|
|
@ -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<SeedlingData> Seedlings;
|
||||
}
|
||||
|
|
@ -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<MaterialData>
|
||||
{
|
||||
(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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<PlantLineData> PlantLines = new List<PlantLineData>();
|
||||
// [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<MaterialData> Material = new List<MaterialData>();
|
||||
// 店頭ポップコーン在庫
|
||||
[DataMember(Name = "Data19")]
|
||||
[DataMember(Name = "Data19")]
|
||||
private int[] shopStock;
|
||||
public List<int> ShopStock;
|
||||
// タンクポップコーン在庫
|
||||
[DataMember(Name = "Data20")]
|
||||
|
|
@ -111,6 +111,7 @@ public sealed class GameData {
|
|||
// avatarIdList = avatarIdArray == null ? new List<int>() : avatarIdArray.ToList();
|
||||
// newAvatarIdList = newAvatarIdArray == null ? new List<int>() : newAvatarIdArray.ToList();
|
||||
// lastAdRewardTimeList = lastAdRewardTimeArray == null ? new List<long>() : lastAdRewardTimeArray.ToList();
|
||||
ShopStock = shopStock?.ToList() ?? new List<int>();
|
||||
}
|
||||
private Dictionary<int, int> ArrayToDictionary(KeyValueOfintint[] array){
|
||||
var dictionary = new Dictionary<int, int>();
|
||||
|
|
@ -125,6 +126,7 @@ public sealed class GameData {
|
|||
// avatarIdArray = avatarIdList.ToArray();
|
||||
// newAvatarIdArray = newAvatarIdList.ToArray();
|
||||
// lastAdRewardTimeArray = lastAdRewardTimeList.ToArray();
|
||||
shopStock = ShopStock.ToArray();
|
||||
}
|
||||
private KeyValueOfintint[] DictionaryToArray(Dictionary<int, int> dictionary){
|
||||
var array = new KeyValueOfintint[dictionary.Count];
|
||||
|
|
|
|||
Loading…
Reference in New Issue