import Common5 from "../../Platform/th/Common5"; import SoundMgr from "../../FrameWork/Mgr/SoundMgr"; import VibrateMgr from "../../FrameWork/Mgr/VibrateMgr"; import User from "../../FrameWork/User/User"; import EventMgr from "../../FrameWork/Event/EventMgr"; import { ryw_Event } from "../../FrameWork/Event/EventEnum"; import UserManager from "../Manager/UserManager"; import InterfaceManager from "../Manager/InterfaceManager"; import AppPlatform from "../../FrameWork/Util/AppPlatform"; import PrefabManage, { GameType } from "../PrefabManager/PrefabManage"; const { ccclass, property } = cc._decorator; @ccclass export default class Setting extends cc.Component { @property(cc.Node) resetNode: cc.Node = null; @property(cc.Node) headIconLayout: cc.Node = null; @property(cc.Node) selectIcon: cc.Node = null; // protected headImgList: Array = ["headImg1", "headImg2", "headImg3", "headImg4"]; onLoad() { } start() { this.updateShow(); // this.updateHeadImg() if (Common5.ISSHOWGM) { this.node.getChildByName('GMBtn').active = true } } updateShow() { this.node.getChildByName("setNode").getChildByName("yinyue").getChildByName("off").active = Common5.isNoMusic; this.node.getChildByName("setNode").getChildByName("yinyue").getChildByName("on").active = !Common5.isNoMusic; this.node.getChildByName("setNode").getChildByName("yinXiao").getChildByName("off").active = Common5.isNoEffect; this.node.getChildByName("setNode").getChildByName("yinXiao").getChildByName("on").active = !Common5.isNoEffect; this.node.getChildByName("setNode").getChildByName("zhenDong").getChildByName("off").active = Common5.isNoZD; this.node.getChildByName("setNode").getChildByName("zhenDong").getChildByName("on").active = !Common5.isNoZD; } // updateHeadImg() { // let curImg = User.getHeadImg() // let imgs = User.getHeadImgUnlock(); // for (var i = 0; i < this.headImgList.length; i++) { // imgs.forEach((ele) => { // if (ele == this.headImgList[i]) { // this.headIconLayout.getChildByName("icon_" + i).getChildByName("adIcon").active = false; // } // }) // if (this.headImgList[i] == curImg) { // Common5.setNodeToTargetPos(this.selectIcon, this.headIconLayout.getChildByName("icon_" + i)) // } // } // } // onHeadImgClick(event, customData) { // // Common5.playEffect("sound/按键点击") // let imgName = this.headImgList[customData] // if (this.headIconLayout.getChildByName("icon_" + customData).getChildByName("adIcon").active) { // let tab = { // onClose: (finish) => { // if (finish) { // Common5.ReportDY("inLevel", "设置-AD-更换头像" + customData); // User.setHeadImg(imgName); // User.setHeadImgUnlock(imgName); // this.headIconLayout.getChildByName("icon_" + customData).getChildByName("adIcon").active = false; // EventMgr.emitEvent_custom(ryw_Event.setHeadImg, imgName); // Common5.setNodeToTargetPos(this.selectIcon, this.headIconLayout.getChildByName("icon_" + customData)) // } // else { // Common5.showTips_custom("广告未观看完"); // } // }, onFailed: () => { // } // } // AppPlatform.playVideo_custom(tab) // } else { // User.setHeadImg(imgName); // EventMgr.emitEvent_custom(ryw_Event.setHeadImg, imgName); // Common5.setNodeToTargetPos(this.selectIcon, this.headIconLayout.getChildByName("icon_" + customData)) // } // } onBtnCloseClick() { // Common5.playEffect("sound/按键点击") this.node.removeFromParent() } onBtnMusicClick() { // Common5.playEffect("sound/按键点击") // Common5.playEffect("sound/按键点击") Common5.isNoMusic = !Common5.isNoMusic; SoundMgr.setSoundEnabled_custom(!Common5.isNoMusic); if (Common5.isNoMusic == true) { cc.audioEngine.stopMusic(); } else { Common5.playMusic("sound/背景音"); } this.updateShow(); } onBtnEffectClick() { // Common5.playEffect("sound/按键点击") // Common5.playEffect("sound/按键点击") Common5.isNoEffect = !Common5.isNoEffect; SoundMgr.setSoundEnabled_custom(!Common5.isNoEffect); this.updateShow(); } onBtnVibrateClick() { // Common5.playEffect("sound/按键点击") // Common5.playEffect("sound/按键点击") Common5.isNoZD = !Common5.isNoZD; VibrateMgr.isEnable_custom = !Common5.isNoZD; this.updateShow(); } onBtnRestartClick() { // Common5.playEffect("sound/按键点击") this.resetNode.active = true } onBtnYesClick() { Common5.ReportDY("inLevel", '玩家重置数据-AD-设置界面'); console.log('onBtnYesClick') // Common5.playEffect("sound/按键点击") if (!AppPlatform.is_TT_GAME_custom()) { Common5.isVideoAdStopTime = true User.restartGame() this.node.removeFromParent() cc.director.loadScene("FirstSelectScene", function (err, scene) { console.log("跳转游戏场景 FirstSelectScene"); Common5.isVideoAdStopTime = false }); } else { Common5.isVideoAdStopTime = true User.restartGame() this.node.removeFromParent() cc.director.loadScene("FirstSelectScene", function (err, scene) { console.log("跳转游戏场景 FirstSelectScene"); Common5.isVideoAdStopTime = false }); } } onBtnNoClick() { // Common5.playEffect("sound/按键点击") this.resetNode.active = false } onBtnSaveClick() { // Common5.playEffect("sound/按键点击") InterfaceManager.saveData(true) PrefabManage.showTextTips('数据存档成功!') } gmClickEvent() { PrefabManage.loadPrefabByType(GameType.GM) } // update (dt) {} }