123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- /** @format */
- import {UI} from '../enums/UI'
- import {BaseUI} from './BaseUI'
- import {Data, Mgr} from '../GameControl'
- import {ccUtils} from '../utils/ccUtils'
- import {observer, render, node, label, editBox, list} from '../mobx/observer'
- import {msgCmd} from '../proto/msg_cmd'
- import {CallawardConfig} from '../config/CallawardConfig'
- import {RoleConfig} from '../config/RoleConfig'
- import {LANGUAGE_TYPE, PREFAB_TYPE, ROLE_TYPE} from '../enums/Enum'
- import {i18nLabel} from '../uiutils/i18nLabel'
- import List from '../uiutils/List'
- const {ccclass, property} = cc._decorator
- interface HEROIC_RANK {
- //英雄等级
- index: number
- color: string
- heroI18n: string
- equipI18n: string
- }
- interface HeroesCallConfig {
- ID: number //奖池
- points: number //库ID
- type: number //召唤类型
- priority: number //显示顺序
- quality: number //品质
- }
- @ccclass
- @observer
- export class RecruitPublicityUI extends BaseUI {
- @list('recruit_list')
- recruitList: List
- curShowPublicity: HeroesCallConfig[] = []
- heroicRank: HEROIC_RANK[] = [
- {index: 1, color: '#FFFFFF', heroI18n: LANGUAGE_TYPE.commonHero, equipI18n: LANGUAGE_TYPE.commonEquip}, //普通
- {
- index: 2,
- color: '#00FF00',
- heroI18n: LANGUAGE_TYPE.excellentHero,
- equipI18n: LANGUAGE_TYPE.excellentEquip,
- }, //优质
- {index: 3, color: '#03DEFB', heroI18n: LANGUAGE_TYPE.rareHero, equipI18n: LANGUAGE_TYPE.rareEquip}, //稀有
- {index: 4, color: '#8B4FE3', heroI18n: LANGUAGE_TYPE.eliteHero, equipI18n: LANGUAGE_TYPE.eliteEquip}, //精英
- {index: 5, color: '#FEF822', heroI18n: LANGUAGE_TYPE.legendaryEquip, equipI18n: LANGUAGE_TYPE.legendaryEquip}, //传说
- ]
- onShow(args, fromUI: number) {
- this.curShowPublicity = args
- this.recruitList.numItems = this.curShowPublicity.length
- this.recruitList.scrollTo(0, 0)
- }
- onHide(): any {
- Mgr.event.removeAll(this)
- }
- //英雄品级列表
- initRecruitItem(node: cc.Node, index: number) {
- let libraryList = CallawardConfig[this.curShowPublicity[index].points].show
- let quality = CallawardConfig[this.curShowPublicity[index].points].quality
- let odds = CallawardConfig[this.curShowPublicity[index].points].odds
- let i18n: string = ''
- let color: string = ''
- let oddsNode = cc.find('lbs/odds', node)
- let qualityNode = cc.find('lbs/quality', node)
- let rolesNode = ccUtils.instantChildren(cc.find('roles/item_parent', node), libraryList.length)
- for (let i = 0; i < rolesNode.length; i++) {
- Mgr.goods.initGoods([{id: libraryList[i], num: 0}], [cc.find('item/role_parent/role', rolesNode[i])], this)
- let roleCfg = RoleConfig[libraryList[i]]
- cc.find('role_type', rolesNode[i]).active = !!roleCfg
- if (roleCfg) {
- this.loadTexImg(`Public/role/role_type_${roleCfg.profession}`, rolesNode[i], 'role_type')
- let isOnly = roleCfg.type == ROLE_TYPE.only
- let special = cc.find('item/role_parent/item_special', rolesNode[i])
- if (special) {
- special.active = isOnly
- if (special.active) this.loadNotRefTexImg(`Public/role/item_special_frame${quality}`, special)
- }
- }
- }
- let {goodType} = Mgr.goods.getGoodShowInfo(libraryList[0])
- if (goodType == PREFAB_TYPE.goods) {
- //建筑材料
- i18n = LANGUAGE_TYPE.buildingMaterials
- color = '#FFFF00'
- } else if (goodType == PREFAB_TYPE.cardDebris) {
- //技能碎片
- i18n = LANGUAGE_TYPE.skillFragment
- color = '#FFFF00'
- } else {
- if (RoleConfig[libraryList[0]]) {
- i18n = this.heroicRank[quality - 1].heroI18n
- } else {
- i18n = this.heroicRank[quality - 1].equipI18n
- }
- color = this.heroicRank[quality - 1].color
- }
- ccUtils.setLabel(i18n, node, 'lbs/quality') //品级颜色
- ccUtils.setColor(color, node, 'lbs/quality')
- ccUtils.labelForceUpdateRenderData(node, 'lbs/quality')
- oddsNode.getComponent(i18nLabel).setParamByIndex(odds.toString() + '%', 0)
- oddsNode.x = qualityNode.x + qualityNode.width + 30
- }
- //UI或者其他函数=======================================
- //网络事件=======================================
- // onXXXRsp() {}
- //触发事件=======================================
- // @render
- // showRender() {}
- // 点击事件=======================================
- // onClick() {}
- }
|