var gameConfig = require("gameConfig") var playerData = require("playerData") var SDKManage = require("SDKManage") var NetManage = require("NetManage") var wxVoice = require("wxVoice") var vipColorConfig = require("vipColorConfig") var Main = require("Main"); cc.Class({ extends: cc.Component, properties: { lb_gold: { default: null, type: cc.Label, }, head_icon: { default: null, type: cc.Sprite, }, lb_name: { default: null, type: cc.Label, }, nd_gou2: { default: null, type: cc.Node }, nd_tips2: { default: null, type: cc.Node, }, nd_hide: { default: null, type: cc.Node }, nd_hide2: { default: null, type: cc.Node }, lb_reward: { default: null, type: cc.Label, }, nd_reward1: { default: null, type: cc.Node }, pb_reward: { default: null, type: cc.Prefab }, lb_rank: { default: null, type: cc.Label, }, lb_score: { default: null, type: cc.Label, }, nd_box1: { default: null, type: cc.Node, }, nd_box2: { default: null, type: cc.Node, }, btn_share: { default: null, type: cc.Node, }, nd_reward2: { default: null, type: cc.Node, }, pb_reward2: { default: null, type: cc.Prefab }, nd_getreward: { default: null, type: cc.Node, }, pb_win: { default: null, type: cc.Prefab }, pb_fuckbox: { default: null, type: cc.Prefab, }, nd_player: { default: null, type: cc.Node, }, sp_quality: { default: null, type: cc.Sprite, }, nd_rewardcoin: { default: null, type: cc.Node, }, coin_time: 1, pro_time: 1, delay_time: 2, }, // LIFE-CYCLE CALLBACKS: onGrstop(res) { console.log(res) SDKManage.vedioshare(this.btn_share, res) }, onLoad() { if (cc.gameMgr.uic.ndrevive) { cc.gameMgr.uic.ndrevive.active = false } this.coin_num = 0 this.delaycointime = 0 this.coinplaystatus = true this.coin = playerData.coin_num this.diamond = playerData.diamond_num this.games = 0 this.rewardid = 0 this.rewardnum = 0 this.team_rank = 0 playerData.win_list.length = 0 cc.Notifier.on('getfightreward', this, this.getfightreward.bind(this)); cc.Notifier.on('activegameover', this, this.activegameover.bind(this)); cc.Notifier.on('firstrewardinfo', this, this.firstrewardinfo.bind(this)); cc.Notifier.on('gamedoublereward', this, this.gamedoublereward.bind(this)); cc.Notifier.on('Grstop', this, this.onGrstop.bind(this)); //cc.Notifier.on('liandianbox', this, this.callliandianbox.bind(this)); }, onDestroy() { cc.Notifier.off('getfightreward', this); cc.Notifier.off('activegameover', this); cc.Notifier.off('firstrewardinfo', this); cc.Notifier.off('gamedoublereward', this); cc.Notifier.off('Grstop', this); //cc.Notifier.off('liandianbox', this); }, callliandianbox() { if (!playerData.isliandianbox()) { return } playerData.boxid = 13 var nd = cc.instantiate(this.pb_fuckbox) nd.zIndex = 3 this.node.addChild(nd) }, onBtnShare() { SDKManage.Share(this.fenxiang); }, getfightreward() { // if (this.nd_hide2.active || this.isclose) { // SDKManage.logEvent("gameover_ui",cc.gameMgr.gamemode) // wxVoice.playSound("gameover") // this.nd_tips2.active = false // this.nd_getreward.active = false // this.nd_hide2.active = false // this.nd_hide.active = true // this.firstrewardinfo(playerData.win_list.length) // } else { //setTimeout(() => { this.onbtnclose() //}, 1000); //} }, gamedoublereward() { this.isclose = true var self = this // if (playerData.new_first_equip == 0) { // NetManage.getFightEquip(parseInt(gameConfig.parameterConfig['opening_spear'].param_value)) // } else if (playerData.new_second_equip == 0) { // NetManage.getFightEquip(parseInt(gameConfig.parameterConfig['opening_spear2'].param_value)) // } //SDKManage.logEvent("gameover_ad_reward_btn","") NetManage.getFightReward(self.coin_num, self.rewardid, self.rewardnum) NetManage.getFirstReward(1, playerData.win_uuid, self.spoils_items) }, activegameover() { SDKManage.logEvent("gameover_ui", 'jiesuan') this.nd_hide.active = true this.firstrewardinfo(playerData.win_list.length) this.callliandianbox() //NetManage.firstRewardInfo(this.team_rank, 0, this.gamekills, this.gamecoin) }, callgameover(spoils_items) { var nd = cc.instantiate(this.pb_win) nd.zIndex = 2 this.node.addChild(nd) nd.getComponent("win").initbioinfo(spoils_items) }, setdata(res, itemarr, teamarr) { SDKManage.logEvent("gameover_reward_ui", 'jiesuan') cc.Notifier.emit('notbtnhack') playerData.biocount++ this.nd_tips2.active = true this.nd_gou2.active = true this.nd_box1.active = false this.nd_box2.active = true this.aniplay(res.team_rank) playerData.teamarr = teamarr //this.nd_reward.active = false this.nd_hide.active = false this.nd_hide2.active = false this.nd_getreward.active = true // if (res.spoils_items && res.spoils_items.length != 0) { NetManage.addSpoilsItems(res.spoils_items) } this.spoils_items = res.spoils_items // if (iskillself) { // this.nd_hide.active = true // } else { if (playerData.new_first_equip == 0 || playerData.new_second_equip == 0) { cc.newequip = true SDKManage.logEvent("gameover_reward_ui", 'jiesuan') } this.callgameover(res.spoils_items) cc.Notifier.emit('changetitle', cc.language.stringformat("jiesuanreward")) //} // wxVoice.playSound("gameover") NetManage.firstRewardInfo(res.team_rank, 1, res.player_stats[0].kills) this.team_rank = res.team_rank this.lb_rank.string = res.team_rank var self = this playerData.draw_status = 1 //playerData.game_times++ if (playerData.game_times <= 3) { playerData.fight_times = 0 } else { playerData.fight_times++ } NetManage.updateWeizhuang(itemarr); var self = this setTimeout(() => { // var cbp = function() { NetManage.getPassInfo() NetManage.getQuestInfo() //NetManage.recAcitivityInfo() NetManage.equipInfo() //self.games = playerData.game_times } NetManage.getRoleInfo(Main.config.mainConfig.battle_count_switch, cbp) }, 3000); //self.lb_coinnum.string = self.coin //self.lb_diamondnum.string = self.diamond playerData.rank1 = 0 playerData.rank2 = 0 this.lb_name.string = SDKManage.sixstr(SDKManage.nickName) var self = this var avatar_id = 18201 var sex = 'm' if (playerData.sex == 1) { sex = 'f' } if (playerData.avatar_id && Number(playerData.avatar_id) >= 18000 && Number(playerData.avatar_id) <= 19000) { avatar_id = playerData.avatar_id } cc.loader.loadRes("textures/icons/public/" + gameConfig.wai_itemConfig[avatar_id].icon, cc.SpriteFrame, function(err, res) { if (!err && self.isValid) { self.head_icon.spriteFrame = res; } }); playerData.gamerank = res.team_rank playerData.fight_status = 1 this.showPlayer() // var cbgold = function(v) { // self.lb_gold.string = Math.floor(v) // } this.lb_gold.string = "0" // var vauleaction = new cc.VauleTo(); // vauleaction.initWithDuration(this.coin_time, 0, this.coin_num * 2,cbgold); // this.lb_gold.node.runAction(cc.sequence(cc.delayTime(self.delay_time),vauleaction)) var quality = 1 if (gameConfig.wai_itemConfig[10001].quality && gameConfig.wai_itemConfig[10001].quality != 0) { quality = gameConfig.wai_itemConfig[10001].quality } cc.loader.loadRes("textures/icons/public/draw_v" + quality, cc.SpriteFrame, function(err, res) { if (!err && self.isValid) { if (self.sp_quality) { self.sp_quality.spriteFrame = res; } } }); }, aniplay(rank) { if (rank <= 3) { this.aniname = 'emote01' //this.anibody.play('emote01') } else if (rank > 3 && rank <= 19000) { this.aniname = 'emote04' //this.anibody.play('emote04') } else { this.aniname = 'crawl' //this.anibody.play('crawl') } }, firstrewardinfo(length) { this.nd_reward1.destroyAllChildren() //this.nd_reward2.destroyAllChildren() this.coin_num = playerData.biogamegold this.show_coin = (Math.floor(Number(playerData.biogamegold) + Number(playerData.biogamegold) * Number(playerData.roleval[1]) / 100)) this.lb_gold.string = (this.show_coin * 2) this.lb_score.string = playerData.biogamescore for (var i = 0; i < length; i++) { //wxVoice.playSound('ui_rewardicon') var nd = cc.instantiate(this.pb_reward) nd.zIndex = 2 this.nd_reward1.addChild(nd) if (this.nd_hide.active) { nd.active = true } else { nd.active = false } nd.getComponent("win_icon").showWinIcon(Number(playerData.win_list[i].item_id), Number(playerData.win_list[i].item_num), Number(playerData.win_list[i].time)) } // if (playerData.new_first_equip == 0) { // var nd = cc.instantiate(this.pb_reward2) // nd.zIndex = 2 // this.nd_reward2.addChild(nd) // nd.getComponent("jiesuan_icon").showJiesuanIcon(parseInt(gameConfig.parameterConfig['opening_spear'].param_value), 1, 0, 1) // } else if (playerData.new_second_equip == 0) { // var nd = cc.instantiate(this.pb_reward2) // nd.zIndex = 2 // this.nd_reward2.addChild(nd) // nd.getComponent("jiesuan_icon").showJiesuanIcon(parseInt(gameConfig.parameterConfig['opening_spear2'].param_value), 1, 0, 1) // } else { // if (playerData.new_first_equip == 0 || playerData.new_second_equip == 0) { // cc.newequip = true // } // var nd = cc.instantiate(this.pb_reward2) // nd.zIndex = 2 // this.nd_reward2.addChild(nd) // nd.getComponent("jiesuan_icon").showJiesuanIcon(10001, Number(this.coin_num * 2), 0, 0) // for (var i = 0; i < length; i++) { // //wxVoice.playSound('ui_rewardicon') // var nd = cc.instantiate(this.pb_reward2) // nd.zIndex = 2 // this.nd_reward2.addChild(nd) // nd.getComponent("jiesuan_icon").showJiesuanIcon(Number(playerData.win_list[i].item_id), Number(playerData.win_list[i].item_num), Number(playerData.win_list[i].time), 0) // } //} this.nd_rewardcoin.destroyAllChildren() var nd = cc.instantiate(this.pb_reward) this.nd_rewardcoin.addChild(nd) nd.getComponent("win_icon").showWinIcon(10001, Number(this.coin_num) * 2, 0) for (var j = 0; j < this.spoils_items.length; j++) { var arr = this.spoils_items[j].values var nd = cc.instantiate(this.pb_reward) this.nd_rewardcoin.addChild(nd) nd.getComponent("win_icon").showWinIcon(arr[0], Number(arr[1]) * 2, 0) } }, closehide2() { //this.canget = true if (this.aflag) { return } SDKManage.logEvent("gameover_ui", cc.gameMgr.gamemode) wxVoice.playSound("gameover") this.nd_tips2.active = true this.nd_getreward.active = true this.nd_hide2.active = false this.nd_hide.active = true this.firstrewardinfo(playerData.win_list.length) this.callliandianbox() }, onBtnReward() { var self = this var cb = function() { // if (playerData.new_first_equip == 0) { // NetManage.getFightEquip(parseInt(gameConfig.parameterConfig['opening_spear'].param_value)) // } else if (playerData.new_second_equip == 0) { // NetManage.getFightEquip(parseInt(gameConfig.parameterConfig['opening_spear2'].param_value)) // } NetManage.getFightReward(self.coin_num, self.rewardid, self.rewardnum) self.coin = self.coin_num + self.coin NetManage.getFirstReward(1, playerData.win_uuid, self.spoils_items) } var cbf = function() { self.aflag = false } this.aflag = true SDKManage.Share('gameoverreward2_ad', null, cb, cbf); SDKManage.logEvent("gameoverreward2_ad", "double") }, changeGameOverStatus() { //if (Main.config.mainConfig.ad_video_switch) { this.changeGameOverStatus2() }, changeGameOverStatus2() { if (this.coinplaystatus == true) { if (this.nd_gou2.active == false) { cc.Notifier.emit('notbtnhack') this.nd_gou2.active = true this.nd_box1.active = false this.nd_box2.active = true //this.anireward(this.rewardnum, this.rewardnum * 2) this.coinplaystatus = false this.delaycointime = 1 this.firstrewardinfo(playerData.win_list.length) this.anigold(this.coin_num, this.coin_num * 2, this.spoils_items, 2) } else { cc.Notifier.emit('openbtnhack') this.firstrewardinfo(0) this.nd_gou2.active = false this.nd_box1.active = true this.nd_box2.active = false //this.anireward(this.rewardnum * 2, this.rewardnum) this.coinplaystatus = false this.delaycointime = 1 this.anigold(this.coin_num * 2, this.coin_num, this.spoils_items, 1) } } }, anigold(gold, gold2, spoils_items, isdouble) { // var self = this // var cbgold = function(v) { // self.lb_gold.string = Math.floor(v) // } // var vauleaction = new cc.VauleTo(); // vauleaction.initWithDuration(this.coin_time, gold, gold2,cbgold); // this.lb_gold.node.runAction(cc.sequence(cc.delayTime(0),vauleaction)) cc.Notifier.emit('playgoldani', [gold, gold2, spoils_items, isdouble]) }, getdoublereward() { var self = this if (this.coin_num != 0) { var cb = function() { SDKManage.logEvent("gameover_ad_reward_btn", "double") NetManage.getFightReward(self.coin_num, self.rewardid, self.rewardnum) self.coin = self.coin_num + self.coin NetManage.getFirstReward(1, playerData.win_uuid, self.spoils_items) } var cbf = function() { self.aflag = false } this.aflag = true SDKManage.Share('gameoverReward', null, cb, cbf); SDKManage.logEvent("gameover_ad", "double") } }, getsinglereward() { SDKManage.logEvent("gameover_close_btn", "single") this.aflag = true var temp = { 'item_id': 10001, 'item_num': 1, 'time': 0 } playerData.reward_list = [] playerData.reward_list.push(temp) playerData.newequip = 1 //this.anicoin.play('ui_getcoin') // this.lb_coinnum.string = this.coin // this.lb_diamondnum.string = this.diamond //setTimeout(() => { this.onbtnclose() //}, 1300); }, onbtnGet() { if (this.aflag) { return } //if (Main.config.mainConfig.ad_video_switch) { this.onbtnGet2() }, onbtnGet2() { this.coin = this.coin_num + this.coin if (this.nd_gou2.active == true) { var self = this if (this.coin_num != 0) { this.getdoublereward() } else { this.getsinglereward() } } else { this.getsinglereward() } }, 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) this.nd_player.getComponent("uiplayershow").changeaniplay(this.aniname) }, onbtnclose() { cc.newhand = true if (playerData.rank1 != 0 && playerData.rank2 != 0) { cc.frombattle = true } else { cc.frombattle = false playerData.emogod = true } cc.uiHelper.showLoading() setTimeout(() => { cc.director.loadScene("MainScene"); }, 1000); }, update(dt) { if (this.delaycointime > 0) { this.delaycointime -= dt if (this.delaycointime <= 0) { this.coinplaystatus = true } } }, });