Files
tothvillar e896e2ead4 init
2026-07-09 15:04:14 +08:00

188 lines
3.9 KiB
JavaScript

function i(e, o) {
if (!(e instanceof o)) {
throw new TypeError("Cannot call a class as a function");
}
}
function n(e, o) {
for (var t = 0; t < o.length; t++) {
var i = o[t];
i.enumerable = i.enumerable || false;
i.configurable = true;
"value" in i && (i.writable = true);
Object.defineProperty(e, i.key, i);
}
}
function a(e, o, t) {
o && n(e.prototype, o);
t && n(e, t);
return e;
}
var c = function () {
function e() {
i(this, e);
this.activateVoice = true;
this.activateMusic = true;
this.volume = 0;
this.activateMusic = true;
this.activateEffect = true;
this.volume = 0;
}
a(e, [{
key: "playMusic",
value: function (e) {
if (this.activateMusic) {
var o = cc.Utils.AssetMgr.getAudioByName(e);
this.SoundIndex = cc.audioEngine.playMusic(o, true);
}
}
}, {
key: "stopMusic",
value: function () {
this.SoundIndex = -1;
cc.audioEngine.stopMusic();
}
}, {
key: "playEffect",
value: function (e) {
if (this.activateEffect) {
var o = cc.Utils.AssetMgr.getAudioByName(e);
cc.audioEngine.playEffect(o, false);
}
}
}]);
return e;
}();
var s = function () {
function e() {
i(this, e);
}
a(e, [{
key: "randomArray",
value: function (e) {
e.sort(function (e, o) {
if (Math.random() > .5) {
return -1;
} else {
return 1;
}
});
}
}]);
return e;
}();
var l = function () {
function e() {
i(this, e);
}
a(e, [{
key: "getCountDays",
value: function () {
var e = new Date();
return Math.floor(e / 864e5);
}
}]);
return e;
}();
var r = function () {
function e() {
i(this, e);
}
a(e, [{
key: "getRandomNum",
value: function (e, o) {
var t = o - e;
var i = Math.random();
return e + Math.round(i * t);
}
}, {
key: "getTwoVectorDegree",
value: function (e, o) {
var t = o.x - e.x;
var i = o.y - e.y;
var n = Math.atan2(i, t);
return cc.misc.radiansToDegrees(n) - 90;
}
}, {
key: "getMoveVector",
value: function (e, o) {
var t = cc.misc.degreesToRadians(e);
var i = cc.v2();
i.x = -Math.sin(t) * o;
i.y = Math.cos(t) * o;
return i;
}
}]);
return e;
}();
var d = function () {
function e() {
i(this, e);
}
a(e, [{
key: "getSpriteFrameByName",
value: function (e) {
for (var o in cc.SpriteFrames) {
var t = cc.SpriteFrames[o];
if (t.name === e) {
return t;
}
}
return null;
}
}, {
key: "getAudioByName",
value: function (e) {
for (var o in cc.Audios) {
var t = cc.Audios[o];
if (e === t.name) {
return t;
}
}
return null;
}
}, {
key: "getPrefabByName",
value: function (e) {
for (var o in cc.Prefabs) {
var t = cc.Prefabs[o];
if (t.name === e) {
return t;
}
}
return null;
}
}, {
key: "showMessage",
value: function (e) {
cc.view.getVisibleSize();
var o = cc.instantiate(this.getPrefabByName("Message"));
var t = cc.v2(cc.view.getVisibleSize().width / 2, cc.view.getVisibleSize().height / 2);
o.position = t;
cc.director.getScene().addChild(o);
o.getComponent("Message").setMessage(e);
}
}, {
key: "generateCurrency",
value: function (e, o, t, i, n) {
for (var a = 0; a < t; a++) {
var c = cc.instantiate(this.getPrefabByName("CurrencyItem"));
e.addChild(c);
c.getComponent("CurrencyItem").setDisplayInformation(o, i, n);
}
}
}]);
return e;
}();
module.exports = {
SoundMgr: new c(),
StringMgr: new function e() {
i(this, e);
}(),
ArrayMgr: new s(),
TimeMgr: new l(),
MathMgr: new r(),
NumberMgr: new function e() {
i(this, e);
}(),
AssetMgr: new d()
};