package com.ld58.game;

import java.util.Iterator;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;

import Global.Global;
import effects.Explosion;
import effects.FireParticle;
import effects.Fireworks;
import effects.School;
import effects.Torch;
import entities.Ball;
import entities.EvilShip;
import entities.PausePerson;
import entities.Player;
import entities.Student;
import levelElements.Bread;
import levelElements.Cafeteria;
import levelElements.Halo;
import levelElements.Portal;
import unearthables.Amethyst;
import unearthables.AmethystHUD;
import unearthables.Copper;
import unearthables.CopperHUD;
import unearthables.Diamond;
import unearthables.DiamondHUD;
import unearthables.Food;
import unearthables.Gold;
import unearthables.GoldHUD;
import unearthables.Platinum;
import unearthables.PlatinumHUD;
import unearthables.Ruby;
import unearthables.RubyHUD;
import unearthables.Sapphire;
import unearthables.SapphireHUD;
import unearthables.Silver;
import unearthables.SilverHUD;
import unearthables.Topaz;
import unearthables.TopazHUD;
import unearthables.UnearthAmethyst;
import unearthables.UnearthCopper;
import unearthables.UnearthDiamond;
import unearthables.UnearthGold;
import unearthables.UnearthPlatinum;
import unearthables.UnearthRubies;
import unearthables.UnearthSapphire;
import unearthables.UnearthSilver;
import unearthables.UnearthTopaz;

public class LevelMinusThree implements Screen {
	final rcr game;

	private Music levelMusic;
	private OrthographicCamera camera;
	private Viewport vport;
	private Player player;
//	private Player2 player2;
//	private Player3 player3;
//	private Player4 player4;
//	private Player5 player5;
//	private Player6 player6;
	int currentFrame = 1;
	int MAX_FRAMES = 5;

	public int sw = rcr.MW;// was 1440;
	public int sh = rcr.MH;// 720

	private Array<EvilShip> evilShips;

	// private Vector3 mousePos;
	private PausePerson pp;
	// private DeliveryTruck deliveryTruck;
	private Sound enter;
	private Sound enter2;
	private Sound death;
	private int isDeadTimer = 40;
	private boolean isEverythingLoaded;
	private String whatIsLoading = "";
	private int delayTimer;
	private int DTSpd = 2;// was 5
	private boolean isLevelAdded;
	private boolean isPlayerAdded;
	private Sound reverseSlide;
	private Sound click;
	private Sound click2;
	private Sound click3;
	private Sound click4;
	private Sound click5;
	private Sound click6;
	private Sound click7;
	private Sound boom;
	private boolean evilShipLoop;
	private boolean isEvilShipsAdded;
	private Torch torch;
	public Array<FireParticle> fireParticles;
	private School school;
	private Array<Student> students;
	private UnearthRubies rubies;
	private Array<Ruby> rubyGems;
	private UnearthSapphire sapphires;
	private Array<Sapphire> sapphireGems;
	private UnearthAmethyst amethysts;
	private Array<Amethyst> amethystGems;
	private UnearthCopper coppers;
	private Array<Copper> copperMetals;
	private UnearthDiamond diamonds;
	private Array<Diamond> diamondGems;
	private Array<Food> foodHealth;
	private UnearthGold golds;
	private Array<Gold> goldMetals;
	private UnearthPlatinum platinums;
	private Array<Platinum> platinumMetals;
	private UnearthSilver silvers;
	private Array<Silver> silverMetals;
	private UnearthTopaz topazs;
	private Array<Topaz> topazGems;
	private int cameraShakeTimer;
	private float cameraInitX;
	private float cameraInitY;
	private boolean isCameraPositionInitialized;
	private boolean onetime;
	private boolean playSoundOnce;
	private boolean onlyGoThroughLevelEndOnce;
	private AmethystHUD amethystHUD;
	private CopperHUD copperHUD;
	private DiamondHUD diamondHUD;
	private GoldHUD goldHUD;
	private PlatinumHUD platinumHUD;
	private RubyHUD rubyHUD;
	private SapphireHUD sapphireHUD;
	private SilverHUD silverHUD;
	private TopazHUD topazHUD;
	private Fireworks fireworks;
	private Array<Explosion> explosions;
	private Cafeteria cafeteria;
	private Bread bread;
	private Halo halo;
	private Portal portal;
	private boolean isIntroMessageOver;
	private int introMessageTimer = 600;

	private boolean playOnlyOneTime;

	public LevelMinusThree(final rcr game) {
		this.game = game;
		// camera
		camera = new OrthographicCamera();
		vport = new FitViewport(sw, sh, camera);
		System.out.println("trying to create all the things!");
		// sounds
		// music
		levelMusic = Gdx.audio.newMusic(Gdx.files.internal("sfx/rcrGameMusic.ogg"));
		levelMusic.setLooping(true);
		levelMusic.setVolume(1f);
		camera.position.set(vport.getWorldWidth() / 2, vport.getWorldHeight() / 2, 0);
		// sfx
		reverseSlide = Gdx.audio.newSound(Gdx.files.internal("sfx/reverseSlide.ogg"));// death?
		death = Gdx.audio.newSound(Gdx.files.internal("sfx/death.ogg"));// death?
		click = Gdx.audio.newSound(Gdx.files.internal("sfx/click.ogg"));
		click2 = Gdx.audio.newSound(Gdx.files.internal("sfx/click2.ogg"));
		click3 = Gdx.audio.newSound(Gdx.files.internal("sfx/click3.ogg"));
		click4 = Gdx.audio.newSound(Gdx.files.internal("sfx/click4.ogg"));
		click5 = Gdx.audio.newSound(Gdx.files.internal("sfx/click5.ogg"));
		click6 = Gdx.audio.newSound(Gdx.files.internal("sfx/click6.ogg"));
		click7 = Gdx.audio.newSound(Gdx.files.internal("sfx/click7.ogg"));
		boom = Gdx.audio.newSound(Gdx.files.internal("sfx/boom.ogg"));
		// add pause person. This is added to every screen in the game you want a pause menu.
		pp = new PausePerson(Gdx.graphics.getWidth() / 2 - 210, Gdx.graphics.getHeight() - 235f);
		enter = Gdx.audio.newSound(Gdx.files.internal("sfx/click7.ogg"));
		enter2 = Gdx.audio.newSound(Gdx.files.internal("sfx/click8.ogg"));
		// add an empty array to fill as the game goes on. ;-)
//		peoples = new Array<Person>();
//		plants = new Array<Plant>();
//		workers = new Array<Worker>();
		evilShips = new Array<EvilShip>();
//		balls = new Array<Ball>();
		if (rcr.ArriveTimer < 1000)
			rcr.ArriveTimer += 2000;
		fireParticles = new Array<FireParticle>();
		torch = new Torch();
		// gems and metals
		rubies = new UnearthRubies();
		rubyGems = new Array<Ruby>();
		amethysts = new UnearthAmethyst();
		amethystGems = new Array<Amethyst>();
		sapphires = new UnearthSapphire();
		sapphireGems = new Array<Sapphire>();
		coppers = new UnearthCopper();
		copperMetals = new Array<Copper>();
		diamonds = new UnearthDiamond();
		diamondGems = new Array<Diamond>();
		foodHealth = new Array<Food>();
		golds = new UnearthGold();
		goldMetals = new Array<Gold>();
		platinums = new UnearthPlatinum();
		platinumMetals = new Array<Platinum>();
		silvers = new UnearthSilver();
		silverMetals = new Array<Silver>();
		topazs = new UnearthTopaz();
		topazGems = new Array<Topaz>();
		// gem/metal HUD stuff
		amethystHUD = new AmethystHUD(0, 0);
		copperHUD = new CopperHUD(0, 0);
		diamondHUD = new DiamondHUD(0, 0);
		goldHUD = new GoldHUD(0, 0);
		platinumHUD = new PlatinumHUD(0, 0);
		rubyHUD = new RubyHUD(0, 0);
		sapphireHUD = new SapphireHUD(0, 0);
		silverHUD = new SilverHUD(0, 0);
		topazHUD = new TopazHUD(0, 0);
		// explosions
		fireworks = new Fireworks();
		explosions = new Array<Explosion>();
		// level stuff
		school = new School();
		students = new Array<Student>();
		cafeteria = new Cafeteria(0, 0);
		bread = new Bread(1000, 700);
		halo = new Halo(975, 700);
		portal = new Portal(10, MathUtils.random(16, rcr.MH - 50));
		cameraInitX = camera.position.x;
		cameraInitY = camera.position.y;
	}

	public void update(float dt) {
		// now it's not tied to the players death. Just set the cameraShakeTimer;
		if (cameraShakeTimer > 0) {
			u.UsefulMethods.MoveCameraAroundRandomly(camera, 1, 4);
			camera.update();
			cameraShakeTimer -= 1;
		} else {
			camera.position.x = cameraInitX;
			camera.position.y = cameraInitY;
		}
	}

