ワールド毎のデータ保存を追加
This commit is contained in:
parent
91585df658
commit
b5a48e23c5
|
|
@ -0,0 +1,11 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace MyGame.Scripts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 都市ごとのセーブデータ辞書
|
||||||
|
/// </summary>
|
||||||
|
public class CityGameDataDict : Dictionary<int, GameData>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0e93992cd9584288a973aca23bfc31fb
|
||||||
|
timeCreated: 1662021947
|
||||||
|
|
@ -10,6 +10,7 @@ public static class Const {
|
||||||
public static readonly int DefaultMachineLevel = 1;
|
public static readonly int DefaultMachineLevel = 1;
|
||||||
public static readonly int DefaultRecipeId = 1;
|
public static readonly int DefaultRecipeId = 1;
|
||||||
public static readonly int DefaultPanId = 1;
|
public static readonly int DefaultPanId = 1;
|
||||||
|
public static readonly int DefaultCityId = 1;
|
||||||
public static readonly int ShopTankId = 20;
|
public static readonly int ShopTankId = 20;
|
||||||
public static readonly int MaxShopLevel = 18;
|
public static readonly int MaxShopLevel = 18;
|
||||||
public static readonly int TankCapacity = 20;
|
public static readonly int TankCapacity = 20;
|
||||||
|
|
|
||||||
|
|
@ -186,8 +186,12 @@ public sealed class GameData {
|
||||||
[DataMember(Name = "Data65")]
|
[DataMember(Name = "Data65")]
|
||||||
public List<ScrollGameScoreData> ScrollGameStageScoreList;
|
public List<ScrollGameScoreData> ScrollGameStageScoreList;
|
||||||
|
|
||||||
|
// ワールドマップ追加(v1.7.0)
|
||||||
|
public int CurrentCityId; // 選択中の都市
|
||||||
|
public int[] Cities; // 解放済みの都市
|
||||||
|
public CityGameDataDict CityGameDataDict; // 都市ごとのデータ
|
||||||
|
|
||||||
// mission
|
// mission
|
||||||
[DataMember(Name = "Data1001")]
|
[DataMember(Name = "Data1001")]
|
||||||
public int TotalAddCoin { get; private set; }
|
public int TotalAddCoin { get; private set; }
|
||||||
[DataMember(Name = "Data1002")]
|
[DataMember(Name = "Data1002")]
|
||||||
|
|
@ -497,6 +501,16 @@ public sealed class GameData {
|
||||||
Const.ShopCustomizeDefaultSignBoardId,
|
Const.ShopCustomizeDefaultSignBoardId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CurrentCityId < 1)
|
||||||
|
{
|
||||||
|
CurrentCityId = 1;
|
||||||
|
}
|
||||||
|
// CityGameData
|
||||||
|
foreach (var cityGameData in CityGameDataDict.Values)
|
||||||
|
{
|
||||||
|
cityGameData.OnDeserialized();
|
||||||
|
}
|
||||||
|
|
||||||
// 追加した要素の初期化用
|
// 追加した要素の初期化用
|
||||||
// TODO Release前にまっさらにする
|
// TODO Release前にまっさらにする
|
||||||
|
|
@ -523,6 +537,7 @@ public sealed class GameData {
|
||||||
ShopCustomizeMyItems = ShopCustomizeMyItems ?? Array.Empty<int>();
|
ShopCustomizeMyItems = ShopCustomizeMyItems ?? Array.Empty<int>();
|
||||||
ScrollGamePlaceScoreList = ScrollGamePlaceScoreList ?? new List<ScrollGameScoreData>();
|
ScrollGamePlaceScoreList = ScrollGamePlaceScoreList ?? new List<ScrollGameScoreData>();
|
||||||
ScrollGameStageScoreList = ScrollGameStageScoreList ?? new List<ScrollGameScoreData>();
|
ScrollGameStageScoreList = ScrollGameStageScoreList ?? new List<ScrollGameScoreData>();
|
||||||
|
CityGameDataDict ??= new CityGameDataDict();
|
||||||
}
|
}
|
||||||
private Dictionary<int, int> ArrayToDictionary(KeyValueOfintint[] array){
|
private Dictionary<int, int> ArrayToDictionary(KeyValueOfintint[] array){
|
||||||
var dictionary = new Dictionary<int, int>();
|
var dictionary = new Dictionary<int, int>();
|
||||||
|
|
@ -539,6 +554,11 @@ public sealed class GameData {
|
||||||
// lastAdRewardTimeArray = lastAdRewardTimeList.ToArray();
|
// lastAdRewardTimeArray = lastAdRewardTimeList.ToArray();
|
||||||
achievedMission = AchievedMission.ToArray();
|
achievedMission = AchievedMission.ToArray();
|
||||||
deliveredOrder = DeliveredOrder.ToArray();
|
deliveredOrder = DeliveredOrder.ToArray();
|
||||||
|
// CityGameData
|
||||||
|
foreach (var cityGameData in CityGameDataDict.Values)
|
||||||
|
{
|
||||||
|
cityGameData.PreSerialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private KeyValueOfintint[] DictionaryToArray(Dictionary<int, int> dictionary){
|
private KeyValueOfintint[] DictionaryToArray(Dictionary<int, int> dictionary){
|
||||||
var array = new KeyValueOfintint[dictionary.Count];
|
var array = new KeyValueOfintint[dictionary.Count];
|
||||||
|
|
@ -692,6 +712,21 @@ public static class GameDataManager {
|
||||||
.Replace("KVOiIF", "KeyValueOfintInfiniteFloat");
|
.Replace("KVOiIF", "KeyValueOfintInfiniteFloat");
|
||||||
return StringExtensions.XMLToData<GameData>(str);
|
return StringExtensions.XMLToData<GameData>(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// CityIdから都市セーブデータを取得
|
||||||
|
/// はじめの都市のみ、別クラスにより透過的にGameData上の値を直接参照
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cityId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static GameData GetCityGameData(int cityId) =>
|
||||||
|
cityId switch
|
||||||
|
{
|
||||||
|
1 => GameData,
|
||||||
|
_ => GameData.CityGameDataDict[cityId]
|
||||||
|
};
|
||||||
|
|
||||||
|
public static GameData GetCurrentCityGameData() => GameData.CityGameDataDict[GameData.CurrentCityId];
|
||||||
|
|
||||||
#if UNITY_EDITOR || DEVELOPMENT_BUILD
|
#if UNITY_EDITOR || DEVELOPMENT_BUILD
|
||||||
public static void ResetData(){
|
public static void ResetData(){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue