package finale;

import java.util.ArrayList;

import finale.boss.Xyrux;

import util.MP3;
import world.GameObject;

public class GameMaster extends GameObject {
	
	private boolean hasWon;
	
	public GameMaster() {
		
	}
	
	private int time;
	private int beepTime;
	
	public void update() {
		
		float distance = (float) camera.getPosition().getMagnitude();
		
		beepTime = (int) ((distance / 25));
		
		if(beepTime > 100)
			beepTime = 100;
		
		if(beepTime < 1)
			beepTime = 1;
		
		time++;
		
		if(hasWon && time % beepTime == 0)
			new MP3("/audio/FX/Bell.mp3").play(1);
		
		if(hasWon && distance < 250) {
			
			triggeredGameState = "Level, Space";
			
			endScene();
		}
	}
	
	public void inspectScene(ArrayList<GameObject> objects) {
		
		if(!hasWon && time > 10000) {
			
			hasWon = true;
			
			for(int i = 0; i < objects.size(); i++)
				
				if(objects.get(i) instanceof Xyrux)
					hasWon = false;
		}
	}
}