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

80 lines
2.7 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 MapViewComp.ts
* @description 地图视图组件ECS 视图层)
*
* 职责:
* 1. 作为地图的顶层 **视图逻辑控制器**,挂载在地图预制体的 "map" 子节点上。
* 2. 持有 MapViewScene 引用,用于访问场景中的各图层(实体层、技能层、地图层)。
* 3. 提供全局事件监听接口(当前已注释,预留扩展)。
* 4. 管理游戏内计时器game_timer预留 1 秒间隔周期逻辑)。
*
* 关键设计:
* - start() 时获取同节点上的 MapViewScene 组件引用。
* - reset() 在 ECS 实体移除时取消全局事件监听。
* - 当前 update / onLoad 为空实现,预留帧更新和初始化扩展位。
*
* 依赖:
* - MapViewSceneview/MapViewScene.ts—— 场景图层管理
* - Timeroops-framework—— 周期计时器
* - smc —— 全局单例模块
* - BoxSet —— 游戏常量配置
*/
import { v3, Vec3, _decorator ,Prefab,instantiate,JsonAsset} from "cc";
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../../common/SingletonModuleComp";
import { BoxSet } from "../../common/config/GameSet";
import { MapViewScene } from "./MapViewScene";
import { Timer } from "../../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
const { ccclass, property } = _decorator;
/**
* MapViewComp —— 地图视图逻辑组件
*
* ECS 视图层入口,通过 scene 属性访问场景中各图层。
*/
@ccclass('MapViewComp')
@ecs.register('MapView', false)
export class MapViewComp extends CCComp {
/** 场景图层管理器引用start 时初始化) */
scene: MapViewScene = null!;
/** 游戏内周期计时器(预留,间隔 1 秒) */
private game_timer: Timer = new Timer(1);
/** 地图加载完成回调(预留) */
private mapLoaded() {
}
/** 初始化:预留全局事件监听位 */
async onLoad(){
// 监听全局事件
}
/** ECS 组件移除时取消全局事件监听 */
reset(): void {
//撤销监听
// oops.message.off("do_add_hero", this.on_do_add_hero, this);
}
/** 启动时获取同节点上的 MapViewScene 组件 */
start() {
this.scene = this.getComponent(MapViewScene);
}
/** 预留:加载游戏数据 */
load_data(){
// let heros = oops.res.get("config/game/heros")
}
/** 帧更新(预留扩展) */
protected update(dt: number): void {
}
// 刷新怪物
}