	@Override
	public void show() {
		Gdx.input.setInputProcessor(new InputAdapter() {
			@Override
			public boolean keyDown(int keyCode) {
				if (keyCode == Input.Keys.ESCAPE && !Global.IsPaused) {
					if (!Global.SetVolumeToZero)
						enter.play(2f);
					Global.IsPaused = true;
				} else if (keyCode == Input.Keys.ESCAPE && Global.IsPaused && Global.IsKeyBindings && Global.IsSetKey) {
					if (!Global.SetVolumeToZero)
						enter2.play(2f);
					Global.IsSetKey = false;
				} else if (keyCode == Input.Keys.ESCAPE && Global.IsPaused && Global.IsKeyBindings) {
					if (!Global.SetVolumeToZero)
						enter2.play(2f);
					Global.IsKeyBindings = false;
					pp.IsSwitchingToKeyBindings = true;
				} else if (keyCode == Input.Keys.ESCAPE && Global.IsPaused) {
					if (!Global.SetVolumeToZero)
						enter2.play(2f);
					Global.IsPaused = false;
				}
				if (Global.IsSetKey)
					Global.KeycodeSet = keyCode;
				return true;
			}

			@Override
			public boolean touchDown(int x, int y, int pointer, int button) {// this is for capturing mouse clicks
				if (Global.IsSetKey && Global.IsPaused)
					Global.KeycodeSet = button;
				return true;
			}

		});
	}

	@Override
	public void render(float delta) {
		// bind the fbo (lighting)
		// fbo.begin();
		Gdx.gl.glClearColor(0f, 0f, 0f, 0f);// lighting
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		// this is going to be my background, depending on what scene or area you are in. Trust me, this is intentional.
		ScreenUtils.clear(.05f, .02f, .01f, 1);// Brown (is this going to get in the way?)
		// ScreenUtils.clear(.2f, .5f, .2f, 1);// green.
		game.batch.setProjectionMatrix(camera.combined);
		if (!isCameraPositionInitialized) {
			cameraInitX = Gdx.graphics.getWidth() * .5f;
			cameraInitY = Gdx.graphics.getHeight() * .5f;
			isCameraPositionInitialized = true;
		}
		game.batch.begin();// start the batch. (should be already clear...)
		// System.out.println("game batch begin has been called. " + game.batch + " see? ");
		if (Global.IsPaused) {
			ScreenUtils.clear(0, 0, 0, 1);// black
			camera.position.x = Gdx.graphics.getWidth() * .5f;
			camera.position.y = Gdx.graphics.getHeight() * .5f;
			camera.update();
			// System.out.println("cameraX: " + camera.position.x + " cameraY: " + camera.position.y);
			pp.RenderEntirePauseMenu(delta, game, game.font, levelMusic, camera);
			// DebugRenderer.DrawDebugRectangle(pp.playerSelectLeftRect, Color.RED, camera.combined);// if you want to use this, don't forget to comment out some
			// code in the main render loop below...
		} else {
			// System.out.println("this should run before level.render");
			if (!isEverythingLoaded) {
				// lets load everything in pieces, while it's loading everything lets render stuff to the screen that represents the load state.
				game.font.setColor(Color.GRAY);
				game.font.draw(game.batch, whatIsLoading, camera.position.x - rcr.MW / 2 + 420, camera.position.y + rcr.MH / 2 - 247);// shadow
				game.font.setColor(Color.DARK_GRAY);
				game.font.draw(game.batch, whatIsLoading, camera.position.x - rcr.MW / 2 + 418, camera.position.y + rcr.MH / 2 - 245);
				if (!isLevelAdded && delayTimer <= 0) {
					System.out.println("doing the level");
					System.out.println("the floor should already be invisible at this point. Don't think about it.");
					whatIsLoading = "Loading: there is aboslutely something here. Lets find out what it is";
					for (int x = 0; x < 100; x++) {// trying 5 of them.
						FireParticle firep = torch.obtain();
						firep.rect.x = Global.P.x;
						firep.rect.y = Global.P.y;
						fireParticles.add(firep);
					}
//					System.out.println("I've decided rubies shall be here again");
//					for (int x = 0; x < MathUtils.random(5, 10); x++) {// trying 5 of them.
//						Ruby ruby = rubies.obtain();
//						ruby.rect.x = MathUtils.random(16f, rcr.MW - 16);
//						ruby.rect.y = MathUtils.random(16f, rcr.MH - 16);
//						rubyGems.add(ruby);
//					}
//					System.out.println("can't get enough gems. Haul some more in. purplish color would be nice.");
//					for (int x = 0; x < MathUtils.random(10, 20); x++) {// trying 5 of them.
//						Amethyst amethyst = amethysts.obtain();
//						amethyst.rect.x = MathUtils.random(16f, rcr.MW - 16);
//						amethyst.rect.y = MathUtils.random(16f, rcr.MH - 16);
//						amethystGems.add(amethyst);
//					}
//					System.out.println("make more blue gems.");
//					for (int x = 0; x < MathUtils.random(10, 15); x++) {// trying 5 of them.
//						Sapphire sapphire = sapphires.obtain();
//						sapphire.rect.x = MathUtils.random(16f, rcr.MW - 16);
//						sapphire.rect.y = MathUtils.random(16f, rcr.MH - 16);
//						sapphireGems.add(sapphire);
//					}
					System.out.println("There will be copper.");
					for (int x = 0; x < MathUtils.random(10, 30); x++) {// trying 5 of them.
						Copper copper = coppers.obtain();
						copper.rect.x = MathUtils.random(16f, rcr.MW - 16);
						copper.rect.y = MathUtils.random(16f, rcr.MH - 16);
						copperMetals.add(copper);
					}
//					System.out.println("ching ching ching! Dimaonds are not my best friend, but maybe yours?");
//					for (int x = 0; x < MathUtils.random(1, 5); x++) {// trying 5 of them.
//						Diamond diamond = diamonds.obtain();
//						diamond.rect.x = MathUtils.random(16f, rcr.MW - 16);
//						diamond.rect.y = MathUtils.random(16f, rcr.MH - 16);
//						diamondGems.add(diamond);
//					}
//					System.out.println("food gives health, man, i wish I knew someone to code this into the game ;-)");
//					for (int x = 0; x < MathUtils.random(10, 20); x++) {// trying 5 of them.
//						Food food = foods.obtain();
//						food.rect.x = MathUtils.random(16f, rcr.MW - 16);
//						food.rect.y = MathUtils.random(16f, rcr.MH - 16);
//						foodHealth.add(food);
//					}
//					System.out.println("do more gold. For better purchasing power?");
//					for (int x = 0; x < MathUtils.random(2, 8); x++) {// trying 5 of them.
//						Gold gold = golds.obtain();
//						gold.rect.x = MathUtils.random(16f, rcr.MW - 16);
//						gold.rect.y = MathUtils.random(16f, rcr.MH - 16);
//						goldMetals.add(gold);
//					}
//					System.out.println("like anyone will ever get to the platinum");
//					for (int x = 0; x < MathUtils.random(1, 2); x++) {// trying 5 of them.
//						Platinum platinum = platinums.obtain();
//						platinum.rect.x = MathUtils.random(16f, rcr.MW - 16);
//						platinum.rect.y = MathUtils.random(16f, rcr.MH - 16);
//						platinumMetals.add(platinum);
//					}
//					System.out.println("free silver");
//					for (int x = 0; x < MathUtils.random(10, 20); x++) {// trying 5 of them.
//						Silver silver = silvers.obtain();
//						silver.rect.x = MathUtils.random(16f, rcr.MW - 16);
//						silver.rect.y = MathUtils.random(16f, rcr.MH - 16);
//						silverMetals.add(silver);
//					}
//					System.out.println("why are you doing this. You're not terraria dude.");
//					for (int x = 0; x < MathUtils.random(10, 25); x++) {// trying 5 of them.
//						Topaz topaz = topazs.obtain();
//						topaz.rect.x = MathUtils.random(16f, rcr.MW - 16);
//						topaz.rect.y = MathUtils.random(16f, rcr.MH - 16);
//						topazGems.add(topaz);
//					}
					System.out.println("everyone needs explosions make like 500 of them right of the bat and confuse everyone");
					for (int x = 0; x < 5; x++) {// doing 5 of them. this really works! xD yay ( i think) xD
						Explosion explosion = fireworks.obtain();
						explosion.rect.x = MathUtils.random(16f, rcr.MW - 16);
						explosion.rect.y = MathUtils.random(16f, rcr.MH - 16);
						explosions.add(explosion);
					}
					System.out.println("onto the campus we go. yeah, it's getting intense. There are STUDENTS here. be educated.");
					for (int x = 0; x < 1; x++) {// trying 5 of them. was 100
						Student student = school.obtain();
						student.rect.x = 0;
						student.rect.y = MathUtils.random(0, rcr.MH);
						students.add(student);
					}
					System.out.println("your school is full. run away. before it's too late.");
					isLevelAdded = true;
					delayTimer = DTSpd;
				} else if (!isPlayerAdded && delayTimer <= 0) {
					System.out.println("doing the Player(s)");
					whatIsLoading = "Loading: Constructing player";
					player = new Player(0, MathUtils.random(0, rcr.MH));// one of the students
//					player2 = new Player2(rcr.MW / 4 - 20, rcr.MH / 2 - 20);// to the left of center!
//					player3 = new Player3(rcr.MW / 4 - 40, rcr.MH / 2 - 20);// to the left of center!
//					player4 = new Player4(rcr.MW / 4 - 60, rcr.MH / 2 + 20);// to the left of center!
//					player5 = new Player5(rcr.MW / 4 - 50, rcr.MH / 2 + 30);// to the left of center!
//					player6 = new Player6(rcr.MW / 4 + 20, rcr.MH / 2 - 10);// to the left of center!
					delayTimer = DTSpd;
					isPlayerAdded = true;
					evilShipLoop = true;
				} else if (!isEvilShipsAdded && delayTimer <= 0) {
					System.out.println("doing the evil mom?");
					if (evilShipLoop && delayTimer <= 0) {
						whatIsLoading = "Loading: something evil this way comes";
						System.out.println("ppssttt i'm not adding this. It's minus three there's no way.");
						evilShips = new Array<EvilShip>();
						for (int x = 0; x < 1; x++) {// was 500 yeah, and now it's ONE haha (going to be fun with lots)
							// evilShips.add(new EvilShip(MathUtils.random(1650, 1750), MathUtils.random(42, 814)));
							if (x + 1 == 1) {// end of loop
								isEvilShipsAdded = true;
								delayTimer = DTSpd;
							}
						}
						isEvilShipsAdded = true;
					}
				}
				if (isEvilShipsAdded && delayTimer <= 0) {
					System.out.println("now everything is done! go go go go!");
					isEverythingLoaded = true;
				}
				if (delayTimer > 0)
					delayTimer--;
				game.batch.end();
				// fbo.end();
			} else if (!isIntroMessageOver) {
				// cafeteria.render(game, camera, delta);

				game.font.getData().setScale(1f);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "Welcome to level minus three!", Gdx.graphics.getWidth() / 2 - 300, rcr.MH - 320);// shadow
				game.font.setColor(Color.BROWN);// set color before you draw
				game.font.draw(game.batch, "Welcome to level minus three!", Gdx.graphics.getWidth() / 2 - 300, rcr.MH - 322);

				game.font.setColor(Color.RED);
				game.font.draw(game.batch, "Get that BREAD and get to the PORTAL", rcr.MW / 2 - 450, rcr.MH - 416);// shadows
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "Get that BREAD and get to the PORTAL", rcr.MW / 2 - 450, rcr.MH - 415);
				game.font.setColor(Color.BLACK);

				game.font.setColor(Color.GREEN);
				game.font.draw(game.batch, "Message Will Vanish in: " + introMessageTimer + " units", rcr.MW / 2 - 450, rcr.MH - 616);// shadows
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "Message Will Vanish in: " + introMessageTimer + " units", rcr.MW / 2 - 450, rcr.MH - 615);
				game.font.setColor(Color.BLACK);

