Subversion Repositories AndroidProjects

Rev

Rev 576 | Rev 610 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.gebauz.PonPonChun.game;

import com.badlogic.gdx.audio.Sound;

/** Collects in game sounds and manages them. */
public class GameSounds extends GameLogicObject
{
        // Constants========================================================================================
       
        public static final int SFX_REGULAR_CLEAR = 0;
        public static final int SFX_COMBO_CLEAR = 1;
        public static final int SFX_CHAIN_CLEAR = 2;
        public static final int SFX_CLEAR_BREAK = 3;
        public static final int SFX_FALL = 4;
        public static final int SFX_SWAP = 5;
        public static final int SFX_CLICK = 6;
        public static final int SFX_GAMEOVER = 7;
        public static final int NUM_SFX = 8;

        // Embedded Types===================================================================================

        // Fields===========================================================================================
       
        private Sound mSounds[] = new Sound[NUM_SFX];
       
        // Methods==========================================================================================
        public GameSounds(GameLogic gameLogic)
        {
                super(gameLogic);
        }
       
        public void init()
        {
                mSounds[SFX_REGULAR_CLEAR] = getGameLogic().getGame().getAudio().newManagedSound("data/sounds/regular_clear.wav");
                mSounds[SFX_COMBO_CLEAR] = getGameLogic().getGame().getAudio().newManagedSound("data/sounds/super_clear.wav");
                mSounds[SFX_CHAIN_CLEAR] = getGameLogic().getGame().getAudio().newManagedSound("data/sounds/ultra_clear.wav");
                mSounds[SFX_CLEAR_BREAK] = getGameLogic().getGame().getAudio().newManagedSound("data/sounds/glass_break.wav");
                mSounds[SFX_FALL] = getGameLogic().getGame().getAudio().newManagedSound("data/sounds/block_fall.wav");
                mSounds[SFX_SWAP] = getGameLogic().getGame().getAudio().newManagedSound("data/sounds/swap.wav");
                mSounds[SFX_CLICK] = getGameLogic().getGame().getAudio().newManagedSound("data/sounds/click.wav");
                mSounds[SFX_GAMEOVER] = getGameLogic().getGame().getAudio().newManagedSound("data/sounds/game_over.wav");
        }
       
        public void exit()
        {
                for (int i = 0; i < mSounds.length; i++)
                {
                        getGameLogic().getGame().getAudio().removeManagedSound(mSounds[i]);
                        mSounds[i] = null;
                }
        }
       
        public void playSound(int i)
        {
                if (mSounds[i] != null)
                        mSounds[i].play();
        }

        // Getters/Setters==================================================================================

}