Files
pixelheros/assets/script/game/map/SIconComp.ts
walkpan e880613f8f docs: 为游戏地图模块添加详细的代码注释
为游戏地图模块的脚本文件添加全面的注释,说明每个组件的职责、关键设计、依赖关系和使用方式。注释覆盖了英雄信息面板、技能卡槽位管理器、排行榜弹窗、卡牌控制器、背景滚动组件等核心功能模块,提高了代码的可读性和维护性。

同时修复了英雄预制体的激活状态和技能效果预制体的尺寸参数。
2026-04-07 19:00:30 +08:00

50 lines
1.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 SIconComp.ts
* @description 技能图标组件UI 视图层)
*
* 职责:
* 1. 根据技能 UUID 显示对应的技能图标。
* 2. 从预加载的资源中获取 SpriteFrame 并赋给子节点 "icon" 的 Sprite。
*
* 使用方式:
* 挂载在需要显示技能图标的节点上,外部调用 update_data(s_uuid) 传入技能 UUID。
*
* 依赖:
* - SkillSetSkillSet.ts—— 技能静态配置(含 icon 字段)
* - oops.res —— 已预加载的资源管理器
*/
import { _decorator, Sprite, SpriteFrame } 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 { SkillSet } from "../common/config/SkillSet";
import { oops } from "db://oops-framework/core/Oops";
const { ccclass, property } = _decorator;
/**
* SIconCompComp —— 技能图标视图组件
*
* 从 SkillSet 查询技能配置获取 icon 路径,
* 通过 oops.res.get 获取已预加载的 SpriteFrame 并显示。
*/
@ccclass('SIconCompComp')
@ecs.register('SIconComp', false)
export class SIconCompComp extends CCComp {
start() {
}
/**
* 更新技能图标显示。
* @param s_uuid 技能的唯一标识 UUID
*/
update_data(s_uuid:number){
let skill_data = SkillSet[s_uuid]
// 从预加载的资源中获取对应图标的 SpriteFrame 并赋值
this.node.getChildByName("icon").getComponent(Sprite).spriteFrame = oops.res.get("game/heros/cards/"+skill_data.icon, SpriteFrame)
}
/** ECS 组件移除时销毁节点 */
reset() {
this.node.destroy();
}
}