pubgv3/assets/scripts/game/gamegodmode.js
zhuguoqing ff550d5d6a init
2022-05-22 10:32:02 +08:00

111 lines
3.1 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 Main = require("Main")
var Utils = require("Utils")
var playerData = require("playerData")
var gameConfig = require("gameConfig")
cc.Class({
extends: cc.Component,
properties: {
nd_btn:{
default: null,
type: cc.Node
},
nd_mask:{
default: null,
type: cc.Node
},
tg_god:{
default:null,
type: cc.Toggle,
},
lb_des:{
default: null,
type: cc.Label,
},
},
// LIFE-CYCLE CALLBACKS:
onLoad(){
this.nd_mask.on(cc.Node.EventType.TOUCH_END, this.clickbg,this);
if(cc.gameMgr.player){
this.selfPlayer = cc.gameMgr.player.getComponent("playerCtrl");
}
},
onDestroy(){
this.nd_mask.off(cc.Node.EventType.TOUCH_END, this.clickbg,this);
},
initdata(){
this.tg_god.isChecked = true
this.lb_des.string = cc.language.stringformat("bianshen")
if(this.selfPlayer ){
this.selfPlayer.joyShotEnd()
}
},
clickbg(){
this.node.active = false
// this.nd_btn.active = true
this.tg_god.isChecked = true
},
clickget(){
if(this.tg_god.isChecked == false){
this.clickbg()
return
}
var self = this
battlenet.sendBuffAdStart()
var cb = function(){
// setTimeout(() => {
// var rd = Math.random() >0.5?1:2
// battlenet.sendBuffAdEnd(rd)
// self.node.active = false
// }, 100);
var rd = Math.random() >0.5?1:2
battlenet.sendBuffAdEnd(rd)
cc.gameMgr.uic.btn_god.active = false
self.node.active = false
}
var cbf = function(){
battlenet.sendBuffAdCancel()
}
SDKManage.Share('zhuLi',null,cb,cbf);
},
clickgou(res){
//this.nd_btn.active = res.isChecked
if(res.isChecked){
this.lb_des.string = cc.language.stringformat("bianshen")
}else{
this.lb_des.string = cc.language.stringformat("close")
}
},
update(){
if(this.selfPlayer ){
if(this.selfPlayer.isdead()||this.selfPlayer.isdown){
this.clickbg()
}
}
},
});