feat: update sound
parent
bfd8270909
commit
78b94f8b17
|
@ -1137,7 +1137,8 @@
|
|||
"__id__": 73
|
||||
},
|
||||
"displayName": "CHEESE",
|
||||
"time": 10,
|
||||
"duration": 10,
|
||||
"speedUpBgm": 1.5,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
|
|
@ -326,7 +326,7 @@
|
|||
"__id__": 16
|
||||
},
|
||||
"_hitSound": {
|
||||
"__uuid__": "1fe7a4a1-5174-476b-a19c-a3366391bfcc",
|
||||
"__uuid__": "a5d745ea-77ac-45f7-9add-2d7cecf14588",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"_score": 0,
|
||||
|
|
|
@ -1916,7 +1916,7 @@
|
|||
"__id__": 145
|
||||
},
|
||||
"_collectSound": {
|
||||
"__uuid__": "05a2671e-35bb-4be0-9244-43d541b9a26a",
|
||||
"__uuid__": "b1cc499c-0470-4e1c-bc27-776d6b3a7589",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"_animation": {
|
||||
|
@ -1927,6 +1927,11 @@
|
|||
},
|
||||
"displayName": "CHEESE",
|
||||
"duration": 10,
|
||||
"speedUpBgm": 1,
|
||||
"backgroundMusic": {
|
||||
"__uuid__": "6cf3abb2-39ba-4429-89dc-e55c89109b58",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -18,7 +18,6 @@ import AudioManager from '../Manager/AudioManager';
|
|||
import { EventManger } from '../Manager/EventManger';
|
||||
import { GameManager } from '../Manager/GameManager';
|
||||
import IPoolable from '../Pool/IPoolable';
|
||||
import ObjectPool from '../Pool/ObjectPool';
|
||||
import Utils from '../Utilities';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
@ -40,7 +39,7 @@ export class BoosterBase extends Component implements IPoolable {
|
|||
protected duration: number = 10;
|
||||
|
||||
public readonly type: BoosterType;
|
||||
private _timer: number = 0;
|
||||
protected timer: number = 0;
|
||||
private _activeCollider: boolean = true;
|
||||
private _active: boolean = false;
|
||||
|
||||
|
@ -67,19 +66,19 @@ export class BoosterBase extends Component implements IPoolable {
|
|||
|
||||
public tick(dt: number) {
|
||||
if (!this._active) return;
|
||||
this._timer += dt;
|
||||
if (this._timer >= this.duration) {
|
||||
this.timer += dt;
|
||||
if (this.timer >= this.duration) {
|
||||
this._active = false;
|
||||
}
|
||||
}
|
||||
|
||||
public resetTime() {
|
||||
this._timer = 0;
|
||||
this.timer = 0;
|
||||
}
|
||||
|
||||
public collect(collector: Node) {
|
||||
this._active = true;
|
||||
this._timer = 0;
|
||||
this.timer = 0;
|
||||
this.sprite.setNodeActive(false);
|
||||
this.node.setParent(collector, false);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { _decorator, Component, Node } from 'cc';
|
||||
import { _decorator, AudioClip, CCFloat, clamp01, Component, game, macro, Node } from 'cc';
|
||||
import SpineAnimationHandler from '../Base/SpineAnimationHandler';
|
||||
import BoosterType from '../Enum/BoosterType';
|
||||
import AudioManager from '../Manager/AudioManager';
|
||||
import AudioManager, { SoundSource } from '../Manager/AudioManager';
|
||||
import { BoosterBase } from './BoosterBase';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
@ -9,6 +9,13 @@ const { ccclass, property } = _decorator;
|
|||
export class CumulativeBooster extends BoosterBase {
|
||||
@property(SpineAnimationHandler)
|
||||
private animationHandler: SpineAnimationHandler;
|
||||
@property(CCFloat)
|
||||
private speedUpBgm: number = 1.5;
|
||||
@property(AudioClip)
|
||||
private backgroundMusic: AudioClip;
|
||||
|
||||
private _prePlayRate: number;
|
||||
private _backgroundSfx: SoundSource;
|
||||
|
||||
public readonly type: BoosterType = BoosterType.CumulativeBar;
|
||||
|
||||
|
@ -19,14 +26,48 @@ export class CumulativeBooster extends BoosterBase {
|
|||
|
||||
public async collect(collector: Node): Promise<void> {
|
||||
super.collect(collector);
|
||||
AudioManager.setPlayRateBGM(1.5);
|
||||
this._prePlayRate = AudioManager.bgmPlaybackRate;
|
||||
if (this.backgroundMusic) {
|
||||
AudioManager.playSfx(this.backgroundMusic, { loop: true, volume: 0 });
|
||||
this._backgroundSfx = AudioManager.findAudioSourcesSfx(this.backgroundMusic);
|
||||
}
|
||||
AudioManager.setPlayRateBGM(this.speedUpBgm);
|
||||
await this.animationHandler?.setAnimationAsync('active');
|
||||
this.animationHandler?.setNodeActive(false);
|
||||
}
|
||||
|
||||
public tick(dt: number): void {
|
||||
super.tick(dt);
|
||||
if (this.duration - this.timer <= 1) {
|
||||
if (AudioManager.bgmVolume < 1) {
|
||||
AudioManager.bgmVolume += dt * 2;
|
||||
if (AudioManager.bgmVolume > 1) {
|
||||
AudioManager.bgmVolume = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._backgroundSfx.volume > 0) {
|
||||
this._backgroundSfx.volume -= dt * 2;
|
||||
}
|
||||
} else {
|
||||
if (AudioManager.bgmVolume > 0) {
|
||||
AudioManager.bgmVolume -= dt * 0.5;
|
||||
}
|
||||
|
||||
if (this._backgroundSfx.volume < 1) {
|
||||
this._backgroundSfx.volume += dt * 2;
|
||||
if (this._backgroundSfx.volume > 1) {
|
||||
this._backgroundSfx.volume = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public end(): void {
|
||||
super.end();
|
||||
AudioManager.setPlayRateBGM(1);
|
||||
this._backgroundSfx?.stop();
|
||||
AudioManager.setPlayRateBGM(this._prePlayRate);
|
||||
AudioManager.bgmVolume = 1;
|
||||
}
|
||||
|
||||
async onGet(): Promise<void> {
|
||||
|
|
|
@ -132,7 +132,7 @@ export class CumulativeBar extends Component {
|
|||
case ScoreType.DestroyObject:
|
||||
if (!this._active) return;
|
||||
const star = this._floatingStartFactory.create(GameManager.instance.topContainer);
|
||||
star.node.setWorldPosition(position);
|
||||
star.node.setWorldPosition(position ? position : Vec3.ZERO);
|
||||
tween(star.node)
|
||||
.to(
|
||||
1,
|
||||
|
|
|
@ -339,6 +339,14 @@ AudioSource.prototype.getPlaybackRate = function () {
|
|||
|
||||
AudioSource.prototype.setPlaybackRate = function (value: number) {
|
||||
this._playbackRate = value;
|
||||
if (this._player) {
|
||||
try {
|
||||
this._player._player._sourceNode.playbackRate.value = value;
|
||||
} catch (e) {}
|
||||
this._playbackRate = value;
|
||||
} else {
|
||||
this._playbackRate = value;
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
|
|
|
@ -88,13 +88,29 @@ export class SoundSource {
|
|||
export default class AudioManager {
|
||||
private static readonly storageKey = 'gad-game-galaxy-seeker-mute';
|
||||
private static _audioSourcesSfx: Map<AudioClip, SoundSource> = new Map();
|
||||
private static _audioSourceBgm: SoundSource;
|
||||
private static _primaryAudioSourceBgm: SoundSource;
|
||||
private static _isMute: boolean = false;
|
||||
|
||||
public static get mute() {
|
||||
return this._isMute;
|
||||
}
|
||||
|
||||
public static get bgmPlaybackRate(): number {
|
||||
return this._primaryAudioSourceBgm.playbackRate;
|
||||
}
|
||||
|
||||
public static get bgmClip(): AudioClip {
|
||||
return this._primaryAudioSourceBgm.clip;
|
||||
}
|
||||
|
||||
public static get bgmVolume(): number {
|
||||
return this._primaryAudioSourceBgm.volume;
|
||||
}
|
||||
|
||||
public static set bgmVolume(value: number) {
|
||||
this._primaryAudioSourceBgm.volume = value;
|
||||
}
|
||||
|
||||
public static toggleMute(): boolean {
|
||||
this._isMute = !this._isMute;
|
||||
this.setMute(this._isMute);
|
||||
|
@ -102,7 +118,7 @@ export default class AudioManager {
|
|||
}
|
||||
|
||||
public static setMute(mute: boolean) {
|
||||
this._audioSourceBgm.mute = mute;
|
||||
this._primaryAudioSourceBgm.mute = mute;
|
||||
this._audioSourcesSfx.forEach((source) => {
|
||||
source.mute = mute;
|
||||
});
|
||||
|
@ -117,21 +133,21 @@ export default class AudioManager {
|
|||
playbackRate: 1,
|
||||
...opts,
|
||||
};
|
||||
if (this._audioSourceBgm) {
|
||||
this._audioSourceBgm.stop();
|
||||
this._audioSourceBgm.clip = audio;
|
||||
if (this._primaryAudioSourceBgm) {
|
||||
this._primaryAudioSourceBgm.stop();
|
||||
this._primaryAudioSourceBgm.clip = audio;
|
||||
} else {
|
||||
this._audioSourceBgm = new SoundSource(audio);
|
||||
this._primaryAudioSourceBgm = new SoundSource(audio);
|
||||
}
|
||||
this._audioSourceBgm.loop = config.loop;
|
||||
this._audioSourceBgm.volume = config.volume;
|
||||
this._audioSourceBgm.mute = this._isMute;
|
||||
this._audioSourceBgm.play();
|
||||
this._audioSourceBgm.playbackRate = config.playbackRate;
|
||||
this._primaryAudioSourceBgm.loop = config.loop;
|
||||
this._primaryAudioSourceBgm.volume = config.volume;
|
||||
this._primaryAudioSourceBgm.mute = this._isMute;
|
||||
this._primaryAudioSourceBgm.play();
|
||||
this._primaryAudioSourceBgm.playbackRate = config.playbackRate;
|
||||
}
|
||||
|
||||
public static setPlayRateBGM(rate: number) {
|
||||
this._audioSourceBgm.playbackRate = rate;
|
||||
this._primaryAudioSourceBgm.playbackRate = rate;
|
||||
}
|
||||
|
||||
public static playSfx(audioClip: AudioClip, opts?: ISoundOptions) {
|
||||
|
@ -160,7 +176,7 @@ export default class AudioManager {
|
|||
}
|
||||
|
||||
public static stopBgm() {
|
||||
this._audioSourceBgm.stop();
|
||||
this._primaryAudioSourceBgm.stop();
|
||||
}
|
||||
|
||||
public static stopSfx(audioClip: AudioClip) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "41ffc22c-cc16-4ac9-b9d7-4cc2a775a7bb",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "77ea2061-3c8b-4d5d-abc9-0d3c22f9316b",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "2b216677-9822-44f6-9ce6-39a0054afb5e",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "6cf3abb2-39ba-4429-89dc-e55c89109b58",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "b1cc499c-0470-4e1c-bc27-776d6b3a7589",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "1a6c406c-d5fa-4d17-a1b9-85aea90167f6",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "a5d745ea-77ac-45f7-9add-2d7cecf14588",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "e9447eed-f826-4415-ae20-d558cbdad5ba",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "c9c374b4-e722-4ae7-b158-2348a2131d39",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "bf2b43d1-2342-4f8e-b1f5-de818e510b27",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "4f0fe9f4-a46a-4921-9519-7f657c31fba0",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "9f162a5a-b9cf-4a00-844f-76d340443ca3",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "7fde9104-56e1-4720-9e56-17d2c1399d73",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "35743b89-bf0d-4cba-8424-7804a28eb7c2",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "e168bc33-68e5-4e1a-afc5-204ff6445d96",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "bdf9a0db-f93a-4185-aaab-65274b7f5736",
|
||||
"files": [
|
||||
".json",
|
||||
".mp3"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue