瀏覽代碼

Merge branch 'master' of http://git.mokasz.com/zouyong/mk_framework

kaka 5 年之前
父節點
當前提交
0d0d3cf98b

+ 8 - 6
assets/resources/game/prefab/game.prefab

@@ -46,8 +46,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 0,
-      "height": 0
+      "width": 750,
+      "height": 1334
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -384,7 +384,7 @@
       "__type__": "TypedArray",
       "ctor": "Float64Array",
       "array": [
-        315,
+        302.032,
         0,
         0,
         0,
@@ -918,7 +918,7 @@
       "__id__": 24
     },
     "_enabled": true,
-    "panel_name": "sign",
+    "panel_name": "reward",
     "open_type": 0,
     "panel_type": 2,
     "onComplete": {
@@ -986,10 +986,12 @@
     },
     "_enabled": true,
     "alignMode": 1,
-    "_target": null,
+    "_target": {
+      "__id__": 1
+    },
     "_alignFlags": 32,
     "_left": 0,
-    "_right": 0,
+    "_right": 12.968000000000018,
     "_top": 0,
     "_bottom": 0,
     "_verticalCenter": 0,

+ 41 - 0
assets/resources/module/reward/RewardOpen.anim

@@ -0,0 +1,41 @@
+{
+  "__type__": "cc.AnimationClip",
+  "_name": "RewardOpen",
+  "_objFlags": 0,
+  "_native": "",
+  "_duration": 0.3333333333333333,
+  "sample": 60,
+  "speed": 1,
+  "wrapMode": 1,
+  "curveData": {
+    "props": {
+      "scale": [
+        {
+          "frame": 0,
+          "value": {
+            "__type__": "cc.Vec2",
+            "x": 0,
+            "y": 0
+          }
+        },
+        {
+          "frame": 0.25,
+          "value": {
+            "__type__": "cc.Vec2",
+            "x": 1.1,
+            "y": 1.1
+          }
+        },
+        {
+          "frame": 0.3333333333333333,
+          "value": {
+            "__type__": "cc.Vec2",
+            "x": 1,
+            "y": 1
+          }
+        }
+      ]
+    }
+  },
+  "events": []
+}

+ 5 - 0
assets/resources/module/reward/RewardOpen.anim.meta

@@ -0,0 +1,5 @@
+{
+  "ver": "2.1.0",
+  "uuid": "b3fe8a24-9df4-45cd-a6b9-9eae78842bb1",
+  "subMetas": {}
+}

文件差異過大導致無法顯示
+ 2385 - 262
assets/resources/module/reward/reward.prefab


二進制
assets/resources/module/reward/红包1.png


+ 0 - 36
assets/resources/module/reward/红包1.png.meta

@@ -1,36 +0,0 @@
-{
-  "ver": "2.3.5",
-  "uuid": "845e5457-bac8-4da5-8791-6417a28d890f",
-  "type": "sprite",
-  "wrapMode": "clamp",
-  "filterMode": "bilinear",
-  "premultiplyAlpha": false,
-  "genMipmaps": false,
-  "packable": true,
-  "width": 750,
-  "height": 1334,
-  "platformSettings": {},
-  "subMetas": {
-    "红包1": {
-      "ver": "1.0.4",
-      "uuid": "eab50c3f-71c3-4136-ae80-7310e0d062fe",
-      "rawTextureUuid": "845e5457-bac8-4da5-8791-6417a28d890f",
-      "trimType": "auto",
-      "trimThreshold": 1,
-      "rotated": false,
-      "offsetX": 0,
-      "offsetY": 0,
-      "trimX": 0,
-      "trimY": 0,
-      "width": 750,
-      "height": 1334,
-      "rawWidth": 750,
-      "rawHeight": 1334,
-      "borderTop": 0,
-      "borderBottom": 0,
-      "borderLeft": 0,
-      "borderRight": 0,
-      "subMetas": {}
-    }
-  }
-}

二進制
assets/resources/module/reward/红包2.png


