300 lines
8.8 KiB
JavaScript
300 lines
8.8 KiB
JavaScript
// Learn cc.Class:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
|
|
// Learn Attribute:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
|
|
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
var battlenet = require("battlenetmanage");
|
|
var SDKManage = require("SDKManage");
|
|
var NetManage = require("NetManage");
|
|
var Main = require("Main");
|
|
var Utils = require("Utils");
|
|
var playerData = require("playerData");
|
|
var gameConfig = require("gameConfig");
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
lb_time: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
|
|
btn_fuhuo: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
pro: {
|
|
default: null,
|
|
type: cc.ProgressBar,
|
|
},
|
|
|
|
anibody: {
|
|
default: null,
|
|
type: cc.Animation,
|
|
},
|
|
|
|
nd_gou: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
nd_gou2: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
nd_tips: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
nd_tips2: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
lb_text: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
|
|
nd_player: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
nd_view: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
nd_rmb: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
lb_rmbnum: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
onLoad() {
|
|
this.rev_flag = false;
|
|
cc.Notifier.on("fightRevive", this, this.fightRevive.bind(this));
|
|
},
|
|
|
|
onDestroy() {
|
|
cc.Notifier.off("fightRevive", this);
|
|
},
|
|
|
|
setdata(t, isT) {
|
|
this.nd_tips.active = false;
|
|
this.nd_tips2.active = false;
|
|
if (Main.config.mainConfig.ad_video_switch) {
|
|
this.nd_tips2.active = true;
|
|
this.nd_gou2.active = true;
|
|
} else {
|
|
this.nd_tips.active = true;
|
|
this.nd_gou.active = true;
|
|
}
|
|
cc.Notifier.emit("notbtnhack");
|
|
playerData.fight_status = 1;
|
|
this.time = 10;
|
|
this.lb_time.string = this.time;
|
|
this.lb_time.node.color = cc.Color.WHITE;
|
|
this.btn_fuhuo.active = true;
|
|
this.bindtext();
|
|
this.pro.progress = this.time / 10;
|
|
this.showPlayer();
|
|
this.anibody.play("ui_revive_open");
|
|
//this.nd_gou.active = true
|
|
this.lb_text.string = cc.language.stringformat("bianshenfuhuo");
|
|
SDKManage.logEvent("revive_ui", "fuhuo");
|
|
|
|
this.nd_view.active = false;
|
|
this.nd_rmb.active = false;
|
|
if (
|
|
parseInt(
|
|
gameConfig.parameterConfig["ui_zhanqian_show"].param_value
|
|
) != 0
|
|
) {
|
|
this.nd_view.active = true;
|
|
} else {
|
|
this.nd_rmb.active = true;
|
|
this.lb_rmbnum.string = parseInt(
|
|
gameConfig.parameterConfig["revive_money"].param_value
|
|
);
|
|
}
|
|
//
|
|
// if (playerData.recdaily_list[0].forever == 3) {
|
|
// this.nd_view.active = false
|
|
// this.nd_rmb.active = false
|
|
// this.time = 5;
|
|
// this.lb_time.string = this.time
|
|
// }
|
|
},
|
|
|
|
changeReviveStatus() {
|
|
if (Main.config.mainConfig.ad_video_switch) {
|
|
if (this.nd_gou2.active == false) {
|
|
cc.Notifier.emit("notbtnhack");
|
|
this.nd_gou2.active = true;
|
|
this.lb_text.string = cc.language.stringformat("bianshenfuhuo");
|
|
} else {
|
|
cc.Notifier.emit("openbtnhack");
|
|
this.nd_gou2.active = false;
|
|
this.lb_text.string = cc.language.stringformat("close");
|
|
}
|
|
} else {
|
|
if (this.nd_gou.active == false) {
|
|
cc.Notifier.emit("notbtnhack");
|
|
this.nd_gou.active = true;
|
|
this.lb_text.string = cc.language.stringformat("bianshenfuhuo");
|
|
} else {
|
|
cc.Notifier.emit("openbtnhack");
|
|
this.nd_gou.active = false;
|
|
this.lb_text.string = cc.language.stringformat("close");
|
|
}
|
|
}
|
|
},
|
|
|
|
fightRevive(obj) {
|
|
if (obj.errcode == 0) {
|
|
this.node.active = false;
|
|
battlenet.sendRevive();
|
|
playerData.bannerflag = true;
|
|
SDKManage.logEvent("revive_battle_join", "fuhuo");
|
|
} else {
|
|
this.rev_flag = false;
|
|
cc.uiHelper.showTips(cc.language.stringformat("dianjuanbuzu"));
|
|
}
|
|
},
|
|
|
|
clickrevive() {
|
|
if (Main.config.mainConfig.ad_video_switch) {
|
|
this.clickrevive2();
|
|
} else {
|
|
if (this.nd_gou.active == true) {
|
|
this.rev_flag = true;
|
|
this.viewrevive();
|
|
} else {
|
|
this.clickover();
|
|
SDKManage.logEvent("revive_close", "leave");
|
|
}
|
|
}
|
|
},
|
|
|
|
clickrmbrevive() {
|
|
if (
|
|
Number(playerData.rmb_num) <
|
|
parseInt(gameConfig.parameterConfig["revive_money"].param_value)
|
|
) {
|
|
cc.uiHelper.showTips(cc.language.stringformat("dianjuanbuzu"));
|
|
this.rev_flag = false;
|
|
} else {
|
|
NetManage.fightRevive();
|
|
}
|
|
},
|
|
|
|
viewrevive() {
|
|
var self = this;
|
|
var cb = function () {
|
|
self.node.active = false;
|
|
battlenet.sendRevive();
|
|
playerData.bannerflag = true;
|
|
SDKManage.logEvent("revive_battle_join", "fuhuo");
|
|
};
|
|
var cbf = function () {
|
|
self.rev_flag = false;
|
|
};
|
|
SDKManage.Share("revive", null, cb, cbf);
|
|
},
|
|
|
|
clickrevive2() {
|
|
if (this.nd_gou2.active == true) {
|
|
this.rev_flag = true;
|
|
|
|
this.viewrevive();
|
|
SDKManage.logEvent("revive_ok", "fuhuo");
|
|
} else {
|
|
this.clickover();
|
|
SDKManage.logEvent("revive_close", "leave");
|
|
}
|
|
},
|
|
|
|
clickover() {
|
|
var self = this;
|
|
setTimeout(() => {
|
|
// self.node.active = false
|
|
battlenet.sendGameOver();
|
|
}, 500);
|
|
},
|
|
|
|
showPlayer() {
|
|
var res = {
|
|
cloth_id: playerData.cloth_id,
|
|
hair_id: playerData.hair_id,
|
|
color_id: playerData.color_id,
|
|
hat_id: playerData.hat_id,
|
|
sex: playerData.sex,
|
|
};
|
|
this.nd_player.getComponent("uiplayershow").refresh(res);
|
|
},
|
|
|
|
bindtext() {
|
|
this.textConfig = {
|
|
1: {
|
|
text: cc.language.stringformat("fuhuohua1"),
|
|
},
|
|
2: {
|
|
text: cc.language.stringformat("fuhuohua2"),
|
|
},
|
|
3: {
|
|
text: cc.language.stringformat("fuhuohua3"),
|
|
},
|
|
};
|
|
this.newbieNodes = {};
|
|
this.needNewbie = true;
|
|
},
|
|
|
|
update(dt) {
|
|
if (this.rev_flag) {
|
|
return;
|
|
}
|
|
if (this.time > 0) {
|
|
this.time -= dt;
|
|
if (this.time <= 0) {
|
|
this.time = 0;
|
|
//this.btn_fuhuo.active = false
|
|
//
|
|
// if (playerData.recdaily_list[0].forever == 3) {
|
|
// this.rev_flag = true
|
|
// this.node.active = false
|
|
// battlenet.sendRevive()
|
|
// playerData.bannerflag = true
|
|
// } else {
|
|
this.lb_text.string = cc.language.stringformat("close");
|
|
this.lb_time.string = " ";
|
|
this.clickover();
|
|
this.anibody.play("ui_revive_close");
|
|
SDKManage.logEvent("revive_auto_close", "fuhuo");
|
|
//}
|
|
} else {
|
|
var num = Math.ceil(this.time);
|
|
if (num <= 3) {
|
|
this.lb_time.node.color = cc.Color.RED;
|
|
}
|
|
this.lb_time.string = num;
|
|
}
|
|
this.pro.progress = this.time / 10;
|
|
}
|
|
},
|
|
});
|