209 lines
7.6 KiB
TypeScript
209 lines
7.6 KiB
TypeScript
import PopupManager from "../../ts/gear_2.3.4/manager/PopupManager";
|
|
import SKLogger from "../gear_2.3.4/util/SKLogger";
|
|
import ItemUtil from "../../ts/core/ItemUtil";
|
|
import GameModel from "../core/GameModel";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class NewClass extends cc.Component {
|
|
|
|
@property(cc.Button)
|
|
doBtn: cc.Button = null;
|
|
|
|
@property(cc.Button)
|
|
closeBtn: cc.Button = null;
|
|
|
|
@property(cc.Button)
|
|
infoBtn: cc.Button = null;
|
|
|
|
@property(cc.Node)
|
|
circle: cc.Node = null;
|
|
|
|
@property(cc.Sprite)
|
|
needProp1Icon: cc.Sprite = null;
|
|
|
|
@property(cc.Sprite)
|
|
needProp2Icon: cc.Sprite = null;
|
|
|
|
@property(cc.Sprite)
|
|
needProp3Icon: cc.Sprite = null;
|
|
|
|
@property(cc.Sprite)
|
|
baldricIcon: cc.Sprite = null;
|
|
|
|
@property(cc.Sprite)
|
|
maskIcon: cc.Sprite = null;
|
|
|
|
@property(cc.Label)
|
|
tipLabel: cc.Label = null;
|
|
|
|
@property(cc.Label)
|
|
warnLabel: cc.Label = null;
|
|
|
|
@property(cc.Label)
|
|
needGoldLabel: cc.Label = null;
|
|
|
|
@property(cc.Label)
|
|
material1haveLabel: cc.Label = null;
|
|
|
|
@property(cc.Label)
|
|
material2haveLabel: cc.Label = null;
|
|
|
|
@property(cc.Label)
|
|
material3haveLabel: cc.Label = null;
|
|
|
|
@property(cc.Prefab)
|
|
item_detail: cc.Prefab = null;
|
|
|
|
itemInfo: any = null;
|
|
material1num: number = 0;
|
|
material2num: number = 0;
|
|
material3num: number = 0;
|
|
canDo: Boolean = true;//可以進行鑑定
|
|
skipAnimation: boolean = true;//默認跳過動畫
|
|
onLoad() {
|
|
this.doBtn.node.on("click", this.onDoBtnClick, this);
|
|
this.closeBtn.node.on("click", this.onCloseClick, this);
|
|
this.needProp1Icon.spriteFrame = ItemUtil.getItemIconBy({ icon: 10407 });
|
|
this.needProp2Icon.spriteFrame = ItemUtil.getItemIconBy({ icon: 6101 });
|
|
this.needProp3Icon.spriteFrame = ItemUtil.getItemIconBy({ icon: 10409 });
|
|
this.maskIcon.spriteFrame = ItemUtil.getItemIconBy({ icon: 1000 });
|
|
this.warnLabel.string = "";
|
|
this.tipLabel.string = "點擊按鈕進行配飾鑑定";
|
|
var skipBtn = cc.find("checkBtn", this.node);
|
|
skipBtn.on("click", this.skipAni, this)
|
|
}
|
|
skipAni() {
|
|
this.skipAnimation = !this.skipAnimation
|
|
var duigou = cc.find("skip", this.node);
|
|
if (duigou) {
|
|
duigou.active = this.skipAnimation
|
|
}
|
|
}
|
|
// 初始化面板
|
|
initPanel(data) {
|
|
this.itemInfo = data;
|
|
var iconId = ItemUtil.getItemData(data.Type).icon;
|
|
this.baldricIcon.spriteFrame = ItemUtil.getItemIconBy({ icon: iconId });
|
|
var goodsList = GameModel.player.itemList;
|
|
this.material1num = goodsList["10407"] == null ? 0 : goodsList["10407"]
|
|
this.material2num = goodsList["10405"] == null ? 0 : goodsList["10405"]
|
|
this.material3num = goodsList["10409"] == null ? 0 : goodsList["10409"]
|
|
this.material1num < 1 && (this.material1haveLabel.node.color = new cc.Color(255, 0, 0))
|
|
this.material2num < 1 && (this.material2haveLabel.node.color = new cc.Color(255, 0, 0))
|
|
this.material3num < 1 && (this.material3haveLabel.node.color = new cc.Color(255, 0, 0))
|
|
this.material1haveLabel.string = this.material1num.toString();
|
|
this.material2haveLabel.string = this.material2num.toString();
|
|
this.material3haveLabel.string = this.material3num.toString();
|
|
this.needProp1Icon.node.parent.on("click", this.selected1, this);
|
|
this.needProp2Icon.node.parent.on("click", this.selected2, this);
|
|
this.needProp3Icon.node.parent.on("click", this.selected3, this);
|
|
}
|
|
|
|
onCloseClick() {
|
|
PopupManager.closeView(this.node.name);
|
|
}
|
|
|
|
onDoBtnClick() {
|
|
if (!this.canDo) return
|
|
GameModel.send('c2s_acc_authenticate', {
|
|
roleid: GameModel.player.roleid,
|
|
equipid: this.itemInfo.EquipID
|
|
});
|
|
this.canDo = false
|
|
this.doBtn.node.off("click", this.onDoBtnClick, this);
|
|
this.doBtn.interactable = false;
|
|
}
|
|
|
|
appraisalSuccess(data) {
|
|
// 材料數量變化
|
|
for (var i = 1; i < 4; i++) {
|
|
--this["material" + (i).toString() + "num"] < 1 && (this["material" + (i).toString() + "haveLabel"].node.color = new cc.Color(255, 0, 0))
|
|
this["material" + (i).toString() + "haveLabel"].string = this["material" + (i).toString() + "num"].toString();
|
|
}
|
|
var self = this;
|
|
if (this.skipAnimation) {
|
|
let url = `Prefabs/Accessory/accessory_jianding_result_bg`;
|
|
cc.loader.loadRes(url, cc.Prefab, (error, prefab) => {
|
|
if (error) {
|
|
SKLogger.warn(`$警告:加載資源${url}錯誤!`);
|
|
return;
|
|
}
|
|
PopupManager.showView(prefab, 0, (node) => {
|
|
// var jsScript = node.getComponent("Appraisal");
|
|
// jsScript && jsScript.initPanel(this.itemData)
|
|
PopupManager.closeView("accessory_main_third");
|
|
node.getComponent("AppraisalResult").loadBaldricInfo(this.itemInfo, data, true)
|
|
});
|
|
});
|
|
return
|
|
}
|
|
cc.tween(this.circle)
|
|
.by(0.5, { rotation: 180 })
|
|
.call(() => {
|
|
let url = `ui/appraisal/1043`;
|
|
|
|
cc.loader.loadRes(url, cc.SpriteAtlas, (error, atlas) => {
|
|
if (error) {
|
|
cc.warn(`$警告:加載角色動畫資源失敗${url}`);
|
|
return;
|
|
}
|
|
let curFrames = atlas.getSpriteFrames();
|
|
let curClip = cc.AnimationClip.createWithSpriteFrames(curFrames, 15);
|
|
curClip.name = "auth";
|
|
curClip.wrapMode = cc.WrapMode.Normal;
|
|
|
|
let nodeAni = self.node.getChildByName("ani").getComponent(cc.Animation);
|
|
if (nodeAni) {
|
|
nodeAni.addClip(curClip);
|
|
nodeAni.play("auth");
|
|
}
|
|
})
|
|
})
|
|
.delay(1.5)
|
|
.call(() => {
|
|
let url = `Prefabs/Accessory/accessory_jianding_result_bg`;
|
|
cc.loader.loadRes(url, cc.Prefab, (error, prefab) => {
|
|
if (error) {
|
|
SKLogger.warn(`$警告:加載資源${url}錯誤!`);
|
|
return;
|
|
}
|
|
PopupManager.showView(prefab, 0, (node) => {
|
|
// var jsScript = node.getComponent("Appraisal");
|
|
// jsScript && jsScript.initPanel(this.itemData)
|
|
PopupManager.closeView("accessory_main_third");
|
|
node.getComponent("AppraisalResult").loadBaldricInfo(this.itemInfo, data, false)
|
|
});
|
|
});
|
|
})
|
|
.start()
|
|
}
|
|
selected1() {
|
|
let data = ItemUtil.getItemData(10407);
|
|
data.count = 0;
|
|
this.selected(data)
|
|
}
|
|
selected2() {
|
|
let data = ItemUtil.getItemData(10405);
|
|
data.count = 0;
|
|
this.selected(data)
|
|
}
|
|
selected3() {
|
|
let data = ItemUtil.getItemData(10409);
|
|
data.count = 0;
|
|
this.selected(data)
|
|
}
|
|
selected(info) {
|
|
if (info != null && this.item_detail != null) {
|
|
let canvas = cc.find('Canvas');
|
|
if (canvas.getChildByName('BagItemDetail') == null) {
|
|
let detail = cc.instantiate(this.item_detail);
|
|
detail.parent = canvas;
|
|
detail.name = 'BagItemDetail';
|
|
detail.getComponent('BagItemDetail').loadInfo(info);
|
|
}
|
|
}
|
|
}
|
|
}
|