				game.font.setColor(Color.CYAN);
				game.font.draw(game.batch, "click left mouse to skip... --> this: " + introMessageTimer + " units", rcr.MW / 2 - 350, rcr.MH - 816);// shadows
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "click left mouse to skip... --> this: " + introMessageTimer + " units", rcr.MW / 2 - 350, rcr.MH - 815);
				game.font.setColor(Color.BLACK);
				// UI
				game.font.getData().setScale(1f);
				game.batch.end();
				if (Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && !Global.IsPaused && !isIntroMessageOver) {// basically you are outside of the menus
					// isIntroMessageOver = true;// skip the intro
					introMessageTimer = 0;// skip the intro
					System.out.println("this is clicking, right? :O");
				}
				if (introMessageTimer > 0)
					introMessageTimer--;
				if (introMessageTimer <= 0)
					isIntroMessageOver = true;

			} else {
				// draw level
				cafeteria.render(game, camera, delta);
				bread.render(game, camera, delta, students);
				if (bread.isCarriedByPlayer) {
					portal.render(game, camera, delta);
				} else {
					halo.render(game, camera, delta, bread);
				}
				// now evil ships?!
//				if (evilShips.size <= 0)
//					storeIcon.render(game, camera, delta);
				// draw students
				for (int dc = 0; dc < students.size; dc++) {
					if (!students.get(dc).isDead) {
						// student healthbar
						game.batch.setColor(students.get(dc).healthBar.color);
						students.get(dc).healthBar.render(game, camera, delta, students.get(dc).rect.x + 10f, students.get(dc).rect.y - 50f, students.get(dc).health,
								students.get(dc).healthMax);
						game.batch.setColor(students.get(dc).color);
						students.get(dc).render(game, camera, delta, amethystGems, copperMetals, diamondGems, foodHealth, goldMetals, platinumMetals, rubyGems,
								sapphireGems, silverMetals, topazGems, bread);
					}
				}
				// draw gems and metals
				for (int d = 0; d < rubyGems.size; d++) {
					if (!rubyGems.get(d).isDead) {
						rubyGems.get(d).render(game, camera, delta, students);
					}
				}
				for (int d = 0; d < amethystGems.size; d++) {
					if (!amethystGems.get(d).isDead) {
						amethystGems.get(d).render(game, camera, delta, students);
					}
				}
				for (int d = 0; d < sapphireGems.size; d++) {
					if (!sapphireGems.get(d).isDead) {
						sapphireGems.get(d).render(game, camera, delta, students);
					}
				}
				for (int d = 0; d < copperMetals.size; d++) {
					if (!copperMetals.get(d).isDead) {
						copperMetals.get(d).render(game, camera, delta, students);
					}
				}
				for (int d = 0; d < diamondGems.size; d++) {
					if (!diamondGems.get(d).isDead) {
						diamondGems.get(d).render(game, camera, delta, students);
					}
				}
				for (int d = 0; d < foodHealth.size; d++) {
					if (!foodHealth.get(d).isDead) {
						foodHealth.get(d).render(game, camera, delta, students);
					}
				}
				for (int d = 0; d < goldMetals.size; d++) {
					if (!goldMetals.get(d).isDead) {
						goldMetals.get(d).render(game, camera, delta, students);
					}
				}
				for (int d = 0; d < platinumMetals.size; d++) {
					if (!platinumMetals.get(d).isDead) {
						platinumMetals.get(d).render(game, camera, delta, students);
					}
				}
				for (int d = 0; d < silverMetals.size; d++) {
					if (!silverMetals.get(d).isDead) {
						silverMetals.get(d).render(game, camera, delta, students);
					}
				}
				for (int d = 0; d < topazGems.size; d++) {
					if (!topazGems.get(d).isDead) {
						topazGems.get(d).render(game, camera, delta, students);
					}
				}
				// draw player
				game.batch.setColor(player.color);// set color before you draw
				// DebugRenderer.DrawDebugRectangle(player.rect, Color.RED, camera.combined);// there were a lot more of these heheeh
				// pos23 = camera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0));
				game.batch.draw(player.getFrame(delta, camera), player.rect.x - 15, player.rect.y - 4);// this must be the offset
//				// draw player2
//				game.batch.setColor(player2.color);
//				game.batch.draw(player2.getFrame(delta, camera), player2.rect.x - 24, player2.rect.y - 4);
//				// draw player3
//				game.batch.setColor(player3.color);
//				game.batch.draw(player3.getFrame(delta, camera), player3.rect.x - 24, player3.rect.y - 4);
//				// draw player4
//				game.batch.setColor(player4.color);
//				game.batch.draw(player4.getFrame(delta, camera), player4.rect.x - 24, player4.rect.y - 4);
//				// draw player5
//				game.batch.setColor(player5.color);
//				game.batch.draw(player5.getFrame(delta, camera), player5.rect.x - 24, player5.rect.y - 4);
//				// draw player6
//				game.batch.setColor(player6.color);
//				game.batch.draw(player6.getFrame(delta, camera), player6.rect.x - 24, player6.rect.y - 4);
				// p1 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P1", player.rect.x, player.rect.y - 1);// shadow
//				game.font.setColor(Color.ORANGE);// set color before you draw
//				game.font.draw(game.batch, "P1", player.rect.x, player.rect.y);
//				game.font.getData().setScale(1f);
//				// p2 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P2", player2.rect.x, player2.rect.y - 1);// shadow
//				game.font.setColor(Color.BLUE);// set color before you draw
//				game.font.draw(game.batch, "P2", player2.rect.x, player2.rect.y);
//				game.font.getData().setScale(1f);
//				// p3 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P3", player3.rect.x, player3.rect.y - 1);// shadow
//				game.font.setColor(Color.PURPLE);// set color before you draw
//				game.font.draw(game.batch, "P3", player3.rect.x, player3.rect.y);
//				game.font.getData().setScale(1f);
//				// p4 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P4", player4.rect.x, player4.rect.y - 1);// shadow
//				game.font.setColor(Color.GREEN);// set color before you draw
//				game.font.draw(game.batch, "P4", player4.rect.x, player4.rect.y);
//				game.font.getData().setScale(1f);
//				// p5 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P5", player5.rect.x, player5.rect.y - 1);// shadow
//				game.font.setColor(Color.RED);// set color before you draw
//				game.font.draw(game.batch, "P5", player5.rect.x, player5.rect.y);
//				game.font.getData().setScale(1f);
//				// p6 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P6", player6.rect.x, player6.rect.y - 1);// shadow
//				game.font.setColor(Color.TEAL);// set color before you draw
//				game.font.draw(game.batch, "P6", player6.rect.x, player6.rect.y);
				game.font.getData().setScale(1f);
				// draw the evilShips healthbars and all
				for (int d = 0; d < evilShips.size; d++) {
					if (!evilShips.get(d).isDead) {
						// render the enemy ships (ships first)
						game.batch.setColor(evilShips.get(d).color);
						// DebugRenderer.DrawDebugRectangle(evilShips.get(d).rect, Color.YELLOW, camera.combined);
						evilShips.get(d).render(game, camera, delta, amethystGems, copperMetals, diamondGems, foodHealth, goldMetals, platinumMetals, rubyGems,
								sapphireGems, silverMetals, topazGems);
						// evil ship healthbar
						game.batch.setColor(evilShips.get(d).healthBar.color);
						evilShips.get(d).healthBar.render(game, camera, delta, evilShips.get(d).rect.x + 10f, evilShips.get(d).rect.y - 50f, evilShips.get(d).health,
								evilShips.get(d).healthMax);
						// evil ship enemy gun healthbar
						game.batch.setColor(evilShips.get(d).enemyGun.healthBar.color);
						evilShips.get(d).enemyGun.healthBar.render(game, camera, delta, evilShips.get(d).enemyGun.rect.x + 10f,
								evilShips.get(d).enemyGun.rect.y - 50f, evilShips.get(d).enemyGun.health, evilShips.get(d).enemyGun.healthMax);
						// render the enemy gun
						evilShips.get(d).enemyGun.render(game, camera, delta, player);
						// render the enemy ship's enemy gun's balls, and those ball's explosions.
						for (int eg = 0; eg < evilShips.get(d).enemyGun.balls.size; eg++) {
							if (!evilShips.get(d).enemyGun.balls.get(eg).isDead) {
								game.batch.setColor(evilShips.get(d).enemyGun.balls.get(eg).color);
								game.batch.draw(evilShips.get(d).enemyGun.balls.get(eg).getFrame(camera, delta), evilShips.get(d).enemyGun.balls.get(eg).rect.x,
										evilShips.get(d).enemyGun.balls.get(eg).rect.y);
							} else if (!evilShips.get(d).enemyGun.balls.get(eg).explosion.isDead) {
								game.batch.setColor(evilShips.get(d).enemyGun.balls.get(eg).explosion.getColor());
								game.batch.draw(evilShips.get(d).enemyGun.balls.get(eg).explosion.getFrame(camera, delta),
										evilShips.get(d).enemyGun.balls.get(eg).explosion.rect.x, evilShips.get(d).enemyGun.balls.get(eg).explosion.rect.y);
							}
						}
					}
				}

				// player.powerBar.render(game, camera, delta, player.rect, player.powerBarNumber, player.powerBarMax);
				// draw player 1 balls
				for (int d = 0; d < player.balls.size; d++) {
					if (!player.balls.get(d).isDead) {
						// game.font.draw(game.batch, "" + player.balls.size, player.rect.x, player.rect.y);
						game.batch.setColor(player.balls.get(d).color);
						game.batch.draw(player.balls.get(d).getFrame(camera, delta), player.balls.get(d).rect.x, player.balls.get(d).rect.y);
					} else if (!player.balls.get(d).explosion.isDead) {
						game.batch.setColor(player.balls.get(d).explosion.getColor());
						game.batch.draw(player.balls.get(d).explosion.getFrame(camera, delta), player.balls.get(d).explosion.rect.x,
								player.balls.get(d).explosion.rect.y);
					}
				}
				// draw explosions?
				for (int d = 0; d < explosions.size; d++) {
					if (!explosions.get(d).isDead) {
						explosions.get(d).render(game, camera, delta);
					}
				}
				// player healthbar
				game.batch.setColor(player.healthBar.color);
				player.healthBar.render(game, camera, delta, player.rect.x, player.rect.y - 50f, Player.health, Player.healthMax);
//				player.powerBar.render(game, camera, delta, player.rect, player.powerBarNumber, player.powerBarMax);
//				// player 2 healthbars
//				game.batch.setColor(player2.healthBar.color);
//				player2.healthBar.render(game, camera, delta, player2.rect, Player2.health, Player2.healthMax);
//				player2.powerBar.render(game, camera, delta, player2.rect, player2.powerBarNumber, player2.powerBarMax);
//				// player 3 healthbars
//				game.batch.setColor(player3.healthBar.color);
//				player3.healthBar.render(game, camera, delta, player3.rect, Player3.health, Player3.healthMax);
//				player3.powerBar.render(game, camera, delta, player3.rect, player3.powerBarNumber, player3.powerBarMax);
//				// player 4 healthbars
//				game.batch.setColor(player4.healthBar.color);
//				player4.healthBar.render(game, camera, delta, player4.rect, Player4.health, Player4.healthMax);
//				player4.powerBar.render(game, camera, delta, player4.rect, player4.powerBarNumber, player4.powerBarMax);
//				// player 5 healthbars
//				game.batch.setColor(player5.healthBar.color);
//				player5.healthBar.render(game, camera, delta, player5.rect, Player5.health, Player5.healthMax);
//				player5.powerBar.render(game, camera, delta, player5.rect, player5.powerBarNumber, player5.powerBarMax);
//				// player 6 healthbars
//				game.batch.setColor(player6.healthBar.color);
//				player6.healthBar.render(game, camera, delta, player6.rect, Player6.health, Player6.healthMax);
//				player6.powerBar.render(game, camera, delta, player6.rect, player6.powerBarNumber, player6.powerBarMax);
				// icons:
				game.font.setColor(Color.WHITE);// set color before you draw
				game.batch.setColor(Color.WHITE);// reset batch color
				// draw gem/metal hud
				game.font.getData().setScale(.7f);
				if (Global.p1AmethystStockpile > 0) {
					amethystHUD.render(game, camera, delta, player.rect.x, player.rect.y - 25f);
					game.font.setColor(Color.PURPLE);
					game.font.draw(game.batch, "" + Global.p1AmethystStockpile, player.rect.x + 34f, player.rect.y - 14f);// shadow
					game.font.setColor(Color.WHITE);
					game.font.draw(game.batch, "" + Global.p1AmethystStockpile, player.rect.x + 33f, player.rect.y - 13f);
				}
				if (Global.p1TopazStockpile > 0) {
					topazHUD.render(game, camera, delta, player.rect.x, player.rect.y - 45f);
					game.font.setColor(Color.GOLD);
					game.font.draw(game.batch, "" + Global.p1TopazStockpile, player.rect.x + 34f, player.rect.y - 34f);// shadow
					game.font.setColor(Color.WHITE);
					game.font.draw(game.batch, "" + Global.p1TopazStockpile, player.rect.x + 33f, player.rect.y - 33f);
				}
				if (Global.p1SapphireStockpile > 0) {
					sapphireHUD.render(game, camera, delta, player.rect.x, player.rect.y - 65f);
					game.font.setColor(Color.BLUE);
					game.font.draw(game.batch, "" + Global.p1SapphireStockpile, player.rect.x + 34f, player.rect.y - 54f);// shadow
					game.font.setColor(Color.WHITE);
					game.font.draw(game.batch, "" + Global.p1SapphireStockpile, player.rect.x + 33f, player.rect.y - 53f);
				}
				if (Global.p1RubyStockpile > 0) {
					rubyHUD.render(game, camera, delta, player.rect.x, player.rect.y - 85f);
					game.font.setColor(Color.RED);
					game.font.draw(game.batch, "" + Global.p1RubyStockpile, player.rect.x + 34f, player.rect.y - 74f);// shadow
					game.font.setColor(Color.WHITE);
					game.font.draw(game.batch, "" + Global.p1RubyStockpile, player.rect.x + 33f, player.rect.y - 73f);
				}
				if (Global.p1DiamondStockpile > 0) {
					diamondHUD.render(game, camera, delta, player.rect.x, player.rect.y - 105f);
					game.font.setColor(Color.CYAN);
					game.font.draw(game.batch, "" + Global.p1DiamondStockpile, player.rect.x + 34f, player.rect.y - 94f);// shadow
					game.font.setColor(Color.WHITE);
					game.font.draw(game.batch, "" + Global.p1DiamondStockpile, player.rect.x + 33f, player.rect.y - 93f);
				}
				// copper is always seen since it's the cheapest... ;-)
				copperHUD.render(game, camera, delta, player.rect.x + 60f, player.rect.y - 30f);
				game.font.setColor(Color.SALMON);
				game.font.draw(game.batch, "" + Global.p1CopperStockpile, player.rect.x + 101f, player.rect.y - 16f);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1CopperStockpile, player.rect.x + 100f, player.rect.y - 15f);
				if (Global.p1SilverStockpile > 0) {
					silverHUD.render(game, camera, delta, player.rect.x + 60f, player.rect.y - 55f);
					game.font.setColor(Color.GRAY);
					game.font.draw(game.batch, "" + Global.p1SilverStockpile, player.rect.x + 101f, player.rect.y - 41f);// shadow
					game.font.setColor(Color.WHITE);
					game.font.draw(game.batch, "" + Global.p1SilverStockpile, player.rect.x + 100f, player.rect.y - 40f);
				}
				if (Global.p1GoldStockpile > 0) {
					goldHUD.render(game, camera, delta, player.rect.x + 60f, player.rect.y - 80f);
					game.font.setColor(Color.YELLOW);
					game.font.draw(game.batch, "" + Global.p1GoldStockpile, player.rect.x + 101f, player.rect.y - 66f);// shadow
					game.font.setColor(Color.WHITE);
					game.font.draw(game.batch, "" + Global.p1GoldStockpile, player.rect.x + 100f, player.rect.y - 65f);
				}
				if (Global.p1PlatinumStockpile > 0) {
					platinumHUD.render(game, camera, delta, player.rect.x + 60f, player.rect.y - 105f);
					game.font.setColor(Color.WHITE);
					game.font.draw(game.batch, "" + Global.p1PlatinumStockpile, player.rect.x + 101f, player.rect.y - 91f);// shadow
					game.font.setColor(Color.WHITE);
					game.font.draw(game.batch, "" + Global.p1PlatinumStockpile, player.rect.x + 100f, player.rect.y - 90f);
				}
				// draw HUD
				game.font.getData().setScale(1f);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, player.p1displayScore, 12, rcr.MH - 12);// shadow
				game.font.setColor(Color.ORANGE);// set color before you draw
				game.font.draw(game.batch, player.p1displayScore, 13, rcr.MH - 11);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P2: " + Player2.score, 12 + 150, rcr.MH - 12);// shadow
