20cf03cb-52d3-4fbb-8290-d3f499227e46.js
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"use strict";
cc._RF.push(module, '20cf0PLUtNPu4KQ0/SZIn5G', 'SoundManager');
// scripts/component/SoundManager.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SoundManager = void 0;
var Global_1 = require("../Global");
var SaveDataManager_1 = require("./SaveDataManager");
var SoundManager = /** @class */ (function () {
function SoundManager() {
this._cdMap = new Map();
}
Object.defineProperty(SoundManager, "ins", {
get: function () {
if (this._ins == null) {
this._ins = new SoundManager();
}
return this._ins;
},
enumerable: false,
configurable: true
});
SoundManager.prototype.update = function (dt) {
this._cdMap.forEach(function (value, key, map) {
if (value > 0) {
value -= dt;
}
if (value < 0) {
value = 0;
}
map.set(key, value);
}, this);
};
SoundManager.prototype.playEffect = function (clipName) {
if (!SaveDataManager_1.SaveDataManager.ins.runtimeData.SEMute) {
if (clipName == Global_1.SoundName.HIT || clipName == Global_1.SoundName.BREAK) {
//检查cd
if (this._cdMap.has(clipName) && this._cdMap.get(clipName) > 0) {
return;
}
else {
var cd = (clipName == Global_1.SoundName.HIT ? 0.1 : 0.6);
this._cdMap.set(clipName, cd);
}
}
var clip = cc.resources.get('soundEffect/' + clipName, cc.AudioClip);
if (clip) {
cc.audioEngine.playEffect(clip, false);
}
else {
cc.warn('can not find audio clip:', clipName);
}
}
};
SoundManager.prototype.playMusic = function () {
if (!SaveDataManager_1.SaveDataManager.ins.runtimeData.musicMute) {
var clip = cc.resources.get('soundEffect/' + Global_1.SoundName.BGM, cc.AudioClip);
if (clip && !cc.audioEngine.isMusicPlaying()) {
cc.audioEngine.playMusic(clip, true);
}
// else {
// cc.warn('can not find audio clip: BGM');
// }
}
};
SoundManager.prototype.stopMusic = function () {
if (cc.audioEngine.isMusicPlaying()) {
cc.audioEngine.stopMusic();
}
};
SoundManager._ins = null;
return SoundManager;
}());
exports.SoundManager = SoundManager;
cc._RF.pop();