package Game {
	import flash.media.*;
	import flash.utils.*;
	
	public class GameSounds {
		public var sound_channel:SoundChannel;
		public var soundChannelBG:SoundChannel;
		public var soundChannelBG_weapon:SoundChannel;
		public var soundBG:Sound;
		public var hasWeapon:Boolean = false;
		public var energyFood_active:Boolean = false;
		
		public function GameSounds():void {
		}
		
		public function stopAll():void{
			if(sound_channel != null){
				sound_channel.stop();
			}
			
			if(soundChannelBG != null){
				soundChannelBG.stop();
			}
			
			if(soundChannelBG_weapon != null){
				soundChannelBG_weapon.stop();
			}
		}
		
		public function bgSound():void {
			soundBG 		= new sound_bg();
			soundChannelBG  = soundBG.play();
			setInterval(bgSoundPlay, 1);
		}
		
		public function bgSoundPlay():void {
			if(soundChannelBG.position >= soundBG.length-330)
				soundChannelBG = soundBG.play();
		}
		
		public function EnergyFood():void {
			energyFood_active = true;
			if(!hasWeapon) {
				soundChannelBG_weapon = new sound_getWeapon().play(0,25);
				hasWeapon = true;
			}
		}
		
		public function EnergyFoodEnds():void {
			if(energyFood_active) {
				hasWeapon = false;
				soundChannelBG_weapon.stop();
			}
		}
		
		public function simpleFood():void {
			sound_channel = new sound_getItems().play();
		}
		
		public function killCrab():void {
			sound_channel = new sound_killcrab().play();
		}
		
		public function pacmanDead():void {
			sound_channel = new sound_pacmanDead().play();
		}
		
		public function readyGo():void {
			sound_channel = new readygo().play();
		}
		
		public function gameOver():void {
			sound_channel = new sound_gameover().play();
		}
		
		public function youWin():void {
			sound_channel = new sound_win2().play();
		}
		
	}
}