123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import { _decorator, Component, Label, Node, Toggle } from 'cc';
- import { base_ui } from '../fw/base_ui';
- import { audioManager } from '../manager/audioManager';
- import { GameManager } from '../GameManager';
- import { userDataManager } from '../manager/userDataManager';
- import { config } from '../config';
- const { ccclass, property } = _decorator;
- @ccclass('setting')
- export class setting extends base_ui {
- @property(Node) btn_close:Node = null
- @property(Node) yinyue_btn_on:Node = null;
- @property(Node) yinyue_btn_off:Node = null;
- @property(Node) shengyin_btn_on:Node = null;
- @property(Node) shengyin_btn_off:Node = null;
- @property(Node) zhendong_btn_on:Node = null;
- @property(Node) zhendong_btn_off:Node = null;
- @property(Node) btn_user:Node = null;
- @property(Node) lab_user:Node = null;
- @property(Node) btn_clear_local_data:Node = null;
- protected start(): void {
- this.onButtonListen(this.btn_close, ()=>{
- this.close()
- })
- this.onButtonListen(this.yinyue_btn_on, ()=>{
- this.updateYinyueStatus(false)
- audioManager.Instance().pauseHomeBgm()
- })
- this.onButtonListen(this.yinyue_btn_off, ()=>{
- this.updateYinyueStatus(true)
- audioManager.Instance().playHomeBgm()
- })
- this.onButtonListen(this.shengyin_btn_on, ()=>{
- this.updateShengyinStatus(false)
- })
- this.onButtonListen(this.shengyin_btn_off, ()=>{
- this.updateShengyinStatus(true)
- })
- this.onButtonListen(this.zhendong_btn_on, ()=>{
- this.updateZhendongStatus(false)
- })
- this.onButtonListen(this.zhendong_btn_off, ()=>{
- this.updateZhendongStatus(true)
- })
- // 彩蛋
- if(config.debug) {
- this.btn_clear_local_data.active = true
- }
- this.onButtonListen(this.btn_user, ()=>{
- this.lab_user.active = true
- this.lab_user.getComponent(Label).string = 'id:' + userDataManager.user_data.id
- })
- this.onButtonListen(this.btn_clear_local_data, ()=>{
- userDataManager.clearUserFreeAdsData()
- })
- this.initData()
- }
- initData() {
- let setting_data = GameManager.getSettingData()
- this.updateYinyueStatus(setting_data.isOpenYinYue)
- this.updateShengyinStatus(setting_data.isOpenYinXiao)
- this.updateZhendongStatus(setting_data.isOpenZhendong)
- }
- updateYinyueStatus(open:boolean) {
- if(open) {
- this.yinyue_btn_on.active = true
- this.yinyue_btn_off.active = false
- } else {
- this.yinyue_btn_on.active = false
- this.yinyue_btn_off.active = true
- }
- let setting_data = GameManager.getSettingData()
- if(open==setting_data.isOpenYinYue) {
- return
- }
- setting_data.isOpenYinYue = open
- GameManager.saveSettingData(setting_data)
- }
- updateShengyinStatus(open:boolean) {
- if(open) {
- this.shengyin_btn_on.active = true
- this.shengyin_btn_off.active = false
- } else {
- this.shengyin_btn_on.active = false
- this.shengyin_btn_off.active = true
- }
- let setting_data = GameManager.getSettingData()
- if(open==setting_data.isOpenYinXiao) {
- return
- }
- setting_data.isOpenYinXiao = open
- GameManager.saveSettingData(setting_data)
- }
- updateZhendongStatus(open:boolean) {
- if(open) {
- this.zhendong_btn_on.active = true
- this.zhendong_btn_off.active = false
- } else {
- this.zhendong_btn_on.active = false
- this.zhendong_btn_off.active = true
- }
- let setting_data = GameManager.getSettingData()
- if(open==setting_data.isOpenZhendong) {
- return
- }
- setting_data.isOpenZhendong = open
- GameManager.saveSettingData(setting_data)
- }
- }
|