diff --git a/Client/Assets/Scenes/Test.unity b/Client/Assets/Scenes/Test.unity index 0973207..bcfa585 100644 --- a/Client/Assets/Scenes/Test.unity +++ b/Client/Assets/Scenes/Test.unity @@ -478,7 +478,7 @@ Transform: m_GameObject: {fileID: 1057087086} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -0.60862845, y: 1.3409947, z: -10} + m_LocalPosition: {x: 0, y: 0, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -651,6 +651,37 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 147e91e6929d90a4fb877c0b0a6b608c, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!1 &1485465860 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1485465861} + m_Layer: 0 + m_Name: CatGirl + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1485465861 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1485465860} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 @@ -659,3 +690,4 @@ SceneRoots: - {fileID: 1057087090} - {fileID: 613797070} - {fileID: 912467178} + - {fileID: 1485465861} diff --git a/Client/Assets/Scripts/Data/CharacterDefine.cs b/Client/Assets/Scripts/Data/CharacterDefine.cs new file mode 100644 index 0000000..c80679d --- /dev/null +++ b/Client/Assets/Scripts/Data/CharacterDefine.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.Xml.Linq; + +namespace Data +{ + public class CharacterDef : Define + { + public DrawingOrderDef + drawingOrder_down, + drawingOrder_up, + drawingOrder_left, + drawingOrder_right; + } + + public class DrawingOrderDef : Define + { + public List DrawNodes { get; set; } = new List(); + + public override bool Init(XElement xmlDef) + { + base.Init(xmlDef); + foreach (var node in xmlDef.Elements("DrawNodes")) + { + DrawNodeDef drawNode = new DrawNodeDef(); + drawNode.Init(node); + DrawNodes.Add(drawNode); + } + return true; + } + } + public partial class DrawNodeDef : Define + { + public string NodeName { get; set; } + public List Children { get; set; } = new(); + public override bool Init(XElement xmlDef) + { + base.Init(xmlDef); + NodeName = xmlDef.Attribute("name")?.Value; + foreach (var childNode in xmlDef.Elements("DrawNode")) + { + DrawNodeDef child = new DrawNodeDef(); + child.Init(childNode); + Children.Add(child); + } + return true; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Scripts/Data/CharacterDefine.cs.meta b/Client/Assets/Scripts/Data/CharacterDefine.cs.meta new file mode 100644 index 0000000..dc964d6 --- /dev/null +++ b/Client/Assets/Scripts/Data/CharacterDefine.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e277dc789917427a81ab775cb5e74107 +timeCreated: 1752403551 \ No newline at end of file diff --git a/Client/Assets/Scripts/Data/DefinePack.cs b/Client/Assets/Scripts/Data/DefinePack.cs index 1c69288..a626b75 100644 --- a/Client/Assets/Scripts/Data/DefinePack.cs +++ b/Client/Assets/Scripts/Data/DefinePack.cs @@ -102,7 +102,7 @@ namespace Data /// /// define类别及其定义 /// - public Dictionary> defines; + public Dictionary> defines=new(); public PackAbout packAbout; public string packID; diff --git a/Client/Assets/Scripts/Entity.meta b/Client/Assets/Scripts/Entity.meta new file mode 100644 index 0000000..b929277 --- /dev/null +++ b/Client/Assets/Scripts/Entity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d6df36c59fc95694f93c95b131bc940f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Data/Core/Define/Player/CatGirl.xml b/Client/Data/Core/Define/Player/CatGirl.xml index cfefb6b..4f56ae6 100644 --- a/Client/Data/Core/Define/Player/CatGirl.xml +++ b/Client/Data/Core/Define/Player/CatGirl.xml @@ -1,37 +1,35 @@ - - - - CatGirl - 100 + + + CatGirl + 100 1.2 5 - + - + CatGirl She is a cat girl with agile movements and sharp senses. - CatGirl + CatGirl - CatGirl_down + CatGirl_down CatGirl_left CatGirl_right CatGirl_up - + - - + CatGirl_down - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/Docs/DefineType/DrawingOrderDef.md b/Docs/DefineType/DrawingOrderDef.md new file mode 100644 index 0000000..24f3e3d --- /dev/null +++ b/Docs/DefineType/DrawingOrderDef.md @@ -0,0 +1,90 @@ +# DrawingOrderDef使用文档 + +--- + +## 1. 基本概念 + +### 1.1 DrawingOrderDef +`DrawingOrderDef` 是用于定义游戏对象树形结构的根节点。它表示整个渲染层级的入口点。 + +### 1.2 defName +`defName` 是 `DrawingOrderDef` 的子节点,用于指定当前渲染层级结构的唯一引用名称。这个名称可以在其他地方(如脚本或配置文件)中被引用。 + +### 1.3 DrawNodeDef +`DrawNodeDef` 是定义渲染层级中的节点元素。每个 `DrawNodeDef` 可以包含子节点,形成树形结构。其属性包括: +- **name**:节点的名称,用于标识该节点。 +- **type**:可选属性,用于指定节点的类型。目前支持的类型有: + - `image`:表示一个静态图像。 + - `animation`:表示一个动画序列。 + +--- + +## 2. 示例解析 + +以下是一个完整的 XML 示例及其解析: + +```xml + + CatGirl + + + + + + + + + + + +``` + +### 2.1 结构说明 +1. **根节点**:`DrawingOrderDef` 表示此角色的渲染树 +2. **唯一标识**:`defName` 节点指定了当前渲染层级结构的名称为 `CatGirl`。 +3. **渲染层级**: + - `body` 是顶层节点,表示角色的身体部分。 + - `head` 是 `body` 的子节点,表示头部。 + - `backHair`、`ear`、`face`、`frontHair` 和 `hat` 是 `head` 的子节点,分别表示后发、耳朵、脸部、前发和帽子。 + - `clothes` 是 `body` 的另一个子节点,表示角色的衣服。 + +### 2.2 渲染顺序 +在渲染时,系统会按照 XML 中定义的树形结构依次绘制每个节点。例如,在上述例子中,渲染顺序为: +1. `body` + - `head` + - `backHair` + - `ear` + - `face` + - `frontHair` + - `hat` + - `clothes` + +这种顺序确保了层次分明的渲染效果,例如,头发和帽子会覆盖在脸部之上,衣服则位于身体外部。 + +--- + +## 3. 扩展功能 + +### 3.1 指定节点类型 +可以通过 `type` 属性为节点指定具体的类型。例如: + +```xml + + +``` + +- 如果 `type="image"`,则表示该节点是一个静态图像。 +- 如果 `type="animation"`,则表示该节点是一个动画序列。 + +默认为image + +### 3.2 动态引用 +通过 `defName`,可以将定义好的渲染层级结构动态引用到其他地方。例如,如果某个脚本需要加载 `CatGirl` 的渲染结构,可以直接通过 `defName` 引用。 + +--- + +## 4. 注意事项 + +1. **节点命名唯一性**:在同一层级中,节点的 `name` 属性应保持唯一,以避免冲突。 +2. **类型匹配**:如果指定了 `type` 属性,确保实际内容与类型一致(如 `image` 对应静态图片资源,`animation` 对应动画资源)。 +3. **嵌套深度**:虽然理论上可以无限嵌套,但建议控制嵌套深度,以提高性能和可维护性。 diff --git a/Docs/DefineUse.md b/Docs/DefineUse.md index 8ecd18e..2eb2d7f 100644 --- a/Docs/DefineUse.md +++ b/Docs/DefineUse.md @@ -57,38 +57,38 @@ XML 文件根据根属性名分为三种类型: ```xml - + CatGirl 100 1.2 5 - + - + CatGirl She is a cat girl with agile movements and sharp senses. - CatGirl + CatGirl - CatGirl_down + CatGirl_down CatGirl_left CatGirl_right CatGirl_up - + - + CatGirl_down - - - - - - - - - - - + + + + + + + + + + + ``` @@ -151,7 +151,7 @@ XML 文件根据根属性名分为三种类型: ``` 例如: ``` -Character.CatGirl.label +CharacterDef.CatGirl.label ``` #### 5.3 示例解析 @@ -160,8 +160,8 @@ Character.CatGirl.label ```xml - 猫娘 - 她是一个猫娘,拥有猫的特性和人类的智慧。她的耳朵和尾巴显示了她的猫族血统。 + 猫娘 + 她是一个猫娘,拥有猫的特性和人类的智慧。她的耳朵和尾巴显示了她的猫族血统。 ```