RoleUpgradeUI.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /** @format */
  2. import {BaseUI} from './BaseUI'
  3. import {Data, Mgr} from '../GameControl'
  4. import {ccUtils} from '../utils/ccUtils'
  5. import {observer, node, label} from '../mobx/observer'
  6. import {IRoleLevelConfig, RoleLevelConfig} from '../config/RoleLevelConfig'
  7. import {EVENT} from '../enums/Enum'
  8. import {i18nLabel} from '../uiutils/i18nLabel'
  9. import {idNum} from '../proto/typedef'
  10. import {IRewardNty} from '../interface/UIInterface'
  11. import {IRanksLevelConfig, RanksLevelConfig} from '../config/RanksLevelConfig'
  12. import {SOUND} from '../enums/Sound'
  13. const {ccclass, property} = cc._decorator
  14. @ccclass
  15. @observer
  16. export class RoleUpgradeUI extends BaseUI {
  17. @node('rewardBox')
  18. rewardBox: cc.Node
  19. @node('levelLb')
  20. levelLb: cc.Node
  21. @node('rewardBox/rewardItem')
  22. rewarditem: cc.Node
  23. @node('dec_effect_1')
  24. effect: cc.Node
  25. @label('congratLb')
  26. upLevelI18n: cc.Label
  27. rewards: idNum[]
  28. onShow(args: IRewardNty, fromUI: number) {
  29. Mgr.audio.playSFX(SOUND.roleLvUp)
  30. this.rewards = args.changeArr
  31. //特效缓动
  32. cc.tween(this.effect).by(-1, {angle: -1}).repeatForever().start()
  33. //显示等级
  34. ccUtils.setLabel(Data.user.level.toString(), this.levelLb)
  35. this.upLevelI18n.getComponent(i18nLabel).setParamByIndex(Data.user.level.toString(), 0)
  36. //显示奖励
  37. let goodsNode = ccUtils.instantChildren(this.rewarditem, this.rewards.length)
  38. Mgr.goods.initGoods(this.rewards, goodsNode, this)
  39. }
  40. onDisable(): any {
  41. //显示动效
  42. let index = 0
  43. this.rewards.forEach(goods => {
  44. let starPos = ccUtils.convertToWorldSpaceCanvasAR(this.rewardBox.children[index])
  45. Mgr.goods.flyGoods(goods.id, starPos, () => {
  46. Mgr.event.trigger(EVENT.goodsChangeSync, goods.id, goods.num)
  47. })
  48. index += 1
  49. })
  50. Mgr.event.removeAll(this)
  51. Mgr.event.trigger(EVENT.mainPopAnyUI)
  52. }
  53. //UI或者其他函数=======================================
  54. //网络事件=======================================
  55. //触发事件=======================================
  56. // 点击事件=======================================
  57. }