//				game.font.setColor(Color.BLUE);// set color before you draw
//				game.font.draw(game.batch, "P2: " + Player2.score, 13 + 150, rcr.MH - 11);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P3: " + Player3.score, 12 + 160 * 2, rcr.MH - 12);// shadow
//				game.font.setColor(Color.PURPLE);// set color before you draw
//				game.font.draw(game.batch, "P3: " + Player3.score, 13 + 160 * 2, rcr.MH - 11);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P4: " + Player4.score, 12 + 160 * 3, rcr.MH - 12);// shadow
//				game.font.setColor(Color.GREEN);// set color before you draw
//				game.font.draw(game.batch, "P4: " + Player4.score, 13 + 160 * 3, rcr.MH - 11);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P5: " + Player5.score, 12 + 160 * 4, rcr.MH - 12);// shadow
//				game.font.setColor(Color.RED);// set color before you draw
//				game.font.draw(game.batch, "P5: " + Player5.score, 13 + 160 * 4, rcr.MH - 11);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P6: " + Player6.score, 12 + 160 * 5, rcr.MH - 12);// shadow
//				game.font.setColor(Color.TEAL);// set color before you draw
//				game.font.draw(game.batch, "P6: " + Player6.score, 13 + 160 * 5, rcr.MH - 11);

				game.font.setColor(Color.BROWN);
				game.font.draw(game.batch, "GET THE BROT!!!! -" + rcr.Timer, Gdx.graphics.getWidth() / 2 - 300, rcr.MH - 12);// shadow
				game.font.setColor(Color.SALMON);// set color before you draw
				game.font.draw(game.batch, "GET THE BROT!!!! -" + rcr.Timer, Gdx.graphics.getWidth() / 2 - 300, rcr.MH - 11);

				game.font.setColor(Color.RED);
				game.font.draw(game.batch, "Level -3", rcr.MW - 240, rcr.MH - 16);// shadows
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "Level -3", rcr.MW - 239, rcr.MH - 15);
				game.font.setColor(Color.BLACK);
				// UI
				game.font.getData().setScale(1f);
				// debug info:
				// game.font.setColor(Color.BLACK);
				// game.font.draw(game.batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), rcr.MW - 156, 36);// shadow
				// game.font.setColor(Color.WHITE);
				// game.font.draw(game.batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), rcr.MW - 157, 37);
				// game.font.setColor(Color.BLACK);
