1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import { _decorator, Component, Node, Toggle } from 'cc';
- import { base_ui } from '../fw/base_ui';
- import { audioManager } from '../manager/audioManager';
- import { GameManager } from '../GameManager';
- 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;
- 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)
- })
- 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()
- 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()
- 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()
- setting_data.isOpenZhendong = open
- GameManager.saveSettingData(setting_data)
- }
- }
|