- 添加对话表结构

- 调整部分类的命名空间
- 引入 EnumUtility 用于string与enum的转换
This commit is contained in:
SepComet
2026-02-09 10:23:25 +08:00
parent 67e6b33677
commit 5973c1a4a7
77 changed files with 397 additions and 157 deletions
@@ -9,7 +9,7 @@ using System;
using System.IO;
using UnityEngine;
namespace StarForce
namespace DataTable
{
public static class BinaryReaderExtension
{
@@ -0,0 +1,39 @@
using CustomUtility;
using Definition.Enum;
using UnityGameFramework.Runtime;
namespace DataTable
{
public class DRDialog : DataRowBase
{
private int m_Id;
/// <summary>
/// 获取对话编号。
/// </summary>
public override int Id => m_Id;
/// <summary>
/// 获取对话标识。
/// </summary>
public string Title { get; private set; }
/// <summary>
/// 获取对话形式。
/// </summary>
public DialogUIMode UIMode { get; private set; }
public override bool ParseDataRow(string dataRowString, object userData)
{
string[] fields = dataRowString.Split('\t');
int index = 1;
m_Id = int.Parse(fields[index++]);
index++;
Title = fields[index++];
UIMode = EnumUtility<DialogUIMode>.Get(fields[index++]);
return true;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fb12692f2a7e6174eae3b0d28c769e55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,64 @@
using CustomUtility;
using Definition.Enum;
using UnityGameFramework.Runtime;
namespace DataTable
{
public class DRDialogLine : DataRowBase
{
private int m_Id;
/// <summary>
/// 获取对话行编号
/// </summary>
public override int Id { get; }
/// <summary>
/// 获取说话人 Id。
/// </summary>
public string SpeakerId { get; private set; }
/// <summary>
/// 获取说话人表情。
/// </summary>
public ExpressionType Expression { get; private set; }
/// <summary>
/// 获取说话人显示名。
/// </summary>
public string SpeakerName { get; private set; }
/// <summary>
/// 获取说话人朝向。
/// </summary>
public int Direction { get; private set; }
/// <summary>
/// 获取对话内容。
/// </summary>
public string Text { get; private set; }
/// <summary>
/// 获取对话效果。
/// </summary>
public EmphasisType Emphasis { get; private set; }
public override bool ParseDataRow(string dataRowString, object userData)
{
string[] fields = dataRowString.Split('\t');
int index = 0;
index++;
m_Id = int.Parse(fields[index++]);
index++;
SpeakerId = fields[index++];
Expression = EnumUtility<ExpressionType>.Get(fields[index++]);
SpeakerName = fields[index++];
Direction = int.Parse(fields[index++]);
Text = fields[index++];
Emphasis = EnumUtility<EmphasisType>.Get(fields[index++]);
return true;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fc6d3e8e61ab627488e22bb5fc28f95d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -16,7 +16,7 @@ using System.Text;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace StarForce
namespace DataTable
{
/// <summary>
/// 实体表。
@@ -28,13 +28,7 @@ namespace StarForce
/// <summary>
/// 获取实体编号。
/// </summary>
public override int Id
{
get
{
return m_Id;
}
}
public override int Id => m_Id;
/// <summary>
/// 获取资源名称。
+1 -1
View File
@@ -16,7 +16,7 @@ using System.Text;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace StarForce
namespace DataTable
{
/// <summary>
/// 音乐配置表。
+2 -16
View File
@@ -1,22 +1,8 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
// 此文件由工具自动生成,请勿直接修改。
// 生成时间:2021-06-16 21:54:35.610
//------------------------------------------------------------
using GameFramework;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO;
using System.Text;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace StarForce
namespace DataTable
{
/// <summary>
/// 场景配置表。
+2 -16
View File
@@ -1,22 +1,8 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
// 此文件由工具自动生成,请勿直接修改。
// 生成时间:2021-06-16 21:54:35.625
//------------------------------------------------------------
using GameFramework;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO;
using System.Text;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace StarForce
namespace DataTable
{
/// <summary>
/// 声音配置表。
+2 -12
View File
@@ -1,14 +1,4 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
// 此文件由工具自动生成,请勿直接修改。
// 生成时间:2021-06-16 21:54:35.652
//------------------------------------------------------------
using GameFramework;
using GameFramework;
using System;
using System.Collections.Generic;
using System.IO;
@@ -16,7 +6,7 @@ using System.Text;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace StarForce
namespace DataTable
{
/// <summary>
/// 界面配置表。
+2 -12
View File
@@ -1,14 +1,4 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
// 此文件由工具自动生成,请勿直接修改。
// 生成时间:2021-06-16 21:54:35.666
//------------------------------------------------------------
using GameFramework;
using GameFramework;
using System;
using System.Collections.Generic;
using System.IO;
@@ -16,7 +6,7 @@ using System.Text;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace StarForce
namespace DataTable
{
/// <summary>
/// 声音配置表。
@@ -1,16 +1,10 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using GameFramework.DataTable;
using GameFramework.DataTable;
using System;
using Definition;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace StarForce
namespace DataTable
{
public static class DataTableExtension
{
@@ -5,6 +5,7 @@
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using Definition;
using GameFramework.Debugger;
using GameFramework.Localization;
using UnityEngine;
@@ -5,7 +5,7 @@
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
namespace StarForce
namespace Definition
{
public static partial class Constant
{
@@ -7,7 +7,7 @@
using UnityEngine;
namespace StarForce
namespace Definition
{
public static partial class Constant
{
@@ -5,7 +5,7 @@
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
namespace StarForce
namespace Definition
{
public static partial class Constant
{
@@ -0,0 +1,22 @@
namespace Definition.Enum
{
public enum DialogUIMode
{
None = 0,
/// <summary>
/// 黑屏白字
/// </summary>
Mask = 1,
/// <summary>
/// 底部对话框
/// </summary>
BottomBox = 2,
/// <summary>
/// 对话气泡
/// </summary>
BubbleBox = 3
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7a10763d137f413d828c534b0233f2a6
timeCreated: 1770600423
@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Definition.Enum
{
public enum EmphasisType
{
None,
Shake,
Blink,
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 96908bdc885697e4d9cb0f6627d13230
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Definition.Enum
{
public enum ExpressionType
{
None,
Normal,
Shock,
Happy,
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 174e046d822a14d49843dc415067f13c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -7,6 +7,8 @@
using GameFramework.DataTable;
using System;
using CustomUtility;
using DataTable;
using Entity;
using Entity.EntityData;
using UnityGameFramework.Runtime;
@@ -1,10 +1,6 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using CustomUtility;
using DataTable;
using Definition;
using GameFramework.DataTable;
using GameFramework.Event;
using Scene;
@@ -1,12 +1,6 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using GameFramework.Localization;
using GameFramework.Localization;
using System;
using Definition;
using StarForce;
using UnityGameFramework.Runtime;
using ProcedureOwner = GameFramework.Fsm.IFsm<GameFramework.Procedure.IProcedureManager>;
@@ -1,15 +1,10 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using GameFramework;
using GameFramework;
using GameFramework.Event;
using GameFramework.Resource;
using System.Collections.Generic;
using StarForce;
using CustomUtility;
using DataTable;
using Definition;
using TMPro;
using UI;
using UnityEngine;
@@ -28,6 +23,8 @@ namespace Procedure
"Sound",
"UIForm",
"UISound",
"Dialog",
"DialogLine"
};
private Dictionary<string, bool> _loadedFlag = new Dictionary<string, bool>();
@@ -5,6 +5,9 @@
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using CustomUtility;
using DataTable;
using Definition;
using Entity;
using GameFramework;
using GameFramework.DataTable;
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8cb383e8977814343a630c164eed6c51
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+4 -8
View File
@@ -1,13 +1,9 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using GameFramework.DataTable;
using GameFramework.DataTable;
using GameFramework.UI;
using System.Collections;
using CustomUtility;
using DataTable;
using Definition;
using Procedure;
using StarForce;
using UnityEngine;
@@ -7,7 +7,7 @@
using GameFramework;
namespace StarForce
namespace CustomUtility
{
public static class AssetUtility
{
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using UnityGameFramework.Runtime;
namespace CustomUtility
{
public static class EnumUtility<T> where T : struct, System.Enum
{
private static readonly Dictionary<string, T> _enumCache = new();
public static T Get(string value)
{
if (!_enumCache.TryGetValue(value, out T result))
{
if (System.Enum.TryParse(value, true, out result))
{
_enumCache[value] = result;
}
else
{
Log.Error($"Enum 解析失败:类型:{typeof(T).Name} 不包含值 {value}");
}
}
return result;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d0591e8f95955014f8c2f8d9ba3c9247
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -9,7 +9,7 @@ using GameFramework;
using LitJson;
using System;
namespace StarForce
namespace CustomUtility
{
/// <summary>
/// LitJSON 函数集辅助器。
@@ -1,13 +1,6 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System;
using System;
namespace StarForce
namespace CustomUtility
{
public static class WebUtility
{