1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- /** @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 List from '../uiutils/List'
- import {ATTR_NAME, LANGUAGE_TYPE} from '../enums/Enum'
- import {IBaseAttr, IRole} from '../interface/GlobalInterface'
- import {ArmorConfig} from '../config/ArmorConfig'
- const {ccclass, property} = cc._decorator
- @ccclass
- @observer
- export class EquipAttrUI extends BaseUI {
- @list('attrList')
- attrList: List
- @list('entryList')
- entryList: List
- entryData: number[] = []
- attrKeys: ATTR_NAME[] = [
- ATTR_NAME.HP,
- ATTR_NAME.defense,
- ATTR_NAME.attack,
- ATTR_NAME.spellAttack,
- ATTR_NAME.spellDefense,
- ATTR_NAME.attackCrit,
- ATTR_NAME.critNum,
- ATTR_NAME.dodge,
- ATTR_NAME.hit,
- ]
- allAttr: IBaseAttr
- onShow(args: IRole, fromUI: number) {
- this.entryData.length = 0
- let allAttr = Mgr.global.buildIBaseAttr(null, true)
- for (let equip of args.equips) {
- if (equip) {
- let baseID = equip.cfg.ID - (equip.cfg.ID % 100) + 1
- for (let i = baseID; i <= equip.cfg.ID; i++) {
- if (ArmorConfig[i].entry) this.entryData.push(ArmorConfig[i].entry)
- }
- Mgr.global.changeBaseAttr(allAttr, equip, true)
- }
- }
- this.allAttr = allAttr
- this.entryList.numItems = this.entryData.length
- this.attrList.numItems = this.attrKeys.length
- }
- initEntryItem(node, index) {
- let richTextNode = cc.find('richText', node)
- ccUtils.setRichLabel(Mgr.i18n.getEntryLabel(this.entryData[index]), richTextNode)
- this.scheduleOnce(() => {
- if (node.activeInHierarchy) {
- let layout = node.getComponent(cc.Layout)
- layout.resizeMode =
- richTextNode.height < 60 ? cc.Layout.ResizeMode.NONE : cc.Layout.ResizeMode.CONTAINER
- layout.updateLayout()
- if (richTextNode.height < 60) {
- node.height = 60
- }
- }
- })
- }
- initAttrItem(node, index) {
- let attrName = this.attrKeys[index]
- let rateKey = [ATTR_NAME.attackCrit, ATTR_NAME.critNum, ATTR_NAME.dodge, ATTR_NAME.hit]
- let num: string = rateKey.includes(attrName)
- ? Math.floor(this.allAttr[attrName] / Data.game.rateNum) + '%'
- : this.allAttr[attrName]
- ccUtils.setLabel(num, node, 'attrNum')
- ccUtils.setLabel(LANGUAGE_TYPE[attrName], node, 'attrName')
- this.loadTexImg(`Public/allAttr/${attrName}`, node, 'icon')
- }
- }
|