EquipBreakSuccessUI.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /** @format */
  2. import {BaseUI} from './BaseUI'
  3. import {Data, Mgr} from '../GameControl'
  4. import {ccUtils} from '../utils/ccUtils'
  5. import {observer, render, node, label, editBox, list} from '../mobx/observer'
  6. import {ATTR_NAME, LANGUAGE_TYPE} from '../enums/Enum'
  7. import {IEquip} from '../interface/GlobalInterface'
  8. import {SOUND} from '../enums/Sound'
  9. const {ccclass, property} = cc._decorator
  10. @ccclass
  11. @observer
  12. export class EquipBreakSuccessUI extends BaseUI {
  13. attrNodes: cc.Node[] = []
  14. onOpenAniOver() {
  15. let t = cc.tween
  16. for (let i = 0; i < this.attrNodes.length; i++) {
  17. let attrNode = this.attrNodes[i]
  18. attrNode.stopAllActions()
  19. attrNode.x = -560
  20. attrNode.opacity = 0
  21. t(attrNode)
  22. .delay(i * 0.1)
  23. .then(t().to(0.2, {opacity: 255}).to(0.3, {x: 0}, {easing: 'sineIn'}).union())
  24. .start()
  25. }
  26. }
  27. onShow(args: IEquip, fromUI: number) {
  28. Mgr.audio.playSFX(SOUND.goodsUp)
  29. let iEquip = args
  30. Mgr.global.initEquipItem(iEquip, cc.find('equip', this.node), this)
  31. ccUtils.setLabel(iEquip.cfg.name, this.node, 'name')
  32. this.loadTexImg(`Public/role/streamer_${iEquip.cfg.qualityType}`, this.node, 'streamer')
  33. ccUtils.instantChildren(cc.find('stars/star', this.node), iEquip.grade)
  34. //属性
  35. let lastQualityIEquip = Mgr.global.buildIEquip({
  36. id: iEquip.equip.id - 1,
  37. lv: iEquip.equip.lv,
  38. sid: iEquip.equip.sid,
  39. hero: '',
  40. })
  41. let breakTip = cc.find('breakTip', this.node)
  42. let attrOrigin = cc.find('scrollView/view/content/attrs/attr', breakTip)
  43. let attrs = [
  44. iEquip.HP > 0
  45. ? ATTR_NAME.HP
  46. : iEquip.spellAttack > iEquip.attack
  47. ? ATTR_NAME.spellAttack
  48. : ATTR_NAME.attack,
  49. ]
  50. let allAttrs = ccUtils.instantChildren(attrOrigin, attrs.length)
  51. this.attrNodes = allAttrs
  52. for (let i = 0; i < attrs.length; i++) {
  53. let attr = attrs[i]
  54. let attrNode = allAttrs[i]
  55. attrNode.x = -560
  56. ccUtils.setLabel(LANGUAGE_TYPE[attr.toString()], attrNode, 'attrName')
  57. ccUtils.setLabel(lastQualityIEquip[attr.toString()], attrNode, 'attrNum')
  58. ccUtils.setLabel(iEquip[attr.toString()], attrNode, 'nextNum')
  59. }
  60. ccUtils.setRichLabel(Mgr.i18n.getEntryLabel(iEquip.cfg.entry), breakTip, 'scrollView/view/content/rtL/rt')
  61. }
  62. }