/** * 设置 */ import AudioManager from "../../Tools/AudioManager"; import { GameType } from "../../Tools/Define"; import GameResMgr, { soundName, uiPreName } from "../../Tools/GameResMgr"; import PlayData from "../../Tools/PlayData"; import AdsApiMgr from "../../Tools/Sdk/ads/AdsApiMgr"; import gameStorage from "../../Tools/gameStorage"; import TipsManager from "../TipsManager"; const {ccclass, property} = cc._decorator; @ccclass export default class setPanelSc extends cc.Component { @property([cc.Node]) kuangarr:cc.Node[] = [] yinxiaokaiguan:cc.Node[] = [] yinyuekaiguan:cc.Node[] = [] zhendongkaiguan:cc.Node[] = [] showtype = -1 onLoad () { this.kuangarr[0].active = !1 this.kuangarr[1].active = !1 } start () { } protected onEnable(): void { AdsApiMgr.Instance.chaPingAds_Show() } /** * 展示类型 * @param _type */ showType(_type){ this.showtype = _type this.kuangarr[_type].active = !0 this.yinxiaokaiguan[0] = cc.find('yinxiao/kai', this.kuangarr[_type]) this.yinxiaokaiguan[1] = cc.find('yinxiao/guan', this.kuangarr[_type]) this.yinyuekaiguan[0] = cc.find('yinyue/kai', this.kuangarr[_type]) this.yinyuekaiguan[1] = cc.find('yinyue/guan', this.kuangarr[_type]) this.zhendongkaiguan[0] = cc.find('zhendong/kai', this.kuangarr[_type]) this.zhendongkaiguan[1] = cc.find('zhendong/guan', this.kuangarr[_type]) this.initUi() } /** * 初始化 */ initUi(){ console.log('打印音效=', gameStorage.Instance.getSound()) this.yinxiaokaiguan[0].active = gameStorage.Instance.getSound() == 0 this.yinxiaokaiguan[1].active = gameStorage.Instance.getSound() == 1 this.yinyuekaiguan[0].active = gameStorage.Instance.getMusic() == 0 this.yinyuekaiguan[1].active = gameStorage.Instance.getMusic() == 1 this.zhendongkaiguan[0].active = gameStorage.Instance.getZhenDong() == 0 this.zhendongkaiguan[1].active = gameStorage.Instance.getZhenDong() == 1 } closeBtn(){ this.node.destroy() } /** * 按钮点击 * @param t * @param e */ btnClickCallBack(t, e){ if(e == 'restart'){ //重新开始 if(gameStorage.Instance.getEnergy() <= 0){ gameStorage.Instance.setoffLineTime() let newnode = cc.instantiate(GameResMgr.Instance.uiPre[uiPreName.addEnery]) newnode.parent = cc.director.getScene() TipsManager.Instance.createTips('体力不足!') return } AdsApiMgr.Instance.recording_Video_End() gameStorage.Instance.setEnergy(gameStorage.Instance.getEnergy()-1) if(PlayData.Instance.gameType == GameType.normal){ PlayData.Instance.storageGameDate[1] = 0 PlayData.Instance.storageGameDate[2] = 9 PlayData.Instance.storageGameDate[3] = [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1] PlayData.Instance.storageGameDate[4] = [] gameStorage.Instance.setCheckOutData(PlayData.Instance.storageGameDate) }else if(PlayData.Instance.gameType == GameType.challenge){ gameStorage.Instance.resetShengJiCheckOutData(PlayData.Instance.guanqia) } cc.director.loadScene('LevelUpGameScene') }else if(e == 'yinxiao'){ let sound = gameStorage.Instance.getSound() if(sound == 0){ sound = 1 }else{ sound = 0 } gameStorage.Instance.setSound(sound) this.yinxiaokaiguan[0].active = sound == 0 this.yinxiaokaiguan[1].active = sound == 1 }else if(e == 'yinyue'){ let music = gameStorage.Instance.getMusic() if(music == 0){ music = 1 gameStorage.Instance.setMusic(music) AudioManager.stopAllMusic() }else{ music = 0 gameStorage.Instance.setMusic(music) if(this.showtype == 0){ AudioManager.playMusic(soundName.bgSound0) }else if(this.showtype == 1) { AudioManager.playMusic(soundName.bgSound1) } } this.yinyuekaiguan[0].active = music == 0 this.yinyuekaiguan[1].active = music == 1 }else if(e == 'zhendong'){ let zhen = gameStorage.Instance.getZhenDong() if(zhen == 0){ zhen = 1 }else{ zhen = 0 } gameStorage.Instance.setZhenDong(zhen) this.zhendongkaiguan[0].active = zhen == 0 this.zhendongkaiguan[1].active = zhen == 1 } } // update (dt) {} }