Files
pixelheros/assets/script/game/map/view/map/layer/EntityLayer.ts
walkpan 81a07bc16c feat: 新增英雄召唤事件并优化UI布局与组件注释
- 在 MissionHeroComp 中召唤英雄后派发 MasterCalled 事件,以更新英雄信息面板
- 调整 hnode.prefab 中多个节点的位置和尺寸,优化界面布局
- 为多个 TypeScript 组件文件添加详细注释,说明职责、关键设计和依赖关系
- 在 MissionCardComp 中完善英雄信息面板的创建、排序和布局逻辑
2026-04-07 19:52:40 +08:00

69 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file EntityLayer.ts
* @description 实体图层组件(场景显示层)
*
* 职责:
* 1. 作为所有游戏实体(英雄、怪物)的 **父容器节点**。
* 2. 预留深度排序逻辑(当前已注释,按 Y 坐标排序子节点渲染顺序)。
* 3. 提供 clear() 方法清除所有子节点(用于场景重置)。
*
* 关键设计:
* - 使用 Timer0.2 秒间隔)降频排序,避免每帧排序导致性能问题。
* - 深度排序按 Y 坐标从大到小Y 越小渲染越靠前),
* 模拟 2D 俯视角的遮挡关系。
* - 如果后续切换为全 3D 渲染,则不需要 2D 深度排序。
*
* 依赖:
* - Timeroops-framework—— 降频计时器
*/
/*
* @Author: dgflash
* @Date: 2022-08-04 15:22:33
* @LastEditors: dgflash
* @LastEditTime: 2023-05-12 18:04:45
*/
import { Component, Node, _decorator } from 'cc';
import { Timer } from '../../../../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer';
const { ccclass, property } = _decorator;
/**
* EntityLayer —— 实体图层
*
* 所有英雄和怪物节点的父容器,预留深度排序功能。
*
* 注:
* 1. 如果深度排序存在性能问题,可修改为非每帧排序(使用 Timer 降频)。
* 2. 如果全 3D 渲染,则不需要 2D 深度排序,只引用 2D 地图上的位置信息。
*/
@ccclass('EntityLayer')
export default class EntityLayer extends Component {
/** 降频计时器0.2 秒间隔,当前 update 中只调用 update 但未使用返回值) */
private timer: Timer = new Timer(0.2);
/**
* 帧更新:
* 预留深度排序调用位(当前已注释排序逻辑)。
*/
update(dt: number) {
this.timer.update(dt)
// 预留:按 Y 坐标排序子节点渲染顺序
// if (this.timer.update(dt))
// this.node.children.sort(this.zIndexSort);
}
protected start(): void {
}
/**
* 清除该图层下的所有子节点。
* 由 MapViewScene.reset() 在场景重置时调用。
*/
public clear() {
this.node.children.forEach(n => {
});
}
}