From c4eb8f98aa84acbdb996a60b0d79cb3ae160b31c Mon Sep 17 00:00:00 2001 From: js Date: Thu, 11 May 2023 20:58:21 +0800 Subject: [PATCH] feat: AudioManager --- .../{game_over.wav => game_game_over.wav} | Bin .../imshit/aircraftwar/logic/AudioManager.kt | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) rename app/src/main/assets/audio/{game_over.wav => game_game_over.wav} (100%) create mode 100644 app/src/main/java/net/imshit/aircraftwar/logic/AudioManager.kt diff --git a/app/src/main/assets/audio/game_over.wav b/app/src/main/assets/audio/game_game_over.wav similarity index 100% rename from app/src/main/assets/audio/game_over.wav rename to app/src/main/assets/audio/game_game_over.wav diff --git a/app/src/main/java/net/imshit/aircraftwar/logic/AudioManager.kt b/app/src/main/java/net/imshit/aircraftwar/logic/AudioManager.kt new file mode 100644 index 0000000..18b1103 --- /dev/null +++ b/app/src/main/java/net/imshit/aircraftwar/logic/AudioManager.kt @@ -0,0 +1,18 @@ +package net.imshit.aircraftwar.logic + +import android.content.Context +import android.content.res.AssetFileDescriptor + +class AudioManager(context: Context) { + private val getAfd: (String) -> AssetFileDescriptor = { fileName -> + context.assets.openFd("audio/$fileName") + } + + val bgmBoss = getAfd("game_bgm_boss.wav") + val bgmNormal = getAfd("game_bgm_normal.wav") + val bulletHit = getAfd("game_bullet_hit.wav") + val bulletShoot = getAfd("game_bullet_shoot.wav") + val explode = getAfd("game_explode.wav") + val gameOver = getAfd("game_game_over.wav") + val supplyGet = getAfd("game_supply_get.wav") +} \ No newline at end of file