package
{
	import flash.events.Event;
	import flinjin.events.FlinjinEvent;
	import flinjin.Flinjin;
	import flinjin.graphics.PostEffects.BlackAndWhite;
	import flinjin.graphics.PostEffects.Blur;
	import flinjin.graphics.PostEffects.MotionBlur;
	import flinjin.graphics.Sprite;
	import flinjin.sound.FlinjinSound;
	import flinjin.sound.FlinjinSoundCollection;
	import game.GameMain.GameMain;
	import game.GameMenu.GameMenu;
	
	/**
	 * ...
	 * @author Michael Miriti <m.s.miriti@gmail.com>
	 */
	[Frame(factoryClass="Preloader")]
	
	public class Main extends Flinjin
	{
		public var sndMainTheme:FlinjinSound;
		
		[Embed(source="assets/sound/music/Main_Theme.mp3")]
		private static var _sndMainTheme:Class;
		
		[Embed(source="assets/sound/wood.mp3")]
		private static var _sndWood:Class;
		
		[Embed(source="assets/sound/mantis.mp3")]
		private static var _sndMantis:Class;
		
		[Embed(source="assets/sound/forest.mp3")]
		private static var _sndForest:Class;
		
		private var _gameMain:GameMain;
		private var _gameMenu:GameMenu;
		
		public function Main():void
		{
			super();
			Screen.setFillColor(0);
			addEventListener(FlinjinEvent.ENGINE_STARTUP, onEngineStartup);
		}
		
		public function gotoGame():void
		{
			_gameMain = new GameMain();
			_gameMain._main = this;
			
			Screen.MainLayer.deleteSprite(_gameMenu);
			addToMainLayer(_gameMain);
		}
		
		public function gotoMenu():void
		{
			_gameMenu = new GameMenu();
			_gameMenu._main = this;
			
			Screen.MainLayer.deleteSprite(_gameMain);
			addToMainLayer(_gameMenu);
		}
		
		private function onEngineStartup(e:FlinjinEvent):void
		{
			FlinjinSoundCollection.addSound(new _sndMainTheme(), 'main_theme');
			FlinjinSoundCollection.addSound(new _sndWood(), 'wood');
			FlinjinSoundCollection.addSound(new _sndMantis(), 'mantis');
			FlinjinSoundCollection.addSound(new _sndForest(), 'forest');
			
			sndMainTheme = FlinjinSoundCollection.playSound('main_theme');
			sndMainTheme.loop = true;
			
			Screen.MainLayer.setColorMults(1.5, 1.2, 0.7);
			
			_gameMenu = new GameMenu();
			_gameMenu._main = this;
			
			addToMainLayer(_gameMenu);
		}
	
	}

}