RecruitPublicityUI.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /** @format */
  2. import {UI} from '../enums/UI'
  3. import {BaseUI} from './BaseUI'
  4. import {Data, Mgr} from '../GameControl'
  5. import {ccUtils} from '../utils/ccUtils'
  6. import {observer, render, node, label, editBox, list} from '../mobx/observer'
  7. import {msgCmd} from '../proto/msg_cmd'
  8. import {CallawardConfig} from '../config/CallawardConfig'
  9. import {RoleConfig} from '../config/RoleConfig'
  10. import {LANGUAGE_TYPE, PREFAB_TYPE, ROLE_TYPE} from '../enums/Enum'
  11. import {i18nLabel} from '../uiutils/i18nLabel'
  12. import List from '../uiutils/List'
  13. const {ccclass, property} = cc._decorator
  14. interface HEROIC_RANK {
  15. //英雄等级
  16. index: number
  17. color: string
  18. heroI18n: string
  19. equipI18n: string
  20. }
  21. interface HeroesCallConfig {
  22. ID: number //奖池
  23. points: number //库ID
  24. type: number //召唤类型
  25. priority: number //显示顺序
  26. quality: number //品质
  27. }
  28. @ccclass
  29. @observer
  30. export class RecruitPublicityUI extends BaseUI {
  31. @list('recruit_list')
  32. recruitList: List
  33. curShowPublicity: HeroesCallConfig[] = []
  34. heroicRank: HEROIC_RANK[] = [
  35. {index: 1, color: '#FFFFFF', heroI18n: LANGUAGE_TYPE.commonHero, equipI18n: LANGUAGE_TYPE.commonEquip}, //普通
  36. {
  37. index: 2,
  38. color: '#00FF00',
  39. heroI18n: LANGUAGE_TYPE.excellentHero,
  40. equipI18n: LANGUAGE_TYPE.excellentEquip,
  41. }, //优质
  42. {index: 3, color: '#03DEFB', heroI18n: LANGUAGE_TYPE.rareHero, equipI18n: LANGUAGE_TYPE.rareEquip}, //稀有
  43. {index: 4, color: '#8B4FE3', heroI18n: LANGUAGE_TYPE.eliteHero, equipI18n: LANGUAGE_TYPE.eliteEquip}, //精英
  44. {index: 5, color: '#FEF822', heroI18n: LANGUAGE_TYPE.legendaryEquip, equipI18n: LANGUAGE_TYPE.legendaryEquip}, //传说
  45. ]
  46. onShow(args, fromUI: number) {
  47. this.curShowPublicity = args
  48. this.recruitList.numItems = this.curShowPublicity.length
  49. this.recruitList.scrollTo(0, 0)
  50. }
  51. onHide(): any {
  52. Mgr.event.removeAll(this)
  53. }
  54. //英雄品级列表
  55. initRecruitItem(node: cc.Node, index: number) {
  56. let libraryList = CallawardConfig[this.curShowPublicity[index].points].show
  57. let quality = CallawardConfig[this.curShowPublicity[index].points].quality
  58. let odds = CallawardConfig[this.curShowPublicity[index].points].odds
  59. let i18n: string = ''
  60. let color: string = ''
  61. let oddsNode = cc.find('lbs/odds', node)
  62. let qualityNode = cc.find('lbs/quality', node)
  63. let rolesNode = ccUtils.instantChildren(cc.find('roles/item_parent', node), libraryList.length)
  64. for (let i = 0; i < rolesNode.length; i++) {
  65. Mgr.goods.initGoods([{id: libraryList[i], num: 0}], [cc.find('item/role_parent/role', rolesNode[i])], this)
  66. let roleCfg = RoleConfig[libraryList[i]]
  67. cc.find('role_type', rolesNode[i]).active = !!roleCfg
  68. if (roleCfg) {
  69. this.loadTexImg(`Public/role/role_type_${roleCfg.profession}`, rolesNode[i], 'role_type')
  70. let isOnly = roleCfg.type == ROLE_TYPE.only
  71. let special = cc.find('item/role_parent/item_special', rolesNode[i])
  72. if (special) {
  73. special.active = isOnly
  74. if (special.active) this.loadNotRefTexImg(`Public/role/item_special_frame${quality}`, special)
  75. }
  76. }
  77. }
  78. let {goodType} = Mgr.goods.getGoodShowInfo(libraryList[0])
  79. if (goodType == PREFAB_TYPE.goods) {
  80. //建筑材料
  81. i18n = LANGUAGE_TYPE.buildingMaterials
  82. color = '#FFFF00'
  83. } else if (goodType == PREFAB_TYPE.cardDebris) {
  84. //技能碎片
  85. i18n = LANGUAGE_TYPE.skillFragment
  86. color = '#FFFF00'
  87. } else {
  88. if (RoleConfig[libraryList[0]]) {
  89. i18n = this.heroicRank[quality - 1].heroI18n
  90. } else {
  91. i18n = this.heroicRank[quality - 1].equipI18n
  92. }
  93. color = this.heroicRank[quality - 1].color
  94. }
  95. ccUtils.setLabel(i18n, node, 'lbs/quality') //品级颜色
  96. ccUtils.setColor(color, node, 'lbs/quality')
  97. ccUtils.labelForceUpdateRenderData(node, 'lbs/quality')
  98. oddsNode.getComponent(i18nLabel).setParamByIndex(odds.toString() + '%', 0)
  99. oddsNode.x = qualityNode.x + qualityNode.width + 30
  100. }
  101. //UI或者其他函数=======================================
  102. //网络事件=======================================
  103. // onXXXRsp() {}
  104. //触发事件=======================================
  105. // @render
  106. // showRender() {}
  107. // 点击事件=======================================
  108. // onClick() {}
  109. }