RoleBreakSuccessUI.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /** @format */
  2. import {BaseUI} from './BaseUI'
  3. import {Data, Mgr} from '../GameControl'
  4. import {ccUtils} from '../utils/ccUtils'
  5. import {ATTR_NAME, LANGUAGE_TYPE, PROFESSION} from '../enums/Enum'
  6. import {IRole} from '../interface/GlobalInterface'
  7. import {SOUND} from '../enums/Sound'
  8. const {ccclass, property} = cc._decorator
  9. @ccclass
  10. export class RoleBreakSuccessUI extends BaseUI {
  11. attrNodes: cc.Node[] = []
  12. onOpenAniOver() {
  13. ccUtils.playAni('lvup', 0, this.node, 'lvupAni')
  14. let t = cc.tween
  15. for (let i = 0; i < this.attrNodes.length; i++) {
  16. let attrNode = this.attrNodes[i]
  17. attrNode.stopAllActions()
  18. attrNode.x = -560
  19. attrNode.opacity = 0
  20. t(attrNode)
  21. .delay(i * 0.15)
  22. .then(t().to(0.3, {opacity: 255}).to(0.3, {x: 0}, {easing: 'sineIn'}).union())
  23. .start()
  24. }
  25. }
  26. onShow(args: IRole, fromUI: number) {
  27. Mgr.audio.playSFX(SOUND.goodsUp)
  28. let iRole = args
  29. let hero = ccUtils.deepCopy(iRole.hero)
  30. hero.id -= 1
  31. let lastQualityIRole = Mgr.global.buildIRole(hero)
  32. //英雄
  33. let roleNode = cc.find('role', this.node)
  34. ccUtils.setLabel(iRole.cfg.name, roleNode, 'roleName')
  35. ccUtils.setLabel(`lv.${iRole.hero.lv}`, roleNode, 'lv')
  36. this.loadTexImg(`Public/role/streamer_${iRole.cfg.qualityType}`, roleNode, 'streamer')
  37. this.loadTexImg(`Public/role/role_type_${iRole.cfg.profession}`, roleNode, 'role_type')
  38. this.loadTexImg(`Public/role/base_light_${iRole.cfg.qualityType}`, roleNode, 'base_light')
  39. Mgr.global.initRoleSpine(iRole, roleNode, 'spine')
  40. ccUtils.instantChildren(cc.find('stars/star', roleNode), iRole.grade)
  41. //属性
  42. let breakTip = cc.find('breakTip', this.node)
  43. let attrOrigin = cc.find('scrollView/view/content/attrs/attr', breakTip)
  44. let attrs = [ATTR_NAME.HP, ATTR_NAME.defense, ATTR_NAME.spellDefense]
  45. attrs.unshift(iRole.cfg.profession == PROFESSION.mage ? ATTR_NAME.spellAttack : ATTR_NAME.attack)
  46. let allAttrs = ccUtils.instantChildren(attrOrigin, attrs.length)
  47. this.attrNodes = allAttrs
  48. for (let i = 0; i < attrs.length; i++) {
  49. let attr = attrs[i]
  50. let attrNode = allAttrs[i]
  51. attrNode.x = -560
  52. ccUtils.setLabel(LANGUAGE_TYPE[attr.toString()], attrNode, 'attrName')
  53. ccUtils.setLabel(lastQualityIRole[attr.toString()], attrNode, 'attrNum')
  54. ccUtils.setLabel(iRole[attr.toString()], attrNode, 'nextNum')
  55. }
  56. ccUtils.setLabel(iRole.cfg.tips, breakTip, 'scrollView/view/content/rtL/rt')
  57. }
  58. }