8.30
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 存档中的角色。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct CharacterSave
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色 ID,对应 CharacterConfig.Id。
|
||||
/// </summary>
|
||||
public int characterId;
|
||||
|
||||
/// <summary>
|
||||
/// 武器栏物品 ID,0 表示空栏。
|
||||
/// </summary>
|
||||
public int weaponItemId;
|
||||
|
||||
/// <summary>
|
||||
/// 防具栏物品 ID,0 表示空栏。
|
||||
/// </summary>
|
||||
public int armorItemId;
|
||||
|
||||
public CharacterSave(int characterId, int weaponItemId, int armorItemId)
|
||||
{
|
||||
this.characterId = characterId;
|
||||
this.weaponItemId = weaponItemId;
|
||||
this.armorItemId = armorItemId;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75fd10c7585513846ab25372be0590b7
|
||||
timeCreated: 1528026162
|
||||
licenseType: Pro
|
||||
guid: 431023ff1288d45a9a8a3713cd38593e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 物品堆叠。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct ItemStack
|
||||
{
|
||||
/// <summary>
|
||||
/// 物品 ID,对应 ItemConfig.Id。
|
||||
/// </summary>
|
||||
public int itemId;
|
||||
|
||||
/// <summary>
|
||||
/// 数量,不超过配表 ItemConfig.StackLimit。
|
||||
/// </summary>
|
||||
public int count;
|
||||
|
||||
public ItemStack(int itemId, int count)
|
||||
{
|
||||
this.itemId = itemId;
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48bca35b200a444218a36ce1a49a76ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 战备配置。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public sealed class LoadoutSave
|
||||
{
|
||||
/// <summary>
|
||||
/// 出战角色 ID 及顺序,1~4 人,顺序决定同速时的行动次序。
|
||||
/// </summary>
|
||||
public int[] partyCharacterIds;
|
||||
|
||||
/// <summary>
|
||||
/// 携带进入地图的物品,开局时填充共享背包;首版无局内效果。
|
||||
/// </summary>
|
||||
public List<ItemStack> carriedItems;
|
||||
|
||||
/// <summary>
|
||||
/// 本局难度,对应 DifficultyConfig 主键。
|
||||
/// </summary>
|
||||
public DifficultyTier difficultyId;
|
||||
|
||||
/// <summary>
|
||||
/// 补齐缺失字段,避免反序列化后出现空引用。
|
||||
/// </summary>
|
||||
public void Normalize()
|
||||
{
|
||||
if (partyCharacterIds == null)
|
||||
{
|
||||
partyCharacterIds = System.Array.Empty<int>();
|
||||
}
|
||||
|
||||
if (carriedItems == null)
|
||||
{
|
||||
carriedItems = new List<ItemStack>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb9f7c288b0da4b88b83e82c87418550
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 已结束单局的结算记录。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct RunRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// 结算结果。
|
||||
/// </summary>
|
||||
public RunResultType outcome;
|
||||
|
||||
/// <summary>
|
||||
/// 本局难度。
|
||||
/// </summary>
|
||||
public DifficultyTier difficultyId;
|
||||
|
||||
/// <summary>
|
||||
/// 本局使用的随机数。
|
||||
/// </summary>
|
||||
public long seed;
|
||||
|
||||
/// <summary>
|
||||
/// 进入单局时间,Unix 毫秒。
|
||||
/// </summary>
|
||||
public long startedAt;
|
||||
|
||||
/// <summary>
|
||||
/// 结算时间,Unix 毫秒。
|
||||
/// </summary>
|
||||
public long endedAt;
|
||||
|
||||
public RunRecord(RunResultType outcome, DifficultyTier difficultyId, long seed, long startedAt, long endedAt)
|
||||
{
|
||||
this.outcome = outcome;
|
||||
this.difficultyId = difficultyId;
|
||||
this.seed = seed;
|
||||
this.startedAt = startedAt;
|
||||
this.endedAt = endedAt;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 591a205ef9e5c4f5f9fadcbc5b0db979
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,104 @@
|
||||
using System.Collections.Generic;
|
||||
using GameFramework;
|
||||
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏存档根数据。
|
||||
/// 对应 Docs/Tech/02_SaveData.md。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public sealed class SaveData
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前存档结构版本。
|
||||
/// </summary>
|
||||
public const int CurrentVersion = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 存档结构版本。
|
||||
/// </summary>
|
||||
public int version = CurrentVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 最后写入时间,Unix 毫秒。
|
||||
/// </summary>
|
||||
public long updatedAt;
|
||||
|
||||
/// <summary>
|
||||
/// 主仓库内容,无容量上限。
|
||||
/// </summary>
|
||||
public List<ItemStack> mainWarehouse;
|
||||
|
||||
/// <summary>
|
||||
/// 拥有的角色,数组顺序即入队顺序。
|
||||
/// </summary>
|
||||
public List<CharacterSave> characters;
|
||||
|
||||
/// <summary>
|
||||
/// 当前战备配置。
|
||||
/// </summary>
|
||||
public LoadoutSave loadout;
|
||||
|
||||
/// <summary>
|
||||
/// 已结束单局的结算记录。
|
||||
/// </summary>
|
||||
public List<RunRecord> runHistory;
|
||||
|
||||
/// <summary>
|
||||
/// 序列化为 JSON 字符串。
|
||||
/// </summary>
|
||||
public string ToJson()
|
||||
{
|
||||
return GameFramework.Utility.Json.ToJson(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从 JSON 字符串反序列化;json 为空或反序列化失败时返回 null。
|
||||
/// </summary>
|
||||
public static SaveData FromJson(string json)
|
||||
{
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
SaveData saveData = GameFramework.Utility.Json.ToObject<SaveData>(json);
|
||||
if (saveData == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
saveData.Normalize();
|
||||
return saveData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 补齐缺失字段,避免反序列化后出现空引用。
|
||||
/// </summary>
|
||||
private void Normalize()
|
||||
{
|
||||
if (mainWarehouse == null)
|
||||
{
|
||||
mainWarehouse = new List<ItemStack>();
|
||||
}
|
||||
|
||||
if (characters == null)
|
||||
{
|
||||
characters = new List<CharacterSave>();
|
||||
}
|
||||
|
||||
if (loadout == null)
|
||||
{
|
||||
loadout = new LoadoutSave();
|
||||
}
|
||||
|
||||
loadout.Normalize();
|
||||
|
||||
if (runHistory == null)
|
||||
{
|
||||
runHistory = new List<RunRecord>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2bfe2058edce460abc5e5054b5f7a7a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fc27161191c61549a74f80fd54e9645
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026150
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
public enum SceneType : byte
|
||||
{
|
||||
Launch = 0,
|
||||
Menu = 1,
|
||||
Main = 2,
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20fc28f41ef04f8fa4fbfb9189b58d0d
|
||||
timeCreated: 1768899171
|
||||
@@ -1,30 +0,0 @@
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面编号。
|
||||
/// </summary>
|
||||
public enum UIFormType : byte
|
||||
{
|
||||
Undefined = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 弹出框。
|
||||
/// </summary>
|
||||
DialogForm = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 主菜单。
|
||||
/// </summary>
|
||||
MenuForm = 100,
|
||||
|
||||
/// <summary>
|
||||
/// 设置。
|
||||
/// </summary>
|
||||
SettingForm = 101,
|
||||
|
||||
/// <summary>
|
||||
/// 关于。
|
||||
/// </summary>
|
||||
AboutForm = 102,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user