+ 0 - 36
assets/resources/module/reward/红包2.png.meta

@@ -1,36 +0,0 @@
-{
-  "ver": "2.3.5",
-  "uuid": "93533dc3-809f-487c-812f-aa6324b87d2a",
-  "type": "sprite",
-  "wrapMode": "clamp",
-  "filterMode": "bilinear",
-  "premultiplyAlpha": false,
-  "genMipmaps": false,
-  "packable": true,
-  "width": 750,
-  "height": 1334,
-  "platformSettings": {},
-  "subMetas": {
-    "红包2": {
-      "ver": "1.0.4",
-      "uuid": "90d67af0-cc88-4c78-bb69-c1e15b253a72",
-      "rawTextureUuid": "93533dc3-809f-487c-812f-aa6324b87d2a",
-      "trimType": "auto",
-      "trimThreshold": 1,
-      "rotated": false,
-      "offsetX": 0,
-      "offsetY": 0,
-      "trimX": 0,
-      "trimY": 0,
-      "width": 750,
-      "height": 1334,
-      "rawWidth": 750,
-      "rawHeight": 1334,
-      "borderTop": 0,
-      "borderBottom": 0,
-      "borderLeft": 0,
-      "borderRight": 0,
-      "subMetas": {}
-    }
-  }
-}

+ 4 - 4
assets/resources/module/turnable/turnable.prefab

@@ -2788,7 +2788,7 @@
     "asset": {
       "__uuid__": "18e0b7f8-059f-4a52-9e57-690fe778a31a"
     },
-    "fileId": "fdfjeLbuxNhL06oNXr01uY",
+    "fileId": "1fN/LnElpKsYLei+CS/TFW",
     "sync": false
   },
   {
@@ -2920,7 +2920,7 @@
     "asset": {
       "__uuid__": "18e0b7f8-059f-4a52-9e57-690fe778a31a"
     },
-    "fileId": "51yUASr+BEiZU6Das9s9fd",
+    "fileId": "7fUJTp7ElGNI8aCqv8feSY",
     "sync": false
   },
   {
@@ -3052,7 +3052,7 @@
     "asset": {
       "__uuid__": "18e0b7f8-059f-4a52-9e57-690fe778a31a"
     },
-    "fileId": "5bYhEtuH5POL0zjYqZhlso",
+    "fileId": "3fHoh0/txA9IcjuuQ0r5Zh",
     "sync": false
   },
   {
@@ -3265,7 +3265,7 @@
     "asset": {
       "__uuid__": "18e0b7f8-059f-4a52-9e57-690fe778a31a"
     },
-    "fileId": "dcAfYrg3lHsrkPgRWQve1o",
+    "fileId": "c6DhHc9wZJupNy7E4AG9CP",
     "sync": false
   },
   {

+ 2 - 2
assets/scene/MainScene.fire

@@ -565,8 +565,8 @@
       "width": 750,
       "height": 1334
     },
