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

104 lines
3.3 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 MapViewScene.ts
* @description 地图场景管理器(负责图层持有与场景生命周期)
*
* 职责:
* 1. 持有场景中的各个显示图层引用:
* - camera场景摄像机
* - layer通用容器层
* - mapLayer地图背景层MapLayer
* - floorLayer地面装饰层
* - entityLayer实体层EntityLayer承载英雄/怪物节点)
* - SkillLayer技能效果层
* 2. 提供 init() 初始化入口和 reset() 清理入口。
* 3. 控制摄像机是否跟随玩家isFollowPlayer
*
* 关键设计:
* - ratio2D 到 3D 的位置比例值(预留,用于混合渲染模式)。
* - reset() 清除所有图层子节点,恢复初始状态。
* - onLoad() 时 enabled=false等待外部 init() 后启动。
*
* 依赖:
* - EntityLayer —— 实体图层(管理英雄/怪物的排序与清理)
* - SkillLayer —— 技能图层
* - MapLayer —— 地图背景图层
*/
import { Camera, CCBoolean, Component, EventTouch, Node, screen, Size, Texture2D, UITransform, Vec2, Vec3, view, _decorator } from "cc";
import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
import EntityLayer from "./map/layer/EntityLayer";
import SkillLayer from "./map/layer/SkillLayer";
import MapLayer from "./map/layer/MapLayer";
const { ccclass, property } = _decorator;
/**
* MapViewScene —— 地图场景管理器
*
* 持有场景中所有图层的引用,提供初始化和清理接口。
* 由 MapViewComp 在 start() 时获取引用。
*/
@ccclass('MapViewScene')
export class MapViewScene extends Component {
/** 场景摄像机(可选,用于跟随角色) */
@property(Camera)
public camera: Camera | null = null;
/** 通用容器图层节点 */
@property(Node)
public layer: Node | null = null;
/** 地图背景图层(管理背景图片的尺寸和清理) */
@property(MapLayer)
public mapLayer: MapLayer | null = null;
/** 地面装饰图层节点 */
@property(Node)
public floorLayer: Node | null = null;
/** 实体图层HERO / MON 等游戏实体的父容器) */
@property(EntityLayer)
public entityLayer: EntityLayer | null = null;
/** 技能效果图层 */
@property(SkillLayer)
public SkillLayer: SkillLayer | null = null;
/** 是否启用摄像机跟随玩家 */
@property(CCBoolean)
public isFollowPlayer: boolean = true;
/** 2D→3D 位置比例值(预留,混合渲染时使用) */
ratio: Vec2 = new Vec2();
/** 加载时禁用自身,等待 init() 手动启用 */
onLoad() {
this.enabled = false;
}
start() {
}
/**
* 重置场景:清除各图层的子节点和数据。
* 用于关卡切换或任务结束时恢复初始状态。
*/
private reset() {
this.floorLayer!.removeAllChildren(); // 清除地面显示对象
this.entityLayer!.clear(); // 清除游戏实体对象
this.mapLayer!.clear(); // 清除地图背景
}
/** 场景初始化(预留扩展) */
public init() {
}
/** 帧更新(预留摄像机跟随等逻辑) */
update(dt: number) {
}
}