/** @format */ import {BaseUI} from './BaseUI' import {Data, Mgr} from '../GameControl' import {ccUtils} from '../utils/ccUtils' import {ATTR_NAME, LANGUAGE_TYPE, PROFESSION} from '../enums/Enum' import {IRole} from '../interface/GlobalInterface' import {SOUND} from '../enums/Sound' const {ccclass, property} = cc._decorator @ccclass export class RoleBreakSuccessUI extends BaseUI { attrNodes: cc.Node[] = [] onOpenAniOver() { ccUtils.playAni('lvup', 0, this.node, 'lvupAni') let t = cc.tween for (let i = 0; i < this.attrNodes.length; i++) { let attrNode = this.attrNodes[i] attrNode.stopAllActions() attrNode.x = -560 attrNode.opacity = 0 t(attrNode) .delay(i * 0.15) .then(t().to(0.3, {opacity: 255}).to(0.3, {x: 0}, {easing: 'sineIn'}).union()) .start() } } onShow(args: IRole, fromUI: number) { Mgr.audio.playSFX(SOUND.goodsUp) let iRole = args let hero = ccUtils.deepCopy(iRole.hero) hero.id -= 1 let lastQualityIRole = Mgr.global.buildIRole(hero) //英雄 let roleNode = cc.find('role', this.node) ccUtils.setLabel(iRole.cfg.name, roleNode, 'roleName') ccUtils.setLabel(`lv.${iRole.hero.lv}`, roleNode, 'lv') this.loadTexImg(`Public/role/streamer_${iRole.cfg.qualityType}`, roleNode, 'streamer') this.loadTexImg(`Public/role/role_type_${iRole.cfg.profession}`, roleNode, 'role_type') this.loadTexImg(`Public/role/base_light_${iRole.cfg.qualityType}`, roleNode, 'base_light') Mgr.global.initRoleSpine(iRole, roleNode, 'spine') ccUtils.instantChildren(cc.find('stars/star', roleNode), iRole.grade) //属性 let breakTip = cc.find('breakTip', this.node) let attrOrigin = cc.find('scrollView/view/content/attrs/attr', breakTip) let attrs = [ATTR_NAME.HP, ATTR_NAME.defense, ATTR_NAME.spellDefense] attrs.unshift(iRole.cfg.profession == PROFESSION.mage ? ATTR_NAME.spellAttack : ATTR_NAME.attack) let allAttrs = ccUtils.instantChildren(attrOrigin, attrs.length) this.attrNodes = allAttrs for (let i = 0; i < attrs.length; i++) { let attr = attrs[i] let attrNode = allAttrs[i] attrNode.x = -560 ccUtils.setLabel(LANGUAGE_TYPE[attr.toString()], attrNode, 'attrName') ccUtils.setLabel(lastQualityIRole[attr.toString()], attrNode, 'attrNum') ccUtils.setLabel(iRole[attr.toString()], attrNode, 'nextNum') } ccUtils.setLabel(iRole.cfg.tips, breakTip, 'scrollView/view/content/rtL/rt') } }