-    "_fitWidth": false,
-    "_fitHeight": true,
+    "_fitWidth": true,
+    "_fitHeight": false,
     "_id": "59Cd0ovbdF4byw5sbjJDx7"
   },
   {

+ 3 - 0
assets/script/game/component/BtnClosePanel.ts

@@ -13,6 +13,8 @@ export default class BtnClosePanel extends cc.Component {
     @property({ displayName: '完成回调', tooltip: "面板打开完成后触发", type: cc.Component.EventHandler })
     public onComplete: cc.Component.EventHandler[] = [];
 
+    /** 阻断点击 */
+    public block_click: boolean = false;
     onLoad() {
         if (!this.node.getComponent(cc.Button)) this.node.addComponent(cc.Button);
     }
@@ -22,6 +24,7 @@ export default class BtnClosePanel extends cc.Component {
     }
 
     private async closePanel() {
+        if (this.block_click) return;
         if (this.node_panel) {
             mk.ui.closePanel(this.node_panel.name);
         }

+ 12 - 0
assets/script/game/data/GameData.ts

@@ -139,6 +139,7 @@ export enum GameProp {
     /** 当前能否签到 */
     sign_can = 121,
 }
+
 /**
  * 奖励状态
  */
@@ -149,4 +150,15 @@ export enum RewardState {
     lock = 2,
     /** 可领取 */
     unlock = 3
+}
+
+/**
+ * 音频路径
+ */
+export enum AUDIO_TYPE {
+    bgm = 'Background_music1',           //背景音乐
+    button = 'Button_click',            //按钮点击音效
+    turntableDraw = 'turntable1',           //转盘抽奖结束
+    turntableDrawEnd = 'turntable_2',           //转盘抽奖音效
+    getGold = 'Get_gold',       //获取金币音效
 }

+ 0 - 7
assets/script/game/data/module/PigBankData.ts

@@ -39,13 +39,6 @@ export class PigBankData extends Data {
 
     /** 提现最低限制 */
     public cash_min_limit: number = 0.3;
-    /** 存款最高限制 */
-    // public cash_max_limit: number = 0.45;
-    /** 
-     * 视频数最低限制 
-     * 存钱罐提现次数*10【配置】,未满足视频数要求则不打款
-    */
-    // public ad_count_min_limit: number = 0;
 
     /** 
      * 提现操作

+ 16 - 3
assets/script/game/data/module/RewardData.ts

@@ -2,9 +2,22 @@ import { Data } from "../../../mk/data/Data";
 
 /**
  * @description 奖励数据
- * @author 邹勇
+ * @author 邹勇 薛鸿潇
  */
- export class RewardData extends Data{
+export class RewardData extends Data {
+    public init_luck_style: boolean = false;
 
-    data:any;
+    /** 默认幸运红包 */
+    private _is_luck: boolean = true;
+    /** 是幸运红包 不是通关红包 */
+    set is_luck(value: boolean) {
+        this._is_luck = value;
+        this.init_luck_style = true;
+    }
+    get is_luck() {
+        return this._is_luck;
+    }
+
+    /** 奖励列表 */
+    data: any;
 }

+ 0 - 247
assets/script/game/manager/AudioManager.ts

@@ -1,247 +0,0 @@
-/**
- * 音频模块
- * @author 薛鸿潇
- */
-export default class AudioManager {
-
-    /** 音乐开关 */
-    private _switchMusic: boolean = true;
-    /** 音效开关 */
-    private _switchEffect: boolean = true;
-    /** 音效音量 */
-    private _effectVolume: number = 1;
-    /** 音乐音量 */
-    private _musicVolume: number = 1;
-    /** 暂时音效开关 */
-    private _switchTempEffect: boolean = true;
-    /** 音频map */
-    private _map_audio: Map<AUDIO_NAME, cc.AudioClip> = new Map();
-
-    /** 初始化 */
-    public init() {
-        // 获取本地开关设置
-        let effect = cc.sys.localStorage.getItem("switchEffect");
-        if (effect) {
-            if (effect == "true") {
-                this._switchEffect = true;
-            } else {
-                this._switchEffect = false;
-            }
-        }
-
-        let music = cc.sys.localStorage.getItem("switchMusic");
-        if (music) {
-            if (music == "true") {
-                this._switchMusic = true;
-            } else {
-                this._switchMusic = false;
-            }
-        }
-
-        if (this._switchMusic) {
-            this.playMusic('bgm', true)
-        }
-    }
-
-    /**
-     * 播放音乐文件
-     * @param audio_name 音频名字
-     * @param loop 是否循环【默认循环】
-     */
-    public async playMusic(audio_name: AUDIO_NAME, loop: boolean = true) {
-        let asset = this._map_audio.get(audio_name);
-        if (!asset) {
-            asset = await mk.loader.load(AUDIO_PATH + audio_name, cc.AudioClip);
-            this._map_audio.set(audio_name, asset);
-        }
-        mk.audio.playMusic(asset, loop);
-    }
-
-    /**
-     * 播放音效文件
-     * @param audio_name 音频名字
-     * @param loop 是否循环【默认不循环】
-     */
-    public async playEffect(audio_name: AUDIO_NAME, loop: boolean = false) {
-        if (this._switchEffect && this._switchTempEffect) {
-            let asset = this._map_audio.get(audio_name);
-            if (!asset) {
-                asset = await mk.loader.load(AUDIO_PATH + audio_name, cc.AudioClip);
-                this._map_audio.set(audio_name, asset);
-            }
-            mk.audio.playEffect(asset, loop);
-        }
-    }
-
-    /**
-     * 停止播放音效
-     * @param audio_id 音频id
-     */
-    public stopEffect(audio_id: number) {
-        mk.audio.stopEffect(audio_id);
-    }
-
-    /**
-     * 转换音效开关
-     */
-    public switchEffectFunc() {
-        this._switchEffect = !this._switchEffect;
-        if (!this._switchEffect) {
-            this.setStopAllEffect();
-        }
-        cc.sys.localStorage.setItem("switchEffect", this._switchEffect.toString());
-    }
-
-    /**
-     * 获取音效开关状态
-     * @returns {boolean}
-     */
-    public getSwitchEffect(): boolean {
-        return this._switchEffect;
-    }
-
-    /**
-     * 设置音效声音大小
-     * value: 0.0 - 1.0
-     */
-    public setEffectVolume(value: number) {
-        this._effectVolume = value;
-        mk.audio.setEffectVolume(value);
-        cc.sys.localStorage.setItem("audio", JSON.stringify({ effect: this._effectVolume, music: this._musicVolume }));
-    }
-
-    /**
-     * 获取音效大小
-     * @return {number} 0.0 - 1.0
-     */
-    public getEffectVolume(): number {
-        return mk.audio.getEffectVolume();
-    }
-
-    /**
-     * 恢复当前说暂停的所有音效
-     */
-    public setResumeAllEffect() {
-        if (this._switchEffect) {
-            mk.audio.resumeAllEffects();
-        }
-    }
-
-    /**
-     * 停止播放所有正在播放的音效
-     */
-    public setStopAllEffect() {
-        mk.audio.stopAllEffects();
-    }
-
-    /** 暂时开启关闭音效开关
-     * @param state true  打开  false 关闭
-     */
-    public setTempEffect(state: boolean) {
-        this._switchTempEffect = state;
-    }
-
-    /**
-     * 转换音乐按钮开关
-     */
-    public switchMusicFunc() {
-        this._switchMusic = !this._switchMusic;
-        if (!this._switchMusic) {
-            this.stopMusic();
-        } else {
-            this.playMusic('bgm');
-        }
-        cc.sys.localStorage.setItem("switchMusic", this._switchMusic.toString());
-    }
-
-    /**
-     * 获取音乐开关状态
-     * @returns {boolean}
-     */
-    public getSwitchMusic() {
-        return this._switchMusic;
-    }
-
-    /**
-     * 暂停当前播放音乐
-     */
-    public setPauseMusic() {
-        mk.audio.pauseMusic();
-    }
-
-    /**
-     * 恢复当前被暂停音乐音乐
-     */
-    public setResumeMusic() {
-        if (this._switchMusic) {
-            mk.audio.resumeMusic();
-        }
-    }
-
-    /**
-     * 暂停所有 music
-     */
-    public stopMusic() {
-        mk.audio.stopMusic();
-    }
-
-    /**
-     * 设置music音量
-     * @param value 音量
-     */
-    public setMusicVolume(value: number) {
-        this._musicVolume = value;
-        mk.audio.setMusicVolume(value);
-        cc.sys.localStorage.setItem("audio", JSON.stringify({ effect: this._effectVolume, music: this._musicVolume }));
-    }
-
-    /**
-     * 获取当前music音量
-     * @returns {number} 音量
-     */
-    public getMusicVolume() {
-        return mk.audio.getMusicVolume();
-    }
-
-    /**
-     * 音乐是否正在播放(验证些方法来实现背景音乐是否播放完成)
-     * @returns {boolen}
-     */
-    public isMusicPlaying() {
-        return mk.audio.isMusicPlaying();
-    }
-
-    /**
-     * 释放指定音效资源
-     * @param audio 音频资源
-     */
-    public releaseAudio(audio: cc.AudioClip) {
-        if (!audio) {
-            cc.error("【音频】资源" + audio + "不存在, 释放失败")
-            return;
-        }
-        mk.audio.releaseAudio(audio);
-    }
-
-    /** 停止所有音效 */
-    public stopAllAudio() {
-        mk.audio.stopAllAudio();
-    }
-
-    /** 卸载所有音频 */
-    public releaseAllAudio() {
-        mk.audio.releaseAllAudio();
-    }
-}
-/** 音频路径 */
-const AUDIO_PATH = 'music/';
-/** 声音枚举 */
-enum AUDIO_TYPE {
-    bgm = 'Background_music1',           //背景音乐
-    button = 'Button_click',            //按钮点击音效
-    turntableDraw = 'turntable1',           //转盘抽奖结束
-    turntableDrawEnd = 'turntable_2',           //转盘抽奖音效
-    getGold = 'Get_gold',       //获取金币音效
-}
-/** 外部读取到的类型 */
-type AUDIO_NAME = keyof typeof AUDIO_TYPE;

+ 0 - 9
assets/script/game/manager/AudioManager.ts.meta

@@ -1,9 +0,0 @@
-{
-  "ver": "1.0.8",
-  "uuid": "23fb4f4f-fbcf-4147-8940-a4e141f50f3c",
-  "isPlugin": false,
-  "loadPluginInWeb": true,
-  "loadPluginInNative": true,
-  "loadPluginInEditor": false,
-  "subMetas": {}
-}

+ 2 - 1
assets/script/game/module/game/FunBtns.ts

@@ -23,7 +23,8 @@ export default class FunBtns extends cc.Component {
     }
 
     init() {
-        let data = [1, 1, 0, 1];
+        // data功能开启
+        let data = [1, 1, 1, 1];
         for (let i = 0; i < data.length; i++) {
             if (data[i] == 0) {
                 this['btn' + (i + 1)].active = data[i] == 1;

+ 76 - 11
assets/script/game/module/module/reward/Reward.ts

@@ -1,25 +1,90 @@
-// Learn TypeScript:
-//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
-// Learn Attribute:
-//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
-// Learn life-cycle callbacks:
-//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
 
 const { ccclass, property } = cc._decorator;
-
+/**
+ * 获取奖励界面-红包
+ * @author 薛鸿潇
+ */
 @ccclass
-export default class reward extends cc.Component {
+export default class Reward extends cc.Component {
+
+    @property({ displayName: '按钮看视频', type: cc.Button })
+    private btn_watch_video: cc.Button = null;
+
+    @property({ displayName: '幸运红包', type: cc.Node })
+    private node_luck: cc.Node = null;
+    @property({ displayName: '通关红包', type: cc.Node })
+    private node_mission: cc.Node = null;
+
+    @property({ displayName: 'spr提现进度', type: cc.Sprite })
+    private spr_cash_out: cc.Sprite = null;
+    @property({ displayName: 'lbl提现进度', type: cc.Label })
+    private lbl_cash_out: cc.Label = null;
+    @property({ displayName: '提现金额', type: cc.Label })
+    private lbl_cash: cc.Label = null;
+
 
-    @property({ displayName: '领取按钮', type: cc.Button })
-    private btn_receive: cc.Button = null;
+    @property({ displayName: '开红包动画', type: cc.Animation })
+    private anim_open_redbag: cc.Animation = null;
 
     onLoad() {
 
     }
 
     start() {
+        /** 盖子 */
+        this.initLid();
+    }
+
+    update(dt) {
+        if (gData.reward.init_luck_style) {
+            gData.reward.init_luck_style = false;
+            this.initLid();
+        }
+    }
+
+    /**
+     * 初始化封面样式
+     */
+    private initLid() {
+        if (gData.reward.is_luck) {
+            this.node_luck.active = true;
+            this.node_mission.active = false;
+        } else {
+            this.node_luck.active = false;
+            this.node_mission.active = true;
+        }
+    }
+
+    /**
+     * 看广告
+     */
+    private clickWatchVideo() {
+        cc.log('看广告请求');
+        this.anim_open_redbag.play();
+        this.node_luck.active = false;
+        this.node_mission.active = false;
+        this.btn_watch_video.node.active = false;;
+    }
+
+    /**
+     * 获得奖励
+     */
+    private clickGetReward() {
+        cc.log('获取奖励:', gData.reward.data);
+    }
+
+    /**
+     * 提现操作
+     */
+    private clickCashOut() {
+        cc.log('提现:');
+    }
+
+    /**
+     * 下一关操作
+     */
+    private clickNextMission() {
 
     }
 
-    // update (dt) {}
 }

+ 6 - 7
assets/script/game/module/module/turntable/Turnable.ts

@@ -1,4 +1,5 @@
 import { PanelType } from "../../../../mk/system/UISystem";
+import BtnClosePanel from "../../../component/BtnClosePanel";
 import { AdFun } from "../../../data/AdData";
 import { GameProp } from "../../../data/GameData";
 import TurnableItem from "./TurnableItem";
@@ -18,8 +19,6 @@ export default class Turnable extends cc.Component {
     @property(cc.RichText)
     lbl_left: cc.RichText = null;
 
-    private isPlaying: boolean = false;
-
     onLoad() {
         this.initData();
     }
@@ -43,19 +42,19 @@ export default class Turnable extends cc.Component {
     }
 
     private play() {
-        this.isPlaying = true;
+        this.btn_close.getComponent(BtnClosePanel).block_click = true;
         this.node_turn.angle = 1800;
         let index = 2;
         let tar = index * 60;
         cc.tween(this.node_turn)
-            .to(3, { angle: tar }, { easing: 'expoInOut' })
+            .to(5, { angle: tar }, { easing: 'expoInOut' })
             .call(this.playOver, this).start();
     }
 
-    private playOver(){
-        this.isPlaying = false;
+    private playOver() {
+        this.btn_close.getComponent(BtnClosePanel).block_click = false;
         this.updateLeftTimes();
-        mk.ui.openPanel("reward",PanelType.module);
+        mk.ui.openPanel("reward", PanelType.module);
     }
 
     updateLeftTimes() {

+ 145 - 39
assets/script/mk/system/AudioSystem.ts

@@ -1,99 +1,205 @@
+import { AUDIO_TYPE } from "../../game/data/GameData";
+
 /**
  * 音频模块
  * @author 薛鸿潇
  */
 export default class AudioSystem {
 
+    /** 音乐开关 */
+    private _switchMusic: boolean = true;
+    /** 音效开关 */
+    private _switchEffect: boolean = true;
+    /** 音效音量 */
+    private _effectVolume: number = 1;
+    /** 音乐音量 */
+    private _musicVolume: number = 1;
+    /** 暂时音效开关 */
+    private _switchTempEffect: boolean = true;
+    /** 音频map */
+    private _map_audio: Map<AUDIO_NAME, cc.AudioClip> = new Map();
+
+    /** 初始化 */
+    public init() {
+        // 获取本地开关设置
+        let effect = cc.sys.localStorage.getItem("switchEffect");
+        if (effect) {
+            if (effect == "true") {
+                this._switchEffect = true;
+            } else {
+                this._switchEffect = false;
+            }
+        }
+
+        let music = cc.sys.localStorage.getItem("switchMusic");
+        if (music) {
+            if (music == "true") {
+                this._switchMusic = true;
+            } else {
+                this._switchMusic = false;
+            }
+        }
+
+        if (this._switchMusic) {
+            this.playMusic('bgm', true)
+        }
+    }
+
     /**
-     * 背景音乐播放
-     * @param clip 音频资源
-     * @param loop 循环
-     * @returns audio_id
+     * 播放音乐文件
+     * @param audio_name 音频名字
+     * @param loop 是否循环【默认循环】
      */
-    public playMusic(clip: cc.AudioClip, loop: boolean = false): number {
-        return cc.audioEngine.playMusic(clip, loop);
+    public async playMusic(audio_name: AUDIO_NAME, loop: boolean = true) {
+        let asset = this._map_audio.get(audio_name);
+        if (!asset) {
+            asset = await mk.loader.load(AUDIO_PATH + audio_name, cc.AudioClip);
+            this._map_audio.set(audio_name, asset);
+        }
+        cc.audioEngine.playMusic(asset, loop);
     }
 
     /**
      * 播放音效文件
-     * @param clip 
-     * @param loop 
-     * @returns audio_id
-     */
-    public playEffect(clip: cc.AudioClip, loop = false): number {
-        return cc.audioEngine.playEffect(clip, loop);
+     * @param audio_name 音频名字
+     * @param loop 是否循环【默认不循环】
+     */
+    public async playEffect(audio_name: AUDIO_NAME, loop: boolean = false) {
+        if (this._switchEffect && this._switchTempEffect) {
+            let asset = this._map_audio.get(audio_name);
+            if (!asset) {
+                asset = await mk.loader.load(AUDIO_PATH + audio_name, cc.AudioClip);
+                this._map_audio.set(audio_name, asset);
+            }
+            cc.audioEngine.playEffect(asset, loop);
+        }
     }
 
     /**
      * 停止播放音效
-     * @param audio_id 
+     * @param audio_id 音频id
      */
-    public stopEffect(audio_id: number): void {
+    public stopEffect(audio_id: number) {
         cc.audioEngine.stopEffect(audio_id);
     }
 
     /**
+     * 转换音效开关
+     */
+    public switchEffectFunc() {
+        this._switchEffect = !this._switchEffect;
+        if (!this._switchEffect) {
+            this.setStopAllEffect();
+        }
+        cc.sys.localStorage.setItem("switchEffect", this._switchEffect.toString());
+    }
+
+    /**
+     * 获取音效开关状态
+     * @returns {boolean}
+     */
+    public getSwitchEffect(): boolean {
+        return this._switchEffect;
+    }
+
+    /**
      * 设置音效声音大小
-     * @param value 
+     * value: 0.0 - 1.0
      */
-    public setEffectVolume(value: number): void {
+    public setEffectVolume(value: number) {
+        this._effectVolume = value;
         cc.audioEngine.setEffectsVolume(value);
+        cc.sys.localStorage.setItem("audio", JSON.stringify({ effect: this._effectVolume, music: this._musicVolume }));
     }
 
     /**
      * 获取音效大小
-     * @return 0.0 - 1.0
+     * @return {number} 0.0 - 1.0
      */
     public getEffectVolume(): number {
         return cc.audioEngine.getEffectsVolume();
     }
 
     /**
+     * 恢复当前说暂停的所有音效
+     */
+    public setResumeAllEffect() {
+        if (this._switchEffect) {
+            cc.audioEngine.resumeAllEffects();
+        }
+    }
+
+    /**
      * 停止播放所有正在播放的音效
      */
-    public stopAllEffects() {
+    public setStopAllEffect() {
         cc.audioEngine.stopAllEffects();
     }
 
+    /** 暂时开启关闭音效开关
+     * @param state true  打开  false 关闭
+     */
+    public setTempEffect(state: boolean) {
+        this._switchTempEffect = state;
+    }
+
     /**
-     * 暂停当前播放音乐
+     * 转换音乐按钮开关
      */
-    public pauseMusic() {
-        cc.audioEngine.pauseMusic();
+    public switchMusicFunc() {
+        this._switchMusic = !this._switchMusic;
+        if (!this._switchMusic) {
+            this.stopMusic();
+        } else {
+            this.playMusic('bgm');
+        }
+        cc.sys.localStorage.setItem("switchMusic", this._switchMusic.toString());
     }
 
     /**
-     * 恢复当前说暂停的所有音效
+     * 获取音乐开关状态
+     * @returns {boolean}
      */
-    public resumeAllEffects() {
-        cc.audioEngine.resumeAllEffects();
+    public getSwitchMusic() {
+        return this._switchMusic;
+    }
+
+    /**
+     * 暂停当前播放音乐
+     */
+    public setPauseMusic() {
+        cc.audioEngine.pauseMusic();
     }
 
     /**
      * 恢复当前被暂停音乐音乐
      */
-    public resumeMusic() {
-        cc.audioEngine.resumeMusic();
+    public setResumeMusic() {
+        if (this._switchMusic) {
+            cc.audioEngine.resumeMusic();
+        }
     }
 
     /**
-     * 暂停播放音乐
+     * 暂停所有 music
      */
     public stopMusic() {
         cc.audioEngine.stopMusic();
     }
 
     /**
-     * 设置音乐音量
-     * @param value 0~1音量
+     * 设置music音量
+     * @param value 音量
      */
     public setMusicVolume(value: number) {
+        this._musicVolume = value;
         cc.audioEngine.setMusicVolume(value);
+        cc.sys.localStorage.setItem("audio", JSON.stringify({ effect: this._effectVolume, music: this._musicVolume }));
     }
 
     /**
-     * 获取音乐音量
-     * @returns {number}
+     * 获取当前music音量
+     * @returns {number} 音量
      */
     public getMusicVolume() {
         return cc.audioEngine.getMusicVolume();
@@ -101,7 +207,7 @@ export default class AudioSystem {
 
     /**
      * 音乐是否正在播放(验证些方法来实现背景音乐是否播放完成)
-     * @returns {boolean}
+     * @returns {boolen}
      */
     public isMusicPlaying() {
         return cc.audioEngine.isMusicPlaying();
@@ -119,17 +225,17 @@ export default class AudioSystem {
         cc.audioEngine.uncache(audio);
     }
 
-    /**
-     * 停止所有音频
-     */
+    /** 停止所有音效 */
     public stopAllAudio() {
         cc.audioEngine.stopAll();
     }
 
-    /**
-     * 释放所有音频
-     */
+    /** 卸载所有音频 */
     public releaseAllAudio() {
         cc.audioEngine.uncacheAll();
     }
-}
+}
+/** 音频路径 */
+const AUDIO_PATH = 'music/';
+/** 外部读取到的类型 */
+type AUDIO_NAME = keyof typeof AUDIO_TYPE;

+ 1 - 1
assets/script/mk/system/AudioSystem.ts.meta

@@ -1,6 +1,6 @@
 {
   "ver": "1.0.8",
-  "uuid": "1506c7e8-e3ee-4092-83cc-a17f3a7c051d",
+  "uuid": "23fb4f4f-fbcf-4147-8940-a4e141f50f3c",
   "isPlugin": false,
   "loadPluginInWeb": true,
   "loadPluginInNative": true,

+ 1 - 1
assets/script/mk/system/MKSystem.ts

@@ -1,7 +1,6 @@
 import BuglySDK from "../sdk/BuglySDK";
 import FileUtil from "../utils/FileUtil";
 import TimeUtil from "../utils/TimeUtil";
-import AudioSystem from "./AudioSystem";
 import DataSystem from "./DataSystem";
 import HttpSystem from "./HttpSystem";
 import LoadResUtil from "../utils/LoadResUtil";
@@ -16,6 +15,7 @@ import MathUtil from "../utils/MathUtil";
 import AdSystem from "./AdSystem";
 import JsbSystem from "./JsbSystem";
 import ATSDKMgr from "../sdk/ad/toppon/AnyThinkAdsMgr/ATSDKMgr";
+import AudioSystem from "./AudioSystem";
 
 /**
  * @description mk系统

部分文件因文件數量過多而無法顯示