"use strict";
cc._RF.push(module, 'aca4aut33NCvIC0yg3JmY0h', 'Pause');
// Script/Pause.ts

"use strict";
// 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
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var Pause = /** @class */ (function (_super) {
    __extends(Pause, _super);
    function Pause() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.time = 0;
        _this.music = null;
        _this.effect = null;
        _this.vibrate = null;
        _this.open = null;
        _this.close = null;
        // mapInfo: number[][] = [];
        _this.musicState = true;
        _this.effectState = true;
        _this.vibrateState = true;
        return _this;
        // update (dt) {}
    }
    Pause.prototype.onLoad = function () {
        if (cc.fx.GameConfig.GM_INFO.musicOpen) {
            this.music.getComponent(cc.Sprite).spriteFrame = this.open;
            this.music.x = 278;
        }
        else {
            this.music.getComponent(cc.Sprite).spriteFrame = this.close;
            this.music.x = 161;
        }
        if (cc.fx.GameConfig.GM_INFO.effectOpen) {
            this.effect.getComponent(cc.Sprite).spriteFrame = this.open;
            this.effect.x = 278;
        }
        else {
            this.effect.getComponent(cc.Sprite).spriteFrame = this.close;
            this.effect.x = 161;
        }
        if (cc.fx.GameConfig.GM_INFO.vibrateOpen) {
            this.vibrate.getComponent(cc.Sprite).spriteFrame = this.open;
            this.vibrate.x = 278;
        }
        else {
            this.vibrate.getComponent(cc.Sprite).spriteFrame = this.close;
            this.vibrate.x = 161;
        }
        this.musicState = cc.fx.GameConfig.GM_INFO.musicOpen;
        this.effectState = cc.fx.GameConfig.GM_INFO.effectOpen;
        this.vibrateState = cc.fx.GameConfig.GM_INFO.vibrateOpen;
    };
    Pause.prototype.start = function () {
    };
    Pause.prototype.init = function (time) {
    };
    Pause.prototype.clickMusic = function () {
        var _this = this;
        if (this.musicState) {
            this.musicState = false;
            cc.fx.GameConfig.GM_INFO.musicOpen = this.musicState;
            this.setMusicConfig();
            this.music.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161, this.music.y)), cc.fadeOut(0.05)), cc.callFunc(function () {
                _this.music.getComponent(cc.Sprite).spriteFrame = _this.close;
            }), cc.fadeIn(0.1)));
            cc.fx.AudioManager._instance.stopMusic();
        }
        else {
            this.musicState = true;
            cc.fx.GameConfig.GM_INFO.musicOpen = this.musicState;
            this.setMusicConfig();
            this.music.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278, this.music.y)), cc.fadeOut(0.05)), cc.callFunc(function () {
                _this.music.getComponent(cc.Sprite).spriteFrame = _this.open;
            }), cc.fadeIn(0.1)));
            cc.fx.AudioManager._instance.playMusicGame();
        }
    };
    Pause.prototype.setMusicConfig = function () {
        var audioInfo = {
            "musicOpen": cc.fx.GameConfig.GM_INFO.musicOpen,
            "effectOpen": cc.fx.GameConfig.GM_INFO.effectOpen,
            "vibrateOpen": cc.fx.GameConfig.GM_INFO.vibrateOpen,
        };
        cc.fx.StorageMessage.setStorage("music", audioInfo);
    };
    Pause.prototype.clickEffect = function () {
        var _this = this;
        if (this.effectState) {
            this.effectState = false;
            cc.fx.GameConfig.GM_INFO.effectOpen = this.effectState;
            this.setMusicConfig();
            this.effect.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161, this.effect.y)), cc.fadeOut(0.05)), cc.callFunc(function () {
                _this.effect.getComponent(cc.Sprite).spriteFrame = _this.close;
            }), cc.fadeIn(0.1)));
        }
        else {
            this.effectState = true;
            cc.fx.GameConfig.GM_INFO.effectOpen = this.effectState;
            this.setMusicConfig();
            this.effect.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278, this.effect.y)), cc.fadeOut(0.05)), cc.callFunc(function () {
                _this.effect.getComponent(cc.Sprite).spriteFrame = _this.open;
            }), cc.fadeIn(0.1)));
        }
    };
    Pause.prototype.clickVibrate = function () {
        var _this = this;
        if (this.vibrateState) {
            this.vibrateState = false;
            cc.fx.GameConfig.GM_INFO.vibrateOpen = this.vibrateState;
            this.setMusicConfig();
            this.vibrate.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161, this.vibrate.y)), cc.fadeOut(0.05)), cc.callFunc(function () {
                _this.vibrate.getComponent(cc.Sprite).spriteFrame = _this.close;
            }), cc.fadeIn(0.1)));
        }
        else {
            this.vibrateState = true;
            cc.fx.GameConfig.GM_INFO.vibrateOpen = this.vibrateState;
            this.setMusicConfig();
            this.vibrate.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278, this.vibrate.y)), cc.fadeOut(0.05)), cc.callFunc(function () {
                _this.vibrate.getComponent(cc.Sprite).spriteFrame = _this.open;
            }), cc.fadeIn(0.1)));
        }
    };
    __decorate([
        property(cc.Node)
    ], Pause.prototype, "music", void 0);
    __decorate([
        property(cc.Node)
    ], Pause.prototype, "effect", void 0);
    __decorate([
        property(cc.Node)
    ], Pause.prototype, "vibrate", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], Pause.prototype, "open", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], Pause.prototype, "close", void 0);
    Pause = __decorate([
        ccclass
    ], Pause);
    return Pause;
}(cc.Component));
exports.default = Pause;

cc._RF.pop();