import { _decorator, Component, Node, Sprite, Label, SpriteFrame } from 'cc'; import { DataSystem } from '../../core/data/DataSystem'; import { ResourceLoader } from '../../core/resourceManager/ResourceLoader'; import { Window } from '../../core/ui/window/Window'; import { WindowOpenMode } from '../../core/ui/window/WindowOpenMode'; import { WindowSystem } from '../../core/ui/window/WindowSystem'; import { MarshalData } from '../MarshalData'; const { ccclass, property } = _decorator; /** * 统帅技能解锁和升级小弹窗 * @author 郑聂华 */ @ccclass('MarshalSkillNotice') export class MarshalSkillNoticeUI extends Component { @property({ type: ResourceLoader, displayName: "资源加载组件", tooltip: "资源加载组件" }) res: ResourceLoader = null; @property({ type: Node, displayName: "技能解锁节点" }) nodeSkillUnlock: Node = null; @property({ type: Node, displayName: "技能升级节点" }) nodeSkillLvUp: Node = null; @property({ type: Sprite, displayName: "技能头像" }) imgSkill: Sprite = null; @property({ type: Label, displayName: "文本_解锁后技能等级" }) txtLvUnlock: Label = null; @property({ type: Label, displayName: "文本_升级前技能等级" }) txtLvUpLast: Label = null; @property({ type: Label, displayName: "文本_升级后技能等级" }) txtLvUpCur: Label = null; @property({ type: Label, displayName: "文本_技能名" }) txtSkillName: Label = null; @property({ type: Label, displayName: "计时器" }) txtTime: Label = null; private timer: number = 10; /** * 打开页面初始化 * @param param 参数 * { * type:1, 1 解锁 2 升级 id:110001, 技能id lv:2, 技能等级 lastLv:1 技能上一级 * } */ async init(param: { type: number, id: number, lv: number, lastLv: number }) { this.nodeSkillUnlock.active = param.type == 1; this.nodeSkillLvUp.active = param.type == 2; let marshalData = DataSystem.getData(MarshalData); let skillData = marshalData.skillData[param.id]; this.txtSkillName.string = skillData.name; this.txtLvUnlock.string = "Lv." + param.lv; this.txtLvUpLast.string = "Lv." + param.lastLv; this.txtLvUpCur.string = "Lv." + param.lv; this.imgSkill.spriteFrame = await this.res.load("images/skill/" + skillData.icon + "/spriteFrame", SpriteFrame); this.schedule(this.closeSchedule, 1); } private closeSchedule() { this.timer -= 1; if (this.timer < 0) { this.unschedule(this.closeSchedule); this.getComponent(Window).close(); } this.txtTime.string = this.timer + "秒后自动关闭"; } onDestroy() { let marshalData = DataSystem.getData(MarshalData); marshalData.skillNoticeQueue.splice(0, 1); let lenAfter = marshalData.skillNoticeQueue.length; if (lenAfter > 0) { let param = marshalData.skillNoticeQueue[0]; WindowSystem.open("prefabs/ui/marshalStage/marshalSkillNotice", WindowOpenMode.NotCloseAndCover, [param]); } } }