import { _decorator, Label, Node, tween, UIOpacity } from 'cc'; import { BaseView } from '../../../framework/layer/BaseView'; import { EquipChooseItem } from './EquipChooseItem'; import { StringUtil } from '../../../framework/util/StringUtil'; import List from '../../../framework/list/List'; import { EquipManager } from '../../manager/EquipManager'; import { Framework } from '../../../framework/Framework'; const { ccclass, property } = _decorator; @ccclass('EquipChoose') export class EquipChoose extends BaseView { @property({ type: Label, tooltip: "关闭提示" }) closeTips: Label = null; @property({ type: Label, tooltip: "标题" }) titieTx: Label = null; @property({ type: Node, tooltip: "穿戴装备节点" }) wearNode: Node = null; @property({ type: Label, tooltip: "列表空提示" }) equipListNoneTx: Label = null; @property({ type: List, tooltip: "列表" }) equipList: List = null; @property({ type: Node, tooltip: "装备节点" }) itemNode: Node = null; @property({ type: Label, tooltip: "装备名" }) nameTx: Label = null; @property({ type: Label, tooltip: "战力标题" }) fightTitie: Label = null; @property({ type: Label, tooltip: "战力文字" }) fightTx: Label = null; @property({ type: Label, tooltip: "穿戴文字" }) wearTx: Label = null; private _curRace: number = 0; private _curSlot: number = 0; private _equipsData: any[] = []; private _curEquip: any = null; start() { } protected onLoad() { super.onLoad(); this.closeTips.string = StringUtil.getLanguageData('点击空白关闭'); this.titieTx.string = StringUtil.getLanguageData('装备选择'); this.wearTx.string = StringUtil.getLanguageData('当前穿戴'); this.fightTitie.string = StringUtil.getLanguageData('战力') + ': '; this.equipListNoneTx.string = StringUtil.getLanguageData('暂无可用装备装备'); this.closeTips.node.getComponent(UIOpacity).opacity = 0; this.wearNode.active = false; } protected onDestroy() { } //UI开打时会调用,如果有初始化代码应该放到此函数 onOpen(data) { tween(this.closeTips.node.getComponent(UIOpacity)) .to(1, { opacity: 255 }) .to(1.2, { opacity: 10 }) .union() .repeatForever() .start() this._curRace = data.race; this._curSlot = data.slot; if (data.equip) { this._curEquip = data.equip; this.wearNode.active = true; } this._equipsData = EquipManager.getEquipRaceSlotGroup(data.race)[data.slot]; this.equipListNoneTx.node.active = this._equipsData.length == 0; this.equipList.numItems = this._equipsData.length; } //UI关闭时会调用,该函数在onDestroy前调用 onClose() { } //框架管理UI层级时会调用,可根据UI情况修改 onShow() { super.onShow(); } //框架管理UI层级时会调用,可根据UI情况修改 onHide() { super.onHide(); } //UI事件处理 private onTouchButton(event: Event) { //Framework.audio.playEffect(AudioID.Click); let target: any = event.target; if (target.name == 'mask') { Framework.layer.close(this); } } onEventList(item, idx) { item.getComponent(EquipChooseItem).refreshItem(this._equipsData[idx], this._curEquip); } }