chore: 清理设计文档和调整GUI资源结构
- 删除过时的属性变更优化方案设计文档 - 删除肉鸽怪物刷新机制设计方案文档 - 移除旧的GUI资源文件 - 添加新的GUI元素预制体 - 更新GUI资源组织结构
This commit is contained in:
@@ -1,168 +0,0 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.Prefab",
|
||||
"_name": "hui",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_native": "",
|
||||
"data": {
|
||||
"__id__": 1
|
||||
},
|
||||
"optimizationPolicy": 0,
|
||||
"persistent": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "hui",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": null,
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 2
|
||||
},
|
||||
{
|
||||
"__id__": 4
|
||||
},
|
||||
{
|
||||
"__id__": 6
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 8
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 14.007,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
"__type__": "cc.Quat",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -1.2,
|
||||
"y": 1.2,
|
||||
"z": 1
|
||||
},
|
||||
"_mobility": 0,
|
||||
"_layer": 1073741824,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 128,
|
||||
"height": 128
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.25
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "cewibQgK1ALbFhMuuspMmN"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 5
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
"_dstBlendFactor": 4,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_spriteFrame": null,
|
||||
"_type": 0,
|
||||
"_fillType": 0,
|
||||
"_sizeMode": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_useGrayscale": false,
|
||||
"_atlas": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "ed71tIQFtJtbSwrQYOmOPP"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Animation",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 7
|
||||
},
|
||||
"playOnLoad": true,
|
||||
"_clips": [],
|
||||
"_defaultClip": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "3dBJqUbmFPGIhxjbVKe/vR"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "9anvHdhj5D1opINsPLBLgs",
|
||||
"instance": null,
|
||||
"targetOverrides": null
|
||||
}
|
||||
]
|
||||
1158
assets/resources/gui/element/box.prefab
Normal file
1158
assets/resources/gui/element/box.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,12 +2,12 @@
|
||||
"ver": "1.1.50",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "4489091b-29ab-4906-972b-978bd4279a8e",
|
||||
"uuid": "d19cde30-f5d0-47de-a0d5-3a272b696343",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "hui"
|
||||
"syncNodeName": "box"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 265 KiB After Width: | Height: | Size: 282 KiB |
@@ -1,71 +0,0 @@
|
||||
# 属性变更脏标签优化方案
|
||||
|
||||
## 一、现有实现存在的具体问题
|
||||
|
||||
### 1.1 性能问题
|
||||
- **HeroViewComp.ts** 的 `update(dt: number)` 方法中,每帧都调用 `hp_show()` 和 `mp_show()`
|
||||
- 即使血量和魔法值没有变化,也会每帧更新UI进度条,造成不必要的性能开销
|
||||
- 缺少属性变更标记机制,采用轮询方式检查
|
||||
|
||||
### 1.2 架构问题
|
||||
- 属性变更与UI更新耦合在 `update` 循环中,违反按需更新原则
|
||||
- UI更新逻辑分散,缺少统一的变更标记管理
|
||||
- 属性变更通知机制不完善
|
||||
|
||||
## 二、需要进行的修改方案
|
||||
|
||||
### 2.1 核心设计
|
||||
- 采用脏标签(Dirty Flag)模式,属性变更时标记对应的脏标签
|
||||
- UI层在 `update` 中检查脏标签,只在属性变化时更新显示
|
||||
- 解耦数据层和视图层,提升性能和可维护性
|
||||
|
||||
### 2.2 实现步骤
|
||||
1. **添加脏标签标记**:在 `HeroAttrsComp` 中添加血量、魔法值、护盾的脏标签
|
||||
2. **修改属性变更方法**:在 `HeroAttrsComp` 的属性变更方法中设置脏标签
|
||||
3. **实现脏标签检查逻辑**:在 `HeroViewComp` 的 `update` 中检查脏标签并按需更新UI
|
||||
4. **清理脏标签**:UI更新完成后清理对应的脏标签
|
||||
|
||||
## 三、需要修改的具体文件及对应模块
|
||||
|
||||
### 3.1 HeroAttrsComp.ts
|
||||
**修改模块**:
|
||||
- 类属性:添加脏标签字段 `dirty_hp`、`dirty_mp`、`dirty_shield`
|
||||
- `add_hp()` 方法:设置 `dirty_hp = true`
|
||||
- `add_mp()` 方法:设置 `dirty_mp = true`
|
||||
- `add_shield()` 方法:设置 `dirty_shield = true`
|
||||
- `reset()` 方法:重置所有脏标签
|
||||
|
||||
**修改内容**:
|
||||
- 添加脏标签字段:`dirty_hp: boolean = false`、`dirty_mp: boolean = false`、`dirty_shield: boolean = false`
|
||||
- 在属性变更方法中设置对应的脏标签为 `true`
|
||||
- 在 `reset` 方法中重置所有脏标签为 `false`
|
||||
|
||||
### 3.2 HeroViewComp.ts
|
||||
**修改模块**:
|
||||
- `update(dt: number)` 方法:添加脏标签检查逻辑,按需调用UI更新方法
|
||||
|
||||
**修改内容**:
|
||||
- 在 `update` 中检查 `this.model.dirty_hp`、`this.model.dirty_mp`、`this.model.dirty_shield`
|
||||
- 只在脏标签为 `true` 时调用对应的 `hp_show()`、`mp_show()`、`show_shield()`
|
||||
- UI更新完成后清理脏标签为 `false`
|
||||
|
||||
### 3.3 HeroAttrEventSystem.ts
|
||||
**修改模块**:
|
||||
- 无需修改
|
||||
|
||||
**修改内容**:
|
||||
- 脏标签方案不需要事件系统,保持现有实现即可
|
||||
|
||||
### 3.4 HeroAttrEvent.ts
|
||||
**修改模块**:
|
||||
- 无需修改
|
||||
|
||||
**修改内容**:
|
||||
- 脏标签方案不需要事件组件,保持现有实现即可
|
||||
|
||||
## 四、预期效果
|
||||
|
||||
- **性能提升**:消除每帧不必要的UI更新,只在属性变化时更新,减少CPU开销
|
||||
- **架构优化**:实现按需更新模式,解耦数据层和视图层
|
||||
- **可维护性提升**:脏标签逻辑简单清晰,易于理解和维护
|
||||
- **代码简洁**:无需引入复杂的事件系统,实现成本低
|
||||
1403
肉鸽怪物刷新机制设计方案.md
1403
肉鸽怪物刷新机制设计方案.md
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user