| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- import { _decorator, Component, Node, Sprite, Label, RichText, sp, SpriteFrame, isValid } from 'cc';
- import { DataSystem } from '../../core/data/DataSystem';
- import { ResourceLoader } from '../../core/resourceManager/ResourceLoader';
- import { UITween } from '../../core/ui/tween/UITween';
- import { Window } from '../../core/ui/window/Window';
- import { WindowOpenMode } from '../../core/ui/window/WindowOpenMode';
- import { WindowSystem } from '../../core/ui/window/WindowSystem';
- import { StringUtils } from '../../core/utils/StringUtils';
- import { MarshalData } from '../MarshalData';
- import { MarshalDataTool } from '../MarshalDataTool';
- import { MarshalSkillSystem } from '../MarshalSkillSystem';
- const { ccclass, property } = _decorator;
- /**
- * 统帅技能解锁和升级弹窗 只在统帅页显示
- * @author 郑聂华
- */
- @ccclass('MarshalSkillLvUpUI')
- export class MarshalSkillLvUpUI extends Component {
- @property({ type: ResourceLoader, displayName: "资源加载组件", tooltip: "资源加载组件" }) res: ResourceLoader = null;
- @property({ type: Node, displayName: "标题_解锁", tooltip: "标题_解锁" }) titleUnlock: Node = null;
- @property({ type: Node, displayName: "标题_升级", tooltip: "标题_升级" }) titleLvup: Node = null;
- @property({ type: Sprite, displayName: "技能图", tooltip: "技能图" }) imgSkill: Sprite = null;
- @property({ type: Label, displayName: "技能名称", tooltip: "技能名称" }) txtSkillName: Label = null;
- @property({ type: Label, displayName: "技能等级", tooltip: "技能等级" }) txtSkillLv: Label = null;
- @property({ type: RichText, displayName: "技能描述", tooltip: "技能描述" }) txtRichDes: RichText = null;
- @property({ type: Label, displayName: "计时器", tooltip: "计时器" }) txtTime: Label = null;
- @property({ type: sp.Skeleton, displayName: "效果_解锁", tooltip: "效果_解锁" }) spineUnlock: sp.Skeleton = null;
- @property({ type: sp.Skeleton, displayName: "效果_升级", tooltip: "效果_升级" }) spineLvup: sp.Skeleton = null;
- private paramData: { type: number, id: number, lv: number, lastLv: number };
- 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.paramData = param;
- this.titleUnlock.active = param.type == 1;
- this.titleLvup.active = param.type == 2;
- let marshalData = DataSystem.getData(MarshalData);
- let skillData = marshalData.skillData[param.id];
- this.txtSkillName.string = skillData.name;
- this.txtSkillLv.string = "Lv." + (param.type == 1 ? param.lv : param.lastLv);
- let totalSkillValueStr = MarshalSkillSystem.getSkillValueStr(skillData, param.type == 1 ? param.lv : param.lastLv);
- let des = StringUtils.format(skillData.des, totalSkillValueStr);
- this.txtRichDes.string = StringUtils.getRichText(des);
- this.schedule(this.closeSchedule, 1);
- if (param.type == 1) this.playUnlockEft(); else this.playLvUpEft();
- this.imgSkill.spriteFrame = await this.res.load<SpriteFrame>("images/skill/" + skillData.icon + "/spriteFrame", SpriteFrame);
- }
- /**解锁动画*/
- private async playUnlockEft() {
- this.imgSkill.grayscale = true;
- this.spineUnlock.node.active = true;
- this.spineUnlock.setAnimation(0, "None", false);
- await new Promise<void>(resolve => { setTimeout(() => resolve(), 1000) });
- if (isValid(this.node)) {
- this.spineUnlock.setToSetupPose();
- this.spineUnlock.setAnimation(0, "animation", false);
- await new Promise<void>(resolve => { setTimeout(() => resolve(), (this.spineUnlock.findAnimation("animation").duration + 0.5) * 1000) });
- if (isValid(this.node)) {
- this.spineUnlock.node.active = false;
- this.imgSkill.grayscale = false;
- }
- }
- }
- /**升级动画*/
- private async playLvUpEft() {
- this.imgSkill.grayscale = false;
- await new Promise<void>(resolve => { setTimeout(() => resolve(), 1000) });
- if (isValid(this.node)) {
- this.spineLvup.node.active = true;
- this.spineLvup.setAnimation(0, "animation", false);
- await new Promise<void>(resolve => { setTimeout(() => resolve(), (this.spineLvup.findAnimation("animation").duration + 0.5) * 1000) });
- if (isValid(this.node)) {
- this.spineLvup.node.active = true;
- let marshalData = DataSystem.getData(MarshalData);
- let skillData = marshalData.skillData[this.paramData.id];
- this.txtSkillLv.string = "Lv." + this.paramData.lv;
- let totalSkillValueStr = MarshalSkillSystem.getSkillValueStr(skillData, this.paramData.lv);
- let des = StringUtils.format(skillData.des, totalSkillValueStr);
- this.txtRichDes.string = StringUtils.getRichText(des);
- this.txtRichDes.node.getComponent(UITween).play();
- }
- }
- }
- 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.skillUnlockLvUpQueue.splice(0, 1);
- let lenAfter = marshalData.skillUnlockLvUpQueue.length;
- if (lenAfter > 0) {
- let param = marshalData.skillUnlockLvUpQueue[0];
- WindowSystem.open("prefabs/ui/marshalStage/marshalSkillLvUp", WindowOpenMode.NotCloseAndCover, [param]);
- }
- }
- }
|