123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- import { _decorator, instantiate, Label, Node, Prefab, SpotLight, Sprite, tween, UIOpacity } from 'cc';
- import { BaseView } from '../../../framework/layer/BaseView';
- import { StringUtil } from '../../../framework/util/StringUtil';
- import { Equip } from '../../data/EquipData';
- import { EquipConf } from '../../config/EquipConf';
- import { CommonItem } from '../common/CommonItem';
- import { AttrAddTypeEnum, AttrEnum, EquipSlotEnum } from '../../common/InterfaceAddEnum';
- import { Framework } from '../../../framework/Framework';
- import { ViewID } from '../../../framework/config/LayerConf';
- const { ccclass, property } = _decorator;
- @ccclass('EquipOpreate')
- export class EquipOpreate extends BaseView {
- @property({ type: Label, tooltip: "关闭提示" })
- closeTips: Label = null;
- @property({ type: Label, tooltip: "标题" })
- titieTx: Label = null;
- @property({ type: Node, tooltip: "图标节点" })
- itemNode: Node = null;
- @property({ type: Label, tooltip: "名字" })
- nameTx: Label = null;
- @property({ type: Label, tooltip: "阵营" })
- posTx: Label = null;
- @property({ type: Label, tooltip: "部位" })
- slotTx: Label = null;
- @property({ type: Label, tooltip: "描述" })
- descTx: Label = null;
- @property({ type: Label, tooltip: "属性标题" })
- attrTitieTx: Label = null;
- @property({ type: Label, tooltip: "属性" })
- attrTx: Label = null;
- @property({ type: Sprite, tooltip: "替换/卸下按钮图" })
- wearBtnSp: Sprite = null;
- @property({ type: Label, tooltip: "替换/卸下按钮文字" })
- wearBtnTx: Label = null;
- @property({ type: Label, tooltip: "升级按钮文字" })
- updateBtnTx: Label = null;
- @property({ type: Node, tooltip: "强化按钮" })
- strongBtn: Node = null;
- @property({ type: Label, tooltip: "强化按钮文字" })
- strongBtnTx: Label = null;
- private _curRace: number = 0;
- private _curSlot: number = 0;
- private _curEquip: Equip = null;
- protected onLoad() {
- super.onLoad();
- this.closeTips.string = StringUtil.getLanguageData('点击空白关闭');
- this.titieTx.string = StringUtil.getLanguageData('装备详情');
- this.attrTitieTx.string = StringUtil.getLanguageData('属性加成');
- this.wearBtnTx.string = StringUtil.getLanguageData('替换');
- this.updateBtnTx.string = StringUtil.getLanguageData('升级');
- this.strongBtnTx.string = StringUtil.getLanguageData('突破');
- this.closeTips.node.getComponent(UIOpacity).opacity = 0;
- }
- 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;
- this._curEquip = data.equip;
- if (this._curEquip.conf['Quality'] < 5) {
- this.strongBtn.active = false;
- }
- this.updateUI();
- }
- //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);
- }else if (target.name == 'wear_btn') {
- let args = { race: this._curRace, slot: this._curSlot, equip: this._curEquip }
- Framework.layer.open(ViewID.EquipChoose, null, args);
- }else if (target.name == 'update_btn') {
- let args = { race: this._curRace, slot: this._curSlot, equip: this._curEquip }
- Framework.layer.open(ViewID.EquipUpdate, null, args);
- }else if (target.name == 'strong_btn') {
- // let args = { race: this._curRace, slot: this._curSlot, equip: this._curEquip }
- // Framework.layer.open(ViewID.EquipStrong, null, args);
- }
- }
- updateUI() {
- this.load('common', `prefab/CommonItem`, Prefab, (pre: Prefab) => {
- let item = instantiate(pre);
- this.itemNode.addChild(item);
- item.getComponent(CommonItem).refreshItem(this._curEquip);
- })
- this.nameTx.string = `${StringUtil.getLanguageData('装备名称')}: ${StringUtil.getLanguageData(this._curEquip.conf['Name'])}`;
- this.posTx.string = `${StringUtil.getLanguageData('阵营类型')}: ${StringUtil.getLanguageData('阵营' + this._curEquip.conf['Race'])}`;
- this.slotTx.string = `${StringUtil.getLanguageData('装备位置')}: ${StringUtil.getLanguageData('部位' + this._curEquip.conf['Slot'])}`;
- this.descTx.string = StringUtil.getLanguageData(this._curEquip.conf['Desc']);
- let attrStr = "";
- for (let index = 1; index <= 2; index++) {
- let Stat = this._curEquip.conf['Stat' + index];
- if (Stat != 0) {
- let attr = Stat.split(':');
- let attrConf = AttrEnum[attr[0]]
- let value = attrConf.type == AttrAddTypeEnum.reality ? ("+" + attr[1]) :
- ("+" + (100 * Number(attr[1])) + "%")
- attrStr = attrStr + StringUtil.getLanguageData(attrConf.name) + ' ' + value + "\n";
- }
- }
- this.attrTx.string = attrStr;
- }
- }
|