package boxs;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;

import personnage.Personnage;
import world.Combat;

public class WorldBoxs 
{
	public AmmoBoxs muni;
	public MitrailletteBoxs mitraillette;
	public ShieldBoxs armure;
	public HealthBoxs vie;
	int counterMuni = (int) (Math.random()*100), counterMitr = (int) (Math.random()*200), counterArmu = (int) (Math.random()*200), counterVie = (int) (Math.random()*300);
	public WorldBoxs() throws SlickException
	{
		muni = new AmmoBoxs();
		mitraillette = new MitrailletteBoxs();
		armure = new ShieldBoxs();
		vie = new HealthBoxs();
	}
	
	public void draw(Graphics g)
	{
		mitraillette.draw(g);
		muni.draw(g);
		vie.draw(g);
		armure.draw(g);
	}
	
	public void update()
	{
		 if(counterMuni >= 10*30)
		 {
			 muni.spawn(Combat.map);
			 counterMuni = (int) (Math.random()*100);
		 }
		 else
		 {
			 counterMuni++;
		 }
		 if(counterVie >= 30*30)
		 {
			 vie.spawn(Combat.map);
			 counterVie = (int) (Math.random()*200);
		 }
		 else
		 {
			 counterVie++;
		 }
		 if(counterArmu >= 40*30)
		 {
			 armure.spawn(Combat.map);
			 counterArmu = (int) (Math.random()*200);
		 }
		 else
		 {
			 counterArmu++;
		 }
		 if(counterMitr >= 50*30)
		 {
			 mitraillette.spawn(Combat.map);
			 counterMitr = (int) (Math.random()*300);
		 }
		 else
		 {
			 counterMitr++;
		 }
	}
	
	public void check(Personnage perso)
	{
		muni.check(perso);
		mitraillette.check(perso);
		armure.check(perso);
		vie.check(perso);
	}
}