//				game.font.draw(game.batch, "JavaMem: " + Gdx.app.getJavaHeap(), camera.position.x + 320, camera.position.y - 297);// SL
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "JavaMem: " + Gdx.app.getJavaHeap(), camera.position.x + 328, camera.position.y - 295);
//				game.font.setColor(Color.BLACK);
//				game.font.draw(game.batch, "NativMem: " + Gdx.app.getNativeHeap(), camera.position.x + 320, camera.position.y - 267);// SL
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "NativMem: " + Gdx.app.getNativeHeap(), camera.position.x + 328, camera.position.y - 265);
//				game.font.draw(game.batch, "NativMem: " + Gdx.app.getNativeHeap(), camera.position.x + 328, camera.position.y - 265);
//				game.font.setColor(Color.BLACK);
				// end debug info
				// timer till extraction
				/*
				 * game.font.setColor(Color.CYAN); game.font.draw(game.batch, "Time till stop: " + rcr.ExtractionTimer, camera.position.x - 300,
				 * camera.position.y + 340); game.font.setColor(Color.WHITE); game.font.draw(game.batch, "Time till Extraction: " + rcr.ExtractionTimer,
				 * camera.position.x - 301, camera.position.y + 342);
				 */
				// separate render loop for shadows.
				game.batch.end();

				// debug drawing section: this IS important. I'm glad this is starting to make sense. It's handled on a different batch render call.
				// DrawDebugLine(posV2, mousePosV2, 2, Color.CORAL, camera.combined);
				// if (balls.size > 0)
				// u.DebugRenderer.DrawDebugRectangle(balls.get(0).rect, Color.BLUE, camera.combined);
				// if (plants.size > 1)
//					u.DebugRenderer.DrawDebugRectangleFilled(black2Rect, Color.BLACK, camera.combined);
//					u.DebugRenderer.DrawDebugRectangle(white2Rect, Color.WHITE, camera.combined);
//					u.DebugRenderer.DrawDebugRectangle(whiteRect, Color.WHITE, camera.combined);
				// u.DebugRenderer.DrawDebugRectangle(bench.rect, Color.YELLOW, camera.combined);
				// u.DebugRenderer.DrawDebugRectangle(giantFoot.rect, Color.RED, camera.combined);
