1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import { _decorator, Label, Node, Sprite, SpriteFrame } from 'cc';
- import { ResKeeper } from '../../../framework/res/ResKeeper';
- import { StringUtil } from '../../../framework/util/StringUtil';
- import { EquipManager } from '../../manager/EquipManager';
- import { Framework } from '../../../framework/Framework';
- const { ccclass, property } = _decorator;
- @ccclass('EquipChooseItem')
- export class EquipChooseItem extends ResKeeper {
- @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: Sprite, tooltip: "穿戴按钮图" })
- wearBtnSp: Sprite = null;
- @property({ type: Label, tooltip: "穿戴按钮文字" })
- wearBtnTx: Label = null;
- private data = {};
- private wearEquip = null;
- protected onLoad() {
- this.fightTitie.string = StringUtil.getLanguageData('战力') + ': ';
- }
- protected onDestroy() {
- //如果该组件有事件自行取消注释
- //Framework.event.removeEvent(this);
- super.onDestroy();
- }
- //如果使用了池中的节点,在该函数内归还,该函数会在onDestroy前调用
- onClose() {
- }
- refreshItem(data, wearEquip) {
- this.data = data;
- this.wearEquip = wearEquip;
- if (wearEquip) {
- this.wearBtnTx.string = StringUtil.getLanguageData('替换');
- this.load('common', `texture/button/blue_btn_1/spriteFrame`, SpriteFrame, (res: SpriteFrame) => {
- this.wearBtnSp.spriteFrame = res;
- })
- } else {
- this.wearBtnTx.string = StringUtil.getLanguageData('装备');
- this.load('common', `texture/button/yellow_btn_1/spriteFrame`, SpriteFrame, (res: SpriteFrame) => {
- this.wearBtnSp.spriteFrame = res;
- })
- }
- this.nameTx.string = StringUtil.getLanguageData(data.conf.Name);
- this.fightTx.string = data.fightForce;
- }
- //UI事件处理
- private onTouchButton(event: Event) {
- //Framework.audio.playEffect(AudioID.Click);
- let target: any = event.target;
- if (target.name == 'wear_btn') {
- let args = { eid: this.data['id'], slot: this.data['conf']['Slot'], race: this.data['conf']['Race'] };
- EquipManager.sendWearMsg(args, () => {
- Framework.tips.setTips(StringUtil.getLanguageData('穿戴成功!'));
- })
- // if (this.wearEquip) {
- // }else{
- // }
- }
- }
- }
|