168 lines
5.5 KiB
JavaScript
168 lines
5.5 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '832872xhfVOyKCm0NLOvxad', 'cmp.wing.scientfic.item');
|
||
|
|
// Scripts/mod/partner/wings/cmp/cmp.wing.scientfic.item.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/****************
|
||
|
|
* 僚机科研单项
|
||
|
|
*/
|
||
|
|
|
||
|
|
var ElfinController = require("elfin_controller");
|
||
|
|
var ElfinConst = require("elfin_const");
|
||
|
|
cc.Class({
|
||
|
|
"extends": cc.Component,
|
||
|
|
properties: {
|
||
|
|
icon: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node,
|
||
|
|
displayName: "宝箱底图"
|
||
|
|
},
|
||
|
|
nodStatus: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node,
|
||
|
|
displayName: "状态"
|
||
|
|
},
|
||
|
|
nodLock: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node,
|
||
|
|
displayName: "锁定状态"
|
||
|
|
},
|
||
|
|
nodTime: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node,
|
||
|
|
displayName: "时间显示"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onLoad: function onLoad() {},
|
||
|
|
freshAll: function freshAll(_data) {
|
||
|
|
var data = _data;
|
||
|
|
this.open = data.is_open;
|
||
|
|
this.state = data.state;
|
||
|
|
this.endTime = data.all_end_time;
|
||
|
|
this.info = _data;
|
||
|
|
this.setLocked();
|
||
|
|
this.setTime();
|
||
|
|
this.setStatus();
|
||
|
|
this.setIcon();
|
||
|
|
},
|
||
|
|
setLocked: function setLocked() {
|
||
|
|
var desc = game.configs.sprite_data.data_hatch_data[this.info.id];
|
||
|
|
if (this.nodLock) {
|
||
|
|
nx.gui.setActive(this.nodLock, "", this.open != 1);
|
||
|
|
nx.gui.setString(this.nodLock, "txt", desc.desc1);
|
||
|
|
}
|
||
|
|
if (nx.gui.find(this, "add")) {
|
||
|
|
nx.gui.setActive(nx.gui.find(this, "add"), "", this.open == 1);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
setTime: function setTime() {
|
||
|
|
//设置时间
|
||
|
|
|
||
|
|
nx.gui.setActive(this.nodTime, "", this.endTime != 0);
|
||
|
|
var wfg = game.configs.sprite_data.data_const.liaoji_materials;
|
||
|
|
var action = parseInt(this.info.do_id - wfg.val[0] + 1);
|
||
|
|
var cmp = nx.gui.getComponent(this, "finish", "nx.fx.spine");
|
||
|
|
if (this.endTime != 0) {
|
||
|
|
if (this.info.state == 1) {
|
||
|
|
if (cmp) {
|
||
|
|
cmp.stop();
|
||
|
|
cmp.load("resDB/effects/E80031/action", function (_e) {
|
||
|
|
if (!_e) {
|
||
|
|
cmp.action("action", true);
|
||
|
|
} else {
|
||
|
|
cmp.stop();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
this.setFreeCD(this.endTime);
|
||
|
|
}
|
||
|
|
if (this.info.state == 2) {
|
||
|
|
nx.gui.setString(this.nodTime, "txt", nx.text.getKey("elfin_hatch_item_4"));
|
||
|
|
if (cmp) {
|
||
|
|
cmp.stop();
|
||
|
|
cmp.load("resDB/effects/E80032/action", function (_e) {
|
||
|
|
if (!_e) {
|
||
|
|
cmp.action("action" + action, true);
|
||
|
|
} else {
|
||
|
|
cmp.stop();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (this.info.state == 0) {
|
||
|
|
nx.gui.setActive(this.nodTime, "", false);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
nx.gui.setActive(this, "finish", this.info.state != 0);
|
||
|
|
},
|
||
|
|
// 免费倒计时
|
||
|
|
setFreeCD: function setFreeCD(_dtFree) {
|
||
|
|
this.unscheduleAllCallbacks();
|
||
|
|
if (!nx.dt.numPositive(_dtFree, false)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var self = this;
|
||
|
|
// let rate = game.configs.sprite_data.data_const.hatch_rate.val;
|
||
|
|
var tick = function tick() {
|
||
|
|
var interval = Utils.getTimeInterval(_dtFree);
|
||
|
|
// console.log( "当前的倒计时" + interval );
|
||
|
|
if (interval <= 0) {
|
||
|
|
self.unscheduleAllCallbacks();
|
||
|
|
nx.gui.setString(self.nodTime, "txt", "");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var time = Utils.changeIntevalToDate(interval);
|
||
|
|
var txt = time.H + ":" + time.M + ":" + time.S;
|
||
|
|
nx.gui.setString(self.nodTime, "txt", txt);
|
||
|
|
};
|
||
|
|
this.schedule(tick, 1, cc.macro.REPEAT_FOREVER);
|
||
|
|
tick();
|
||
|
|
},
|
||
|
|
setStatus: function setStatus() {
|
||
|
|
if (this.info.is_open != 0 && this.info.is_open != 2) {
|
||
|
|
//设置状态
|
||
|
|
|
||
|
|
var clr = cc.Color.WHITE;
|
||
|
|
// let clr = ( this.state == ElfinConst.Hatch_Status.Hatch || this.state == ElfinConst.Hatch_Status.Over ) ? new cc.Color().fromHEX( "#066926" ) : new cc.Color().fromHEX("#896202");
|
||
|
|
var path = this.state == ElfinConst.Hatch_Status.Hatch ? cc.path.join("prefab/partner/wing/ui/partner_62") : this.state == ElfinConst.Hatch_Status.Over ? cc.path.join("prefab/partner/wing/ui/partner_61") : cc.path.join("prefab/partner/wing/ui/partner_62");
|
||
|
|
var pathbg = this.state == ElfinConst.Hatch_Status.Hatch || this.state == ElfinConst.Hatch_Status.Over ? "prefab/partner/wing/ui/partner_63" : "prefab/partner/wing/ui/partner_64";
|
||
|
|
nx.gui.setSpriteFrame(this.nodStatus, "bg", path);
|
||
|
|
nx.gui.setSpriteFrame(this, "sbg", pathbg);
|
||
|
|
nx.gui.setActive(this, "sbg", true);
|
||
|
|
nx.gui.setColor(this.nodStatus, "txt", clr);
|
||
|
|
nx.gui.setString(this.nodStatus, "txt", this.info.state == 0 ? nx.text.getKey("ScientficFree") : nx.text.getKey("ScientficState" + this.state));
|
||
|
|
} else {
|
||
|
|
nx.gui.setActive(this.nodLock, "tipSp", this.info.is_open == 2);
|
||
|
|
nx.gui.setString(this.nodStatus, "txt", nx.text.getKey("ScientficState" + this.state));
|
||
|
|
nx.gui.setActive(this, "sbg", false);
|
||
|
|
}
|
||
|
|
nx.gui.setActive(this.nodStatus, "", this.state != 0);
|
||
|
|
},
|
||
|
|
setIcon: function setIcon() {
|
||
|
|
var id = this.info.do_id;
|
||
|
|
var cfg = game.configs.sprite_data.data_const;
|
||
|
|
var cj = cfg.liaoji_materials.val[0];
|
||
|
|
var mj = cfg.liaoji_target.val[0];
|
||
|
|
var path = "";
|
||
|
|
if (id > 0) {
|
||
|
|
if (id == cj) {
|
||
|
|
path = "prefab/partner/wing/ui/partner_69";
|
||
|
|
} else if (id == mj) {
|
||
|
|
path = "prefab/partner/wing/ui/partner_70";
|
||
|
|
} else {
|
||
|
|
path = "prefab/partner/wing/ui/partner_68";
|
||
|
|
}
|
||
|
|
nx.gui.setSpriteFrame(this.icon, "", path);
|
||
|
|
nx.gui.setActive(this, "add", false);
|
||
|
|
} else {
|
||
|
|
nx.gui.setSpriteFrame(this.icon, "", "");
|
||
|
|
}
|
||
|
|
},
|
||
|
|
getInfo: function getInfo() {
|
||
|
|
return this.info;
|
||
|
|
},
|
||
|
|
onTouch: function onTouch() {}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|