//				for (int i = 0; i < wallTiles.size; i++) {
//					// System.out.println("rect?: " + wallTiles.get(i).getRect());
//					u.DebugRenderer.DrawDebugRectangle(wallTiles.get(i).getRect(), Color.RED, camera.combined);
//				}
				// music check, the show box wasn't working
				if (!Global.IsMusicPaused)
					levelMusic.play();
				// collisions
				checkEvilShipCollisions(evilShips);
				checkAmethystCollisions(amethystGems);
				checkCopperCollisions(copperMetals);
				checkDiamondCollisions(diamondGems);
				checkFoodCollisions(foodHealth);
				checkGoldCollisions(goldMetals);
				checkPlatinumCollisions(platinumMetals);
				checkRubyCollisions(rubyGems);
				checkSapphireCollisions(sapphireGems);
				checkSilverCollisions(silverMetals);
				checkTopazCollisions(topazGems);
				checkPlayerShipCollisions();
				// ui collisions

				if (Gdx.input.isKeyJustPressed(Input.Keys.Q)) {// reset map or screen
					System.out.println("\r\r\r\r\r\r\r");
					dispose();// hee hee i figured out how to reset the level. xD (dispose of the level and reload it. ;-) )
					Global.resetPlayersStats();
					onlyGoThroughLevelEndOnce = false;
					// camera.position.y = 0;
					// camera.position.x = 0;
					// camera.update();
					game.setScreen(new LevelMinusThree(game));
				}
				if (player.dead) {// if you die
					System.out.println("you are a terrible player. Feel insulted? DONT I didn't mean it");
					camera.position.y = 0;
					camera.position.x = 0;
					camera.update();
					dispose();
					game.setScreen(new LoseScreen(game, "You died!? That shouldn't be possible right now"));
				}

				if (Player.health <= 0 && isDeadTimer > 0) {
					isDeadTimer--;
					if (!Global.SetVolumeToZero && !onetime) {
						onetime = true;
						death.play();
					}
					player.isDying = true;
				}
				if (portal.canHit && !player.isDying && Player.health >= 0 && !onlyGoThroughLevelEndOnce) {
					onlyGoThroughLevelEndOnce = true;

					Player.score += amethystGems.size;
					Player.score += rubyGems.size;
					Player.score += topazGems.size;
					Player.score += sapphireGems.size;
					Player.score += diamondGems.size * 2;
					if (copperMetals.size > 0)
						Player.score *= copperMetals.size * 2;
					if (silverMetals.size > 0)
						Player.score *= silverMetals.size * 4;
					if (goldMetals.size > 0)
						Player.score *= goldMetals.size * 6;
					if (platinumMetals.size > 0)
						Player.score *= platinumMetals.size * 8;
					Player.score -= rcr.Timer;// faster is better
					player.updatep1ScoreDisplay();
					// Player2.score *= kittens.size;
					// Player3.score *= kittens.size;
					if (!Global.SetVolumeToZero && !playSoundOnce) {
						playSoundOnce = true;
						reverseSlide.play();
					}
					camera.position.y = 0;
					camera.position.x = 0;
					camera.update();
					dispose();
					game.setScreen(new Store(game));
				}
				if (rcr.ArriveTimer > 0)
					rcr.ArriveTimer--;
				rcr.Timer++;
				update(delta);// going to set camera position to last. :-)
			}

		}

	}// end of render (or update)

	private void checkPlayerShipCollisions() {
//		if (player.rect.overlaps(storeIcon.rect) && evilShips.size <= 0) {
//			storeIcon.canHit = true;// activate the store!
//		}
		if (player.rect.overlaps(bread.rect) && !bread.isCarried) {
			bread.isCarriedByPlayer = true;// you've got the bread
			if (!Global.SetVolumeToZero && !playOnlyOneTime) {
				playOnlyOneTime = true;
				player.playRandomEatSound(11);
			}
		}
		if (player.rect.overlaps(portal.rect) && bread.isCarriedByPlayer) {
			portal.canHit = true;
			System.out.println("we are overlapping the portal and bread is carried");
		}
	}

	private void checkTopazCollisions(Array<Topaz> topazGems) {
		for (Iterator<Topaz> iter = topazGems.iterator(); iter.hasNext();) {
			Topaz d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(player.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomEatSound(11);
				Player.score += 3;// testing score
				Global.p1TopazStockpile++;
				d.isDead = true;
				topazGems.removeValue(d, true);
			}
			// collding with a group: (Students!)
			for (Iterator<Student> iter2 = students.iterator(); iter2.hasNext();) {
				Student st = iter2.next();
				if (st.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					st.topazStockpile++;
					d.uuid = st.uuid;
					d.isCarried = true;
					// d.isDead = true;
					// amethystGems.removeValue(d, true);
				}
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score -= 3;// testing score
					es.topazStockpile++;
					d.uuid = es.uuid;
					// es.isHolding = true; not sure i need this. They can all be together...
					d.isCarried = true;
					// d.isDead = true;
					// topazGems.removeValue(d, true);
				}
			}
		}

	}

	private void checkSilverCollisions(Array<Silver> silverMetals) {
		for (Iterator<Silver> iter = silverMetals.iterator(); iter.hasNext();) {
			Silver d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(player.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomEatSound(11);
				Player.score += 8;// testing score
				Global.p1SilverStockpile++;
				d.isDead = true;
				silverMetals.removeValue(d, true);
			}
			// collding with a group: (Students!)
			for (Iterator<Student> iter2 = students.iterator(); iter2.hasNext();) {
				Student st = iter2.next();
				if (st.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					st.silverStockpile++;
					d.uuid = st.uuid;
					d.isCarried = true;
					// d.isDead = true;
					// amethystGems.removeValue(d, true);
				}
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score -= 8;// testing score
					es.silverStockpile++;
					d.uuid = es.uuid;
					// es.isHolding = true; not sure i need this. They can all be together...
					d.isCarried = true;
					// d.isDead = true;
					// silverMetals.removeValue(d, true);
				}
			}
		}

	}

	private void checkSapphireCollisions(Array<Sapphire> sapphireGems) {
		for (Iterator<Sapphire> iter = sapphireGems.iterator(); iter.hasNext();) {
			Sapphire d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(player.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomEatSound(11);
				Player.score += 6;// testing score
				Global.p1SapphireStockpile++;
				d.isDead = true;
				sapphireGems.removeValue(d, true);
			}
			// collding with a group: (Students!)
			for (Iterator<Student> iter2 = students.iterator(); iter2.hasNext();) {
				Student st = iter2.next();
				if (st.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					st.sapphireStockpile++;
					d.uuid = st.uuid;
					d.isCarried = true;
					// d.isDead = true;
					// amethystGems.removeValue(d, true);
				}
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score -= 6;// testing score
					es.sapphireStockpile++;
					d.uuid = es.uuid;
					// es.isHolding = true; not sure i need this. They can all be together...
					d.isCarried = true;
					// d.isDead = true;
					// sapphireGems.removeValue(d, true);
				}
			}
		}

	}

	private void checkRubyCollisions(Array<Ruby> rubyGems) {
		for (Iterator<Ruby> iter = rubyGems.iterator(); iter.hasNext();) {
			Ruby d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(player.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomEatSound(11);
				Player.score += 7;// testing score
				Global.p1RubyStockpile++;
				d.isDead = true;
				rubyGems.removeValue(d, true);
			}
			// collding with a group: (Students!)
			for (Iterator<Student> iter2 = students.iterator(); iter2.hasNext();) {
				Student st = iter2.next();
				if (st.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					st.rubyStockpile++;
					d.uuid = st.uuid;
					d.isCarried = true;
					// d.isDead = true;
					// amethystGems.removeValue(d, true);
				}
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score -= 7;// testing score
					es.rubyStockpile++;
					d.uuid = es.uuid;
					// es.isHolding = true; not sure i need this. They can all be together...
					d.isCarried = true;
					// d.isDead = true;
					// rubyGems.removeValue(d, true);
				}
			}
		}

	}

	private void checkPlatinumCollisions(Array<Platinum> platinumMetals) {
		for (Iterator<Platinum> iter = platinumMetals.iterator(); iter.hasNext();) {
			Platinum d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(player.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomEatSound(11);
				Player.score += 25;// testing score
				Global.p1PlatinumStockpile++;
				d.isDead = true;
				platinumMetals.removeValue(d, true);
			}
			// collding with a group: (Students!)
			for (Iterator<Student> iter2 = students.iterator(); iter2.hasNext();) {
				Student st = iter2.next();
				if (st.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					st.platinumStockpile++;
					d.uuid = st.uuid;
					d.isCarried = true;
					// d.isDead = true;
					// amethystGems.removeValue(d, true);
				}
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score -= 25;// testing score
					es.platinumStockpile++;
					d.uuid = es.uuid;
					// es.isHolding = true; not sure i need this. They can all be together...
					d.isCarried = true;
					// d.isDead = true;
					// platinumMetals.removeValue(d, true);
				}
			}
		}

	}

	private void checkGoldCollisions(Array<Gold> goldMetals) {
		for (Iterator<Gold> iter = goldMetals.iterator(); iter.hasNext();) {
			Gold d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(player.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomEatSound(11);
				Player.score += 15;// testing score
				Global.p1GoldStockpile++;
				d.isDead = true;
				goldMetals.removeValue(d, true);
			}
			// collding with a group: (Students!)
			for (Iterator<Student> iter2 = students.iterator(); iter2.hasNext();) {
				Student st = iter2.next();
				if (st.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					st.goldStockpile++;
					d.uuid = st.uuid;
					d.isCarried = true;
					// d.isDead = true;
					// amethystGems.removeValue(d, true);
				}
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score -= 15;// testing score
					es.goldStockpile++;
					d.uuid = es.uuid;
					// es.isHolding = true; not sure i need this. They can all be together...
					d.isCarried = true;
					// d.isDead = true;
					// goldMetals.removeValue(d, true);
				}
			}
		}

	}

	private void checkFoodCollisions(Array<Food> foodHealth) {
		for (Iterator<Food> iter = foodHealth.iterator(); iter.hasNext();) {
			Food d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(player.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomEatSound(11);
				Player.score += 1;// testing score
				if (Player.health <= Player.healthMax)
					Player.health += 30;
				else if (Player.health >= Player.healthMax)
					Player.health = Player.healthMax;
				d.isDead = true;// food is used as health
				foodHealth.removeValue(d, true);
			}
			// collding with a group: (Students!)
			for (Iterator<Student> iter2 = students.iterator(); iter2.hasNext();) {
				Student st = iter2.next();
				if (st.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					d.uuid = st.uuid;
					d.isCarried = true;
					// d.isDead = true;
				}
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score -= 1;// testing score
					if (es.health <= es.healthMax)
						es.health += 20;
					else if (es.health >= es.healthMax)
						es.health = es.healthMax;
					d.isDead = true;// food can be used as health, it's gone.
					foodHealth.removeValue(d, true);
				}
			}
		}

	}

	private void checkDiamondCollisions(Array<Diamond> diamondGems) {
		for (Iterator<Diamond> iter = diamondGems.iterator(); iter.hasNext();) {
			Diamond d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(player.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomEatSound(11);
				Player.score += 13;// testing score
				Global.p1DiamondStockpile++;
				d.isDead = true;
				diamondGems.removeValue(d, true);
			}
			// collding with a group: (Students!)
			for (Iterator<Student> iter2 = students.iterator(); iter2.hasNext();) {
				Student st = iter2.next();
				if (st.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					st.diamondStockpile++;
					d.uuid = st.uuid;
					d.isCarried = true;
					// d.isDead = true;
					// amethystGems.removeValue(d, true);
				}
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score -= 13;// testing score
					es.diamondStockpile++;
					d.uuid = es.uuid;
					// es.isHolding = true; not sure i need this. They can all be together...
					d.isCarried = true;
					// d.isDead = true;
					// diamondGems.removeValue(d, true);
				}
			}
		}

	}

	private void checkCopperCollisions(Array<Copper> copperMetals) {
		for (Iterator<Copper> iter = copperMetals.iterator(); iter.hasNext();) {
			Copper d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(player.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomEatSound(11);
				Player.score += 2;// testing score
				Global.p1CopperStockpile++;
				d.isDead = true;
				copperMetals.removeValue(d, true);
			}
			// collding with a group: (Students!)
			for (Iterator<Student> iter2 = students.iterator(); iter2.hasNext();) {
				Student st = iter2.next();
				if (st.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					st.copperStockpile++;
					d.uuid = st.uuid;
					d.isCarried = true;
					// d.isDead = true;
					// amethystGems.removeValue(d, true);
				}
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					es.copperStockpile++;
					d.uuid = es.uuid;
					// es.isHolding = true; not sure i need this. They can all be together...
					d.isCarried = true;
					// d.isDead = true;
					// copperMetals.removeValue(d, true);
				}
			}
		}

	}

	private void checkAmethystCollisions(Array<Amethyst> amethystGems) {
		for (Iterator<Amethyst> iter = amethystGems.iterator(); iter.hasNext();) {
			Amethyst d = iter.next();
			// collding with a single object: (player)
			if (d.rect.overlaps(player.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomEatSound(11);
				Player.score += 1;// testing score
				Global.p1AmethystStockpile++;
				d.isDead = true;
				amethystGems.removeValue(d, true);
			}
			// collding with a group: (Students!)
			for (Iterator<Student> iter2 = students.iterator(); iter2.hasNext();) {
				Student st = iter2.next();
				if (st.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					st.amethystStockpile++;
					d.uuid = st.uuid;
					d.isCarried = true;
					// d.isDead = true;
					// amethystGems.removeValue(d, true);
				}
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect) && !d.isCarried) {
					if (!Global.SetVolumeToZero)
						player.playRandomEatSound(11);
					Player.score--;// testing score
					es.amethystStockpile++;
					d.uuid = es.uuid;
					// es.isHolding = true; not sure i need this. They can all be together...
					d.isCarried = true;
					// d.isDead = true;
					// amethystGems.removeValue(d, true);
				}
			}
		}

	}

