保存形式変更(AOT対応
This commit is contained in:
parent
46701230e4
commit
d1974fc9ec
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace MyGame.Scripts
|
||||
{
|
||||
|
@ -7,9 +9,60 @@ namespace MyGame.Scripts
|
|||
/// </summary>
|
||||
public class CityGameDataDict : Dictionary<int, GameData>
|
||||
{
|
||||
public CityGameDataDict()
|
||||
{
|
||||
}
|
||||
|
||||
public CityGameDataDict(CityGameDataKeyValue[] keyValues)
|
||||
{
|
||||
if (keyValues is null) return;
|
||||
foreach (var pair in keyValues)
|
||||
{
|
||||
if (pair.Value is null) continue;
|
||||
Add(pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public CityGameDataKeyValue[] ToKeyValues() => this.Select(pair => new CityGameDataKeyValue(pair)).ToArray();
|
||||
|
||||
[DataContract]
|
||||
public sealed class CityGameDataKeyValue
|
||||
{
|
||||
[DataMember]
|
||||
public readonly int Key;
|
||||
[DataMember]
|
||||
public readonly GameData Value;
|
||||
|
||||
public CityGameDataKeyValue(KeyValuePair<int, GameData> pair) => (Key, Value) = (pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public class FundingDict : Dictionary<int, int>
|
||||
{
|
||||
public FundingDict()
|
||||
{
|
||||
}
|
||||
|
||||
public FundingDict(FundingKeyValue[] keyValues)
|
||||
{
|
||||
if (keyValues is null) return;
|
||||
foreach (var pair in keyValues)
|
||||
{
|
||||
Add(pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public FundingKeyValue[] ToKeyValues() => this.Select(pair => new FundingKeyValue(pair)).ToArray();
|
||||
|
||||
[DataContract]
|
||||
public sealed class FundingKeyValue
|
||||
{
|
||||
[DataMember]
|
||||
public readonly int Key;
|
||||
[DataMember]
|
||||
public readonly int Value;
|
||||
|
||||
public FundingKeyValue(KeyValuePair<int, int> pair) => (Key, Value) = (pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -194,10 +194,12 @@ public sealed class GameData {
|
|||
[DataMember(Name = "Data67")]
|
||||
public int CurrentCityId; // 選択中の都市
|
||||
[DataMember(Name = "Data68")]
|
||||
public CityGameDataDict.CityGameDataKeyValue[] CityGameDataKeyValues;
|
||||
public CityGameDataDict CityGameDataDict; // 都市ごとのデータ
|
||||
|
||||
// 資金調達
|
||||
[DataMember(Name = "Data69")]
|
||||
public FundingDict.FundingKeyValue[] FundingDictKeyValues;
|
||||
public FundingDict FundingDict; // 国ごとの調達済み資金
|
||||
[DataMember(Name = "Data70")]
|
||||
public bool IsFundingCompleted; // 調達完了フラグ
|
||||
|
@ -579,8 +581,8 @@ public sealed class GameData {
|
|||
ShopCustomizeMyItems = ShopCustomizeMyItems ?? Array.Empty<int>();
|
||||
ScrollGamePlaceScoreList = ScrollGamePlaceScoreList ?? new List<ScrollGameScoreData>();
|
||||
ScrollGameStageScoreList = ScrollGameStageScoreList ?? new List<ScrollGameScoreData>();
|
||||
CityGameDataDict ??= new CityGameDataDict();
|
||||
FundingDict ??= new FundingDict();
|
||||
CityGameDataDict = new CityGameDataDict(CityGameDataKeyValues);
|
||||
FundingDict = new FundingDict(FundingDictKeyValues);
|
||||
UsedItemCondition = usedItemCondition?.ToList() ?? new List<int>();
|
||||
}
|
||||
private Dictionary<int, int> ArrayToDictionary(KeyValueOfintint[] array){
|
||||
|
@ -599,6 +601,8 @@ public sealed class GameData {
|
|||
achievedMission = AchievedMission.ToArray();
|
||||
deliveredOrder = DeliveredOrder.ToArray();
|
||||
usedItemCondition = UsedItemCondition.ToArray();
|
||||
CityGameDataKeyValues = CityGameDataDict.ToKeyValues();
|
||||
FundingDictKeyValues = FundingDict.ToKeyValues();
|
||||
// CityGameData
|
||||
foreach (var cityGameData in CityGameDataDict.Values)
|
||||
{
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace MyGame.Scripts
|
|||
|
||||
public static GameData CreateCityData(int cityId)
|
||||
{
|
||||
if (cityId == Const.DefaultCityId) return GameDataManager.GameData;
|
||||
var dict = GameDataManager.GameData.CityGameDataDict;
|
||||
if (dict.ContainsKey(cityId))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue