538 lines
18 KiB
JavaScript
538 lines
18 KiB
JavaScript
var gameConfig = require("gameConfig")
|
|
var playerData = require("playerData")
|
|
var SDKManage = require("SDKManage")
|
|
var NetManage = require("NetManage")
|
|
var battlenet = require("battlenetmanage")
|
|
var wxVoice = require("wxVoice")
|
|
var Main = require("Main")
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
btn_wudian:{
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
pr_jindu:{
|
|
default: null,
|
|
type: cc.ProgressBar,
|
|
},
|
|
nd_rad:{
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
pr_time:{
|
|
default: null,
|
|
type: cc.ProgressBar,
|
|
},
|
|
ani_rad:{
|
|
default: null,
|
|
type: cc.Animation,
|
|
},
|
|
|
|
items:{
|
|
default: [],
|
|
type: cc.Sprite
|
|
},
|
|
|
|
//clickv:0.1,
|
|
updatev:0.01,
|
|
time2:4,
|
|
waittime:2,
|
|
waittime2:2,
|
|
bannerpro:0.8,
|
|
rewardpro:0.6,
|
|
bannertime:2,
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad () {
|
|
cc.Notifier.on('getfuckboxreward',this, this.getfuckboxreward.bind(this));
|
|
this.time=2
|
|
this.clickv = 0.1
|
|
if (Main.config.mainConfig.fuckbox_num) {
|
|
this.clickv = Main.config.mainConfig.fuckbox_num
|
|
}
|
|
},
|
|
|
|
onDestroy () {
|
|
cc.Notifier.off('getfuckboxreward',this);
|
|
},
|
|
|
|
start () {
|
|
this.fuckboxinfo()
|
|
},
|
|
|
|
|
|
getfuckboxreward(obj){
|
|
if (this&&this.node){
|
|
for (var i = 0; i < this.items.length; i++) {
|
|
this.items[i].spriteFrame = null
|
|
}
|
|
|
|
for (var i = 0; i < obj.item_list.length; i++) {
|
|
this.showicon(obj.item_list[i].item_id, i)
|
|
}
|
|
|
|
this.time = this.waittime
|
|
this.ani_rad.play("ui_adrewardbox")
|
|
}
|
|
|
|
},
|
|
|
|
fuckboxinfo(){
|
|
if (playerData.boxid == 10) {
|
|
SDKManage.logEvent("hackbox_fight_ui", "clickbox")
|
|
} else if (playerData.boxid == 11) {
|
|
SDKManage.logEvent("hackbox_login_ui", "clickbox")
|
|
} else if (playerData.boxid == 12) {
|
|
SDKManage.logEvent("hackbox_ready_ui", "clickbox")
|
|
} else if (playerData.boxid == 13) {
|
|
SDKManage.logEvent("hackbox_gameover_ui", "clickbox")
|
|
}
|
|
|
|
|
|
if (playerData.boxid) {
|
|
this.boxid = playerData.boxid
|
|
} else {
|
|
this.boxid = 11
|
|
}
|
|
this.btn_wudian.active=false
|
|
this.pr_jindu.progress = 0
|
|
this.nd_rad.active = false
|
|
this.totaltime = this.time
|
|
},
|
|
|
|
onClickwudian(){
|
|
console.log("wudian")
|
|
if (playerData.boxid == 10) {
|
|
SDKManage.logEvent("hackbox_fight_ok", "clickbox")
|
|
} else if (playerData.boxid == 11) {
|
|
SDKManage.logEvent("hackbox_login_ok", "clickbox")
|
|
} else if (playerData.boxid == 12) {
|
|
SDKManage.logEvent("hackbox_ready_ok", "clickbox")
|
|
} else if (playerData.boxid == 13) {
|
|
SDKManage.logEvent("hackbox_gameover_ok", "clickbox")
|
|
}
|
|
|
|
this.clickwudian = true
|
|
this.btn_wudian.active = false
|
|
},
|
|
onClickbox(){
|
|
if (!this.firstclick) {
|
|
this.firstclick = true
|
|
if (playerData.boxid == 10) {
|
|
SDKManage.logEvent("hackbox_fight_click", "clickbox")
|
|
} else if (playerData.boxid == 11) {
|
|
SDKManage.logEvent("hackbox_login_click", "clickbox")
|
|
} else if (playerData.boxid == 12) {
|
|
SDKManage.logEvent("hackbox_ready_click", "clickbox")
|
|
} else if (playerData.boxid == 13) {
|
|
SDKManage.logEvent("hackbox_gameover_click", "clickbox")
|
|
}
|
|
}
|
|
if(this.waitting){
|
|
return
|
|
}
|
|
this.pr_jindu.progress+=this.clickv
|
|
|
|
if (this.showbanner) {
|
|
return
|
|
}
|
|
|
|
if(this.pr_jindu.progress>=1){
|
|
//this.btn_wudian.active = true
|
|
// this.waitting = true
|
|
// this.time = this.waittime
|
|
this.nd_rad.active = true
|
|
this.ani_rad.play("ui_adrewardbox")
|
|
this.waitting=true
|
|
NetManage.getFuckBoxReward(this.boxid)
|
|
// if (cc.isbattle){
|
|
// battlenet.sendBaoxiang()
|
|
// this.waitting=true
|
|
// this.time = this.waittime
|
|
// this.ani_rad.play("ui_adrewardbox")
|
|
// } else {
|
|
|
|
// }
|
|
//battlenet.sendBaoxiang()
|
|
}
|
|
|
|
if (this.pr_jindu.progress>=this.bannerpro){
|
|
this.showbanner = true
|
|
cc.Notifier.emit('boxhack')
|
|
console.log("wudian")
|
|
if (playerData.boxid == 10) {
|
|
SDKManage.logEvent("hackbox_fight_ok", "clickbox")
|
|
} else if (playerData.boxid == 11) {
|
|
SDKManage.logEvent("hackbox_login_ok", "clickbox")
|
|
} else if (playerData.boxid == 12) {
|
|
SDKManage.logEvent("hackbox_ready_ok", "clickbox")
|
|
} else if (playerData.boxid == 13) {
|
|
SDKManage.logEvent("hackbox_gameover_ok", "clickbox")
|
|
}
|
|
this.clickwudian = true
|
|
//this.btn_wudian.active = true
|
|
}
|
|
},
|
|
|
|
onNewStart(){
|
|
var arr = []
|
|
var a1 = {key:17001,value:0}
|
|
var a2 = {key:17002,value:0}
|
|
arr.push(a1)
|
|
arr.push(a2)
|
|
|
|
var newequip_data = {
|
|
"weapon_id":21003,
|
|
"weapon_lv":6,
|
|
"ammo":100
|
|
}
|
|
|
|
|
|
var self = this
|
|
battlenet.initengine({
|
|
account_id:NetManage.account_id,//
|
|
player_count:1,//
|
|
energy_shield:1,//
|
|
baseskin:[9,13009,15009,1],//
|
|
team_uuid:'', //
|
|
team_mode:0,//
|
|
auto_fill:false,//
|
|
weapons:[newequip_data],
|
|
first_game:false,
|
|
skins:[],
|
|
prepare_items:[12128, 12802],
|
|
prepare_items2:arr,
|
|
atk_add:0,
|
|
battlecount:1,
|
|
pre_settlement_info:Number(playerData.game_times) + ',' + Number(playerData.win_times) + ',' + Number(playerData.kills) + ',' + 1,
|
|
emojis:playerData.emojis,
|
|
grow_weapons:newequip_data,
|
|
force_entry_newbie_room:false,
|
|
team_members:[],
|
|
offline:true,
|
|
needbox:false
|
|
})
|
|
},
|
|
|
|
|
|
startgame(res){
|
|
// console.log("111111111111111111111111startgame")
|
|
// console.log(playerData.node_id)
|
|
// if (playerData.teamuuid == null) {
|
|
// return
|
|
// }
|
|
var energy_shield = 0
|
|
if (Number(playerData.eq2) != 0 && !playerData.biochemical) {
|
|
energy_shield = 1
|
|
}
|
|
var hair_id = playerData.hair_id
|
|
var cloth_id = playerData.cloth_fightid
|
|
var hat_id = playerData.hat_fightid
|
|
var color_id = playerData.color_id
|
|
if (Number(playerData.eq4) != 0 && !playerData.biochemical) {
|
|
hair_id = playerData.eq4
|
|
cloth_id = playerData.eq5
|
|
hat_id = playerData.eq6
|
|
}
|
|
|
|
var teammode = 0
|
|
var offline = false
|
|
if (playerData.team_list.length > 1) {
|
|
teammode = 1
|
|
} else {
|
|
if (playerData.isdiaoduan || playerData.game_times == 1) {
|
|
teammode = 1
|
|
offline = true
|
|
}
|
|
}
|
|
|
|
var auto = true
|
|
if (playerData.auto_fill == 0) {
|
|
auto = false
|
|
}
|
|
|
|
var arr = []
|
|
var a1 = {key:17001,value:0}
|
|
var a2 = {key:17002,value:0}
|
|
arr.push(a1)
|
|
arr.push(a2)
|
|
for (var i = 0; i < playerData.weizhuangs.length; i++) {
|
|
arr.push(playerData.weizhuangs[i])
|
|
}
|
|
|
|
var team_members = []
|
|
this.data = playerData.team_list
|
|
for (var t = 0; t < this.data.length; t++) {
|
|
var is_leader = false
|
|
if (t == 0) {
|
|
is_leader = true
|
|
}
|
|
var temp = {
|
|
'account_id':this.data[t].account_id,
|
|
'rank':Number(this.data[t].rank),
|
|
'is_leader':is_leader,
|
|
'game_times':Number(this.data[t].game_times),
|
|
'win_times':Number(this.data[t].win_times),
|
|
'kill_times':Number(this.data[t].kills),
|
|
'create_time':Number(this.data[t].create_time),
|
|
}
|
|
team_members.push(temp)
|
|
}
|
|
|
|
var prepare_items = []
|
|
var force_entry_newbie_room = playerData.isdiaoduan
|
|
var room_mode = 0
|
|
var firstzombie = false
|
|
if (!playerData.biochemical) {
|
|
prepare_items = [Number(playerData.eq2), Number(playerData.eq3), Number(playerData.jinzhanwuqi_id)]
|
|
} else {
|
|
prepare_items = [Number(playerData.eq1), Number(playerData.eq2), Number(playerData.eq3), Number(playerData.eq4), Number(playerData.jinzhanwuqi_id)]
|
|
force_entry_newbie_room = false
|
|
room_mode = 1
|
|
offline = false
|
|
if (playerData.biocount == 0) {
|
|
firstzombie = true
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
var weapons = []
|
|
if (gameConfig.dropItemConfig[playerData.equip_data['weapon_id']] &&
|
|
gameConfig.dropItemConfig[playerData.equip_data['weapon_id']].equip_type == 1) {
|
|
weapons.push(playerData.equip_data)
|
|
}
|
|
if (playerData.equip_length == 2 &&
|
|
gameConfig.dropItemConfig[playerData.equip_data1['weapon_id']] &&
|
|
gameConfig.dropItemConfig[playerData.equip_data1['weapon_id']].equip_type == 1) {
|
|
weapons.push(playerData.equip_data1)
|
|
}
|
|
battlenet.initengine({
|
|
account_id:NetManage.account_id,//
|
|
player_count:Number(playerData.team_list.length),//
|
|
energy_shield:Number(energy_shield),//
|
|
baseskin:[Number(hair_id),Number(cloth_id),Number(hat_id),Number(color_id)],//
|
|
team_uuid:playerData.teamuuid, //
|
|
team_mode:Number(teammode),//
|
|
auto_fill:auto,//
|
|
weapons:weapons,
|
|
first_game:false,
|
|
skins:[],
|
|
prepare_items:prepare_items,
|
|
prepare_items2:arr,
|
|
atk_add:Number(playerData.add_atk),
|
|
battlecount:playerData.game_times + 1,
|
|
pre_settlement_info:Number(playerData.game_times) + ',' + Number(playerData.win_times) + ',' + Number(playerData.kills) + ',' + Number(playerData.rank),
|
|
emojis:playerData.emojis,
|
|
grow_weapons:playerData.grow_weapons,
|
|
force_entry_newbie_room:Boolean(force_entry_newbie_room),
|
|
team_members:team_members,
|
|
offline:offline,
|
|
room_mode:room_mode,
|
|
firstzombie:firstzombie,
|
|
needbox:false
|
|
})
|
|
|
|
playerData.teamuuid = null
|
|
playerData.add_atk = 0
|
|
playerData.isteam = 0
|
|
playerData.eq1 = 0
|
|
playerData.eq2 = 0
|
|
playerData.eq3 = 0
|
|
playerData.eq4 = 0
|
|
playerData.eq5 = 0
|
|
playerData.eq6 = 0
|
|
playerData.biochemical = false
|
|
wxVoice.stopbgm()
|
|
playerData.inteam = false
|
|
playerData.inviteflag = true
|
|
playerData.equip_length = 1
|
|
|
|
},
|
|
|
|
|
|
update (dt) {
|
|
if(this.waitting==true){
|
|
if (this.time > 0) {
|
|
this.time-=dt
|
|
if(this.time<=0){
|
|
if (cc.toNewTempScene2) {
|
|
cc.toNewTempScene2 = false
|
|
this.onNewStart()
|
|
}
|
|
|
|
if (cc.toNewTempScene) {
|
|
cc.toNewTempScene = false
|
|
//this.onNewStart()
|
|
playerData.boxid = 10
|
|
cc.toNewTempScene2 = true
|
|
cc.director.loadScene("TempScene2");
|
|
}
|
|
|
|
if (cc.toTempScene) {
|
|
cc.toTempScene = false
|
|
cc.isbattle = false
|
|
this.startgame()
|
|
}
|
|
|
|
|
|
this.close()
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
|
|
if(this.pr_jindu.progress>0){
|
|
this.pr_jindu.progress -=dt*this.updatev
|
|
if(this.pr_jindu.progress<0){
|
|
this.pr_jindu.progress = 0
|
|
}
|
|
}
|
|
// this.time-=dt
|
|
// this.pr_time.progress = this.time/this.totaltime
|
|
// if(this.time<=0){
|
|
|
|
|
|
// if (this.pr_jindu.progress>=this.rewardpro) {
|
|
// // this.waitting = true
|
|
// // this.time2 = this.waittime
|
|
// this.nd_rad.active = true
|
|
|
|
// // } else {
|
|
// // this.time = this.waittime2
|
|
// // this.ani_rad.play("ui_adrewardend")
|
|
// // }
|
|
// }
|
|
|
|
if (this.clickwudian) {
|
|
if(this.time2>0){
|
|
this.time2-=dt
|
|
if(this.time2<=0){
|
|
this.time2=0
|
|
this.waitting=true
|
|
NetManage.getFuckBoxReward(this.boxid)
|
|
//this.ani_rad.play("ui_adrewardbox")
|
|
// if (cc.isbattle){
|
|
// battlenet.sendBaoxiang()
|
|
// this.waitting=true
|
|
// this.time = this.waittime
|
|
// this.ani_rad.play("ui_adrewardbox")
|
|
// } else {
|
|
// NetManage.getFuckBoxReward(this.boxid)
|
|
// }
|
|
}
|
|
}
|
|
return
|
|
}
|
|
// if (this.time <= this.bannertime) {
|
|
// this.showbanner = true
|
|
// this.btn_wudian.active = true
|
|
// }
|
|
},
|
|
|
|
showicon(id, i){
|
|
var self = this
|
|
if (gameConfig.wai_itemConfig[id].fuction == 1 ||
|
|
gameConfig.wai_itemConfig[id].fuction == 2 ||
|
|
gameConfig.wai_itemConfig[id].fuction == 8 ||
|
|
gameConfig.wai_itemConfig[id].fuction == 9 ||
|
|
gameConfig.wai_itemConfig[id].fuction == 16 ||
|
|
gameConfig.wai_itemConfig[id].fuction == 15 ||
|
|
gameConfig.wai_itemConfig[id].fuction == 21 ||
|
|
gameConfig.wai_itemConfig[id].fuction == 19 ||
|
|
gameConfig.wai_itemConfig[id].fuction == 22 ||
|
|
gameConfig.wai_itemConfig[id].fuction == 23){
|
|
cc.loader.loadRes("textures/icons/public/" + gameConfig.wai_itemConfig[id].icon, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
self.items[i].spriteFrame = res;
|
|
}
|
|
});
|
|
} else if (gameConfig.wai_itemConfig[id].fuction == 11) {
|
|
cc.loader.loadRes("textures/icons/gunmaterial/" + gameConfig.wai_itemConfig[id].icon, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
self.items[i].spriteFrame = res;
|
|
}
|
|
});
|
|
} else if (gameConfig.wai_itemConfig[id].fuction == 10) {
|
|
cc.loader.loadRes("icons/" + gameConfig.wai_itemConfig[id].icon, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
self.items[i].spriteFrame = res;
|
|
}
|
|
});
|
|
self.items[i].node.scale = 1.2
|
|
} else if (gameConfig.wai_itemConfig[id].fuction == 7) {
|
|
cc.loader.loadRes("icons/" + gameConfig.wai_itemConfig[id].icon, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
self.items[i].spriteFrame = res;
|
|
}
|
|
});
|
|
} else if (gameConfig.wai_itemConfig[id].fuction == 6) {
|
|
cc.loader.loadRes("textures/emote/" + gameConfig.wai_itemConfig[id].icon, cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
self.items[i].spriteFrame = res;
|
|
}
|
|
});
|
|
self.items[i].node.scale = 1.2
|
|
} else if (gameConfig.wai_itemConfig[id].fuction == 12) {
|
|
self.items[i].spriteFrame = null
|
|
var eg = gameConfig.dropItemConfig[id]
|
|
if (eg) {
|
|
var cb = function(nd,name){
|
|
self.items[i].node.destroyAllChildren()
|
|
nd.scale = 1.1
|
|
nd.rotation = -45
|
|
nd.scaleY = 1.1
|
|
nd.scaleX = 1.1
|
|
self.items[i].node.addChild(nd)
|
|
var cmp = nd.getComponent(cc.Animation)
|
|
if(cmp){
|
|
cmp.play(name+"_"+1)
|
|
}
|
|
}
|
|
this.loadprefab("prefabs/gunprefab/"+eg.model, cb, eg.model)
|
|
}
|
|
} else {
|
|
var string = ''
|
|
if (gameConfig.wai_itemConfig[id].fuction == 3) {
|
|
string = "cloth"
|
|
} else if (gameConfig.wai_itemConfig[id].fuction == 4) {
|
|
string = "hair"
|
|
} else if (gameConfig.wai_itemConfig[id].fuction == 5) {
|
|
string = "hat"
|
|
}
|
|
cc.loader.loadRes("avatar/" + string + "/" + string + "_" + gameConfig.wai_itemConfig[id].icon + "_front", cc.SpriteFrame, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
self.items[i].spriteFrame = res;
|
|
}
|
|
});
|
|
if (gameConfig.wai_itemConfig[id].fuction == 3) {
|
|
self.items[i].node.scale = 1.2
|
|
} else {
|
|
self.items[i].node.scale = 0.8
|
|
}
|
|
}
|
|
},
|
|
|
|
loadprefab(dir,cb,name){
|
|
var self = this
|
|
cc.loader.loadRes(dir, cc.Prefab, function (err, res) {
|
|
if (!err&&self.isValid) {
|
|
let nd = cc.instantiate(res)
|
|
cb(nd,name)
|
|
}
|
|
});
|
|
},
|
|
close(){
|
|
cc.Notifier.emit("3liantiao")
|
|
this.node.destroy()
|
|
},
|
|
|
|
|
|
});
|