//	private void setCorrectScreenCoords(int x, int y, int z) {
//		tempCoords.x = x;
//		tempCoords.y = y;
//		tempCoords.z = z;
//		mousePos = camera.unproject(tempCoords);
//	}

	public void checkEvilShipCollisions(Array<EvilShip> evilShips) {
		for (Iterator<EvilShip> iter = evilShips.iterator(); iter.hasNext();) {
			EvilShip d = iter.next();
			if (!d.isDead) {
				// collding with a single object: (Player)
				if (Player.health > 0 && d.rect.overlaps(player.rect) && d.canHit && !d.isDying) {
					d.canHit = false;
					Player.health -= 50;
					if (!Global.SetVolumeToZero)
						player.playRandomHurtSound(6);
					Player.score -= 2;// testing score (remove this!)
					if (!player.isDying && Player.health <= 0) {
						Player.score -= 100;
						if (!Global.SetVolumeToZero)
							click.play();
						player.isDying = true;
					}
				} else
					d.canHit = true;
				// enemy ship ball collisions
				for (Iterator<Ball> iter2 = d.enemyGun.balls.iterator(); iter2.hasNext();) {
					Ball b = iter2.next();
					// colliding with a single object: (player 1's shipv1)
					if (Player.health > 0 && b.rect.overlaps(player.rect) && b.canHit && !b.isDead) {
						b.canHit = false;
						b.ballLife = 0;
						Player.health -= getDamageBasedOnHowManyShipsThereAre(evilShips);
						if (!Global.SetVolumeToZero)
							player.playRandomHurtSound(3);
						Player.score--;
					}
				}
				// enemy ship player's gun ball
				for (Iterator<Ball> iter3 = player.balls.iterator(); iter3.hasNext();) {
					Ball b = iter3.next();
					// colliding with a single object: (enemy ship)
					if (d.health > 0 && b.rect.overlaps(d.rect) && b.canHit && !b.isDead) {
						b.canHit = false;
						b.ballLife = 0;
						d.health -= getDamageBasedOnHowManyEnemyShipsThereAre(evilShips);
						if (!Global.SetVolumeToZero)
							player.playRandomHurtSound(3);
						Player.score++;
						if (!d.isDead && d.health <= 0) {
							Player.score += 100;// yay
							if (!Global.SetVolumeToZero)
								boom.play();
							d.isDead = true;
							// add explosions?
							for (int x = 0; x < explosions.size; x++) {
								explosions.get(x).rect.x = d.rect.x + MathUtils.random(-100f, 100f);
								explosions.get(x).rect.y = d.rect.y + MathUtils.random(-100f, 100f);
								explosions.get(x).isDead = false;
								explosions.get(x).isResetAnimation = false;
							}
							// spawn any gems and money you were carrying.
							if (d.amethystStockpile > 0) {
								for (int x = 0; x < d.amethystStockpile; x++) {
									Amethyst amethyst = amethysts.obtain();
									amethyst.rect.x = rcr.MW / 2;
									amethyst.rect.y = rcr.MH / 2;
									amethystGems.add(amethyst);
								}
							}
							if (d.copperStockpile > 0) {
								for (int x = 0; x < d.copperStockpile; x++) {
									Copper copper = coppers.obtain();
									copper.rect.x = rcr.MW / 2;
									copper.rect.y = rcr.MH / 2;
									copperMetals.add(copper);
								}
							}
							if (d.diamondStockpile > 0) {
								for (int x = 0; x < d.diamondStockpile; x++) {
									Diamond diamond = diamonds.obtain();
									diamond.rect.x = rcr.MW / 2;
									diamond.rect.y = rcr.MH / 2;
									diamondGems.add(diamond);
								}
							}
							if (d.goldStockpile > 0) {
								for (int x = 0; x < d.goldStockpile; x++) {
									Gold gold = golds.obtain();
									gold.rect.x = rcr.MW / 2;
									gold.rect.y = rcr.MH / 2;
									goldMetals.add(gold);
								}
							}
							if (d.platinumStockpile > 0) {
								for (int x = 0; x < d.platinumStockpile; x++) {
									Platinum platinum = platinums.obtain();
									platinum.rect.x = rcr.MW / 2;
									platinum.rect.y = rcr.MH / 2;
									platinumMetals.add(platinum);
								}
							}
							if (d.rubyStockpile > 0) {
								for (int x = 0; x < d.rubyStockpile; x++) {
									Ruby ruby = rubies.obtain();
									ruby.rect.x = rcr.MW / 2;
									ruby.rect.y = rcr.MH / 2;
									rubyGems.add(ruby);
								}
							}
							if (d.sapphireStockpile > 0) {
								for (int x = 0; x < d.sapphireStockpile; x++) {
									Sapphire sapphire = sapphires.obtain();
									sapphire.rect.x = rcr.MW / 2;
									sapphire.rect.y = rcr.MH / 2;
									sapphireGems.add(sapphire);
								}
							}
							if (d.silverStockpile > 0) {
								for (int x = 0; x < d.silverStockpile; x++) {
									Silver silver = silvers.obtain();
									silver.rect.x = rcr.MW / 2;
									silver.rect.y = rcr.MH / 2;
									silverMetals.add(silver);
								}
							}
							if (d.topazStockpile > 0) {
								for (int x = 0; x < d.topazStockpile; x++) {
									Topaz topaz = topazs.obtain();
									topaz.rect.x = rcr.MW / 2;
									topaz.rect.y = rcr.MH / 2;
									topazGems.add(topaz);
								}
							}
							evilShips.removeValue(d, true);
						}
					}
				}
//			// collding with a single object: (Player2)
//			if (Player2.health > 0 && d.rect.overlaps(player2.rect) && !player2.isJumping && !player2.isKicking && !player2.isBlocked && d.canHit && !d.isDying) {
//				d.canHit = false;
//				Player2.health--;
//				if (!Global.SetVolumeToZero)
//					player2.playRandomHurtSound(6);
//				Player2.score--;// testing score (remove this!)
//				if (!player2.isDying && !d.isEating && !d.isFat) {
//					Player2.score -= 100;
//					if (!Global.SetVolumeToZero)
//						click.play();
//					player2.isDying = true;
//					d.isEating = true;
//					d.isJumping = false;
//				}
//			} else
//				d.canHit = true;
//			// collding with a single object:
//			if (Player2.health > 0 && d.rect.overlaps(player2.rect) && player2.isBlocked) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player2.playRandomHurtSound(6);
//					Player2.score += 4;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object:
//			if (Player2.health > 0 && d.rect.overlaps(player2.rect) && player2.isKicking) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player2.playRandomHurtSound(6);
//					Player2.score += 505;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object: (Player3)
//			if (Player3.health > 0 && d.rect.overlaps(player3.rect) && !player3.isJumping && !player3.isKicking && !player3.isBlocked && d.canHit && !d.isDying) {
//				d.canHit = false;
//				Player3.health--;
//				if (!Global.SetVolumeToZero)
//					player3.playRandomHurtSound(6);
//				Player3.score--;// testing score (remove this!)
//				if (!player3.isDying && !d.isEating && !d.isFat) {
//					Player3.score -= 100;
//					if (!Global.SetVolumeToZero)
//						click.play();
//					player3.isDying = true;
//					d.isEating = true;
//					d.isJumping = false;
//				}
//			} else
//				d.canHit = true;
//			// collding with a single object:
//			if (Player3.health > 0 && d.rect.overlaps(player3.rect) && player3.isBlocked) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player3.playRandomHurtSound(6);
//					Player3.score += 4;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object:
//			if (Player3.health > 0 && d.rect.overlaps(player3.rect) && player3.isKicking) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player3.playRandomHurtSound(6);
//					Player3.score += 505;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object: (Player4)
//			if (Player4.health > 0 && d.rect.overlaps(player4.rect) && !player4.isJumping && !player4.isKicking && !player4.isBlocked && d.canHit && !d.isDying) {
//				d.canHit = false;
//				Player4.health--;
//				if (!Global.SetVolumeToZero)
//					player4.playRandomHurtSound(6);
//				Player4.score--;// testing score (remove this!)
//				if (!player4.isDying && !d.isEating && !d.isFat) {
//					Player4.score -= 100;
//					if (!Global.SetVolumeToZero)
//						click.play();
//					player4.isDying = true;
//					d.isEating = true;
//					d.isJumping = false;
//				}
//			} else
//				d.canHit = true;
//			// collding with a single object:
//			if (Player4.health > 0 && d.rect.overlaps(player4.rect) && player4.isBlocked) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player4.playRandomHurtSound(6);
//					Player4.score += 4;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object:
//			if (Player4.health > 0 && d.rect.overlaps(player4.rect) && player4.isKicking) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player4.playRandomHurtSound(6);
//					Player4.score += 505;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object: (Player5)
//			if (Player5.health > 0 && d.rect.overlaps(player5.rect) && !player5.isJumping && !player5.isKicking && !player5.isBlocked && d.canHit && !d.isDying) {
//				d.canHit = false;
//				Player5.health--;
//				if (!Global.SetVolumeToZero)
//					player5.playRandomHurtSound(6);
//				Player5.score--;// testing score (remove this!)
//				if (!player5.isDying && !d.isEating && !d.isFat) {
//					Player5.score -= 100;
//					if (!Global.SetVolumeToZero)
//						click.play();
//					player5.isDying = true;
//					d.isEating = true;
//					d.isJumping = false;
//				}
//			} else
//				d.canHit = true;
//			// collding with a single object:
//			if (Player5.health > 0 && d.rect.overlaps(player5.rect) && player5.isBlocked) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player5.playRandomHurtSound(6);
//					Player5.score += 4;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object:
//			if (Player5.health > 0 && d.rect.overlaps(player5.rect) && player5.isKicking) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player5.playRandomHurtSound(6);
//					Player5.score += 505;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object: (Player6)
//			if (Player6.health > 0 && d.rect.overlaps(player6.rect) && !player6.isJumping && !player6.isKicking && !player6.isBlocked && d.canHit && !d.isDying) {
//				d.canHit = false;
//				Player6.health--;
//				if (!Global.SetVolumeToZero)
//					player6.playRandomHurtSound(6);
//				Player6.score--;// testing score (remove this!)
//				if (!player6.isDying && !d.isEating && !d.isFat) {
//					Player6.score -= 100;
//					if (!Global.SetVolumeToZero)
//						click.play();
//					player6.isDying = true;
//					d.isEating = true;
//					d.isJumping = false;
//				}
//			} else
//				d.canHit = true;
//			// collding with a single object:
//			if (Player6.health > 0 && d.rect.overlaps(player6.rect) && player6.isBlocked) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player6.playRandomHurtSound(6);
//					Player6.score += 4;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object:
//			if (Player6.health > 0 && d.rect.overlaps(player6.rect) && player6.isKicking) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player6.playRandomHurtSound(6);
//					Player6.score += 505;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
			}
		}
	}

	private int getDamageBasedOnHowManyShipsThereAre(Array<EvilShip> evilShips) {
		int s = evilShips.size;
		if (s <= 1)
			return 30;
		else if (s == 2 && s == 3)
			return 20;
		else if (s == 4 && s == 5)
			return 10;
		else if (s == 6 && s == 7)
			return 5;
		else if (s == 8 && s == 9)
			return 3;
		else if (s == 10 && s == 11)
			return 2;
		else
			return 1;
	}

	private int getDamageBasedOnHowManyEnemyShipsThereAre(Array<EvilShip> evilShips) {
		int s = evilShips.size;
		if (s <= 1)
			return 10;
		else if (s == 2 && s == 3)
			return 12;
		else if (s == 4 && s == 5)
			return 14;
		else if (s == 6 && s == 7)
			return 16;
		else if (s == 8 && s == 9)
			return 18;
		else if (s == 10 && s == 11)
			return 20;
		else
			return 30;
	}

	/**
	 * plays one through 6 sounds set numberOfSounds to 7 to randomly use one of all of them. xD
	 */
	public void playRandomClickSound(int numberOfSounds) {
		int randomSound = MathUtils.random(1, numberOfSounds);
		if (!Global.SetVolumeToZero) {
			if (randomSound == 1)
				click.play();
			else if (randomSound == 2)
				click2.play();
			else if (randomSound == 3)
				click4.play();
			else if (randomSound == 4)
				click5.play();
			else if (randomSound == 5)
				click6.play();
			else if (randomSound == 6)
				click7.play();
		}
	}

	@Override
	public void dispose() {
		enter.dispose();
		enter2.dispose();
		levelMusic.dispose();
		player.dispose();// for disposing the sound effects... because i'm not sure what needs disposed yet. I don't even know if this is needed. lol
//		player2.dispose();
//		player3.dispose();
//		player4.dispose();
//		player5.dispose();
		click.dispose();
		click2.dispose();
		click3.dispose();
		click4.dispose();
		click5.dispose();
		click6.dispose();
		click7.dispose();
		boom.dispose();
		death.dispose();
		reverseSlide.dispose();
	}

	@Override
	public void resize(int width, int height) {
		vport.update(width, height, true);
		// camera.setToOrtho(false, width / 32f / 2f, height / 32f / 2f);
		if (!levelMusic.isPlaying() && !Global.IsMusicPaused) {
			levelMusic.play();
		}
	}

	@Override
	public void hide() {
		if (levelMusic.isPlaying() && !Global.IsMusicPaused) {
			levelMusic.pause();
		}
	}

	@Override
	public void pause() {
		if (levelMusic.isPlaying() && !Global.IsMusicPaused) {
			levelMusic.pause();
		}
	}

	@Override
	public void resume() {
		if (!levelMusic.isPlaying() && !Global.IsMusicPaused) {
			levelMusic.play();
		}
	}

}
