package  
{
	import flash.geom.Point;
	import net.flashpunk.Entity;
	import net.flashpunk.graphics.Image;
	import net.flashpunk.FP;
	import net.flashpunk.utils.Draw;
	/**
	 * ...
	 * @author AntoineGuerchais
	 */
	public class Season2 extends Entity
	{
		[Embed(source = '../assets/graphics/BG/season_sping2.png')] 
	    private const SeasonSpring2:Class;
		[Embed(source = '../assets/graphics/BG/season_sum2.png')] 
		private const SeasonSummer2:Class;
		[Embed(source = '../assets/graphics/BG/season_aut2.png')] 
		private const SeasonAutomn2:Class;
		[Embed(source = '../assets/graphics/BG/season_wint2.png')] 
		private const SeasonWinter2:Class;
		
		private var baseSeason:Season;
		private var image2:Image;
		
		public function Season2(parent:Season) 
		{
			switch(parent.numSeason)
			{
				case 0 : 
					image2 = new Image(SeasonSpring2);
					break;
				case 1 : 
					image2 = new Image(SeasonSummer2); 
					break;
				case 2 : 
					image2 = new Image(SeasonAutomn2);
					visible = false;break;
				case 3 :
					image2 = new Image(SeasonWinter2);
					visible = false;break;
			}
			
			graphic = image2;
			x = FP.width / 2;
			y = FP.height;
			image2.originX = image2.width / 2;
			layer = 90;
			baseSeason = parent;
		}
		
		public override function update():void
		{
			
			FP.log("Angle" + ((baseSeason.image.angle)%360));
			if (!(FP.world as TreeWorld).paused)
			{
				image2.angle = baseSeason.image.angle * 2.0;//(baseSeason.image.angle+(180*(baseSeason.numSeason%2)))+baseSeason.image.angle ;
				visible = baseSeason.visible;// && (Math.abs(baseSeason.image.angle) % 360 > 180);
			}
			/*visible = false;
			 * 
			FP.log("Angle" + (image.angle%360));
			switch(numSeason)
			{
				case 0 : if ((year.time % 1.0) < (0.875) && (year.time % 1.0) > (0.375)) visible = false; break;
				case 1 : if ((year.time % 1.0) > (0.625) && (year.time % 1.0) < (0.125)) visible = false; break;
				case 2 : if ((year.time % 1.0) < (0.375) && (year.time % 1.0) > (0.875)) visible = false;break;
				case 3 : if ((year.time % 1.0) < (0.625) && (year.time % 1.0) > (0.125)) visible = false;break;
			}*/
			
		}
		
		public override function render():void
		{
			if((Math.abs(baseSeason.image.angle) % 360 >180))
			 super.render();
			if ((Math.abs(baseSeason.image.angle) % 360 >90) && (Math.abs(baseSeason.image.angle) % 360 < 270))
			{
				 image2.angle += 180;
				//Draw.graphic(image2);
				image2.render(FP.buffer,new Point(x,y), new Point(FP.camera.x,FP.camera.y));
				image2.angle-= 180;
			}
		}
	}

}