package animations;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

import interfaces.Directions;
import player.Player;
import utils.Animation;

/**  ------------- Nihilne ------------
    *** @author Mitch Weaver - 2016 ***
      ~~~~ All Rights Reserved ~~~~ */

public final class PlayerAnimationSequence implements Directions {

	public final Animation[] idles, walks, axeChops, mines;
	public final BufferedImage[] getHits;

	public PlayerAnimationSequence(Animation[] idles, Animation[] walks, Animation[] axeChops, Animation[] mines, BufferedImage[] getHits) {
		this.idles = idles;
		this.walks = walks;
		this.axeChops = axeChops;
		this.mines = mines;
		this.getHits = getHits;
	}
	
/************************ RUNS *********************************************/

	public final void runIdle() {
		switch(Player.facing){
			case NORTH: 			idles[0].runAnimation(); break;
			case NORTHEAST: 		idles[1].runAnimation(); break;
			case EAST: 			    idles[2].runAnimation(); break;
			case SOUTHEAST:         idles[3].runAnimation(); break;
			case SOUTH:             idles[4].runAnimation(); break;
			case SOUTHWEST:         idles[5].runAnimation(); break;
			case WEST: 				idles[6].runAnimation(); break;
			case NORTHWEST:		    idles[7].runAnimation(); break;
		}
	}

	public final void runWalk() {
		switch(Player.facing){
			case NORTH: 			walks[0].runAnimation(); break;
			case NORTHEAST: 		walks[1].runAnimation(); break;
			case EAST: 			    walks[2].runAnimation(); break;
			case SOUTHEAST:         walks[3].runAnimation(); break;
			case SOUTH:             walks[4].runAnimation(); break;
			case SOUTHWEST:         walks[5].runAnimation(); break;
			case WEST: 				walks[6].runAnimation(); break;
			case NORTHWEST:		    walks[7].runAnimation(); break;
		 }
	}

	public final void runChop() {
		switch(Player.facing){
			case NORTH: 			axeChops[0].runAnimation(); break;
			case NORTHEAST: 		axeChops[1].runAnimation(); break;
			case EAST: 			    axeChops[2].runAnimation(); break;
			case SOUTHEAST:         axeChops[3].runAnimation(); break;
			case SOUTH:             axeChops[4].runAnimation(); break;
			case SOUTHWEST:         axeChops[5].runAnimation(); break;
			case WEST: 				axeChops[6].runAnimation(); break;
			case NORTHWEST:		    axeChops[7].runAnimation(); break;
		 }
	}

	public final void runMine() {
		switch(Player.facing){
			case NORTH: 			mines[0].runAnimation(); break;
			case NORTHEAST: 		mines[1].runAnimation(); break;
			case EAST: 			    mines[2].runAnimation(); break;
			case SOUTHEAST:         mines[3].runAnimation(); break;
			case SOUTH:             mines[4].runAnimation(); break;
			case SOUTHWEST:         mines[5].runAnimation(); break;
			case WEST: 				mines[6].runAnimation(); break;
			case NORTHWEST:		    mines[7].runAnimation(); break;
		 }
	}
	
/************************* END RUNS *******************************************/

/******************** RENDERS **********************************************/
	public final void renderIdle(final Graphics2D g2d) {
		switch(Player.facing){
			case NORTH: 	idles[0].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case NORTHEAST: idles[1].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case EAST: 		idles[2].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTHEAST: idles[3].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTH: 	idles[4].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTHWEST: idles[5].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case WEST: 		idles[6].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case NORTHWEST: idles[7].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
		}
	}

	public final void renderWalk(final Graphics2D g2d) {
		switch(Player.facing){
			case NORTH: 	walks[0].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case NORTHEAST: walks[1].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case EAST: 		walks[2].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTHEAST: walks[3].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTH: 	walks[4].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTHWEST: walks[5].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case WEST:	    walks[6].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case NORTHWEST: walks[7].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
		}
	}

	public final void renderChop(final Graphics2D g2d) {
		switch(Player.facing){
			case NORTH: 	axeChops[0].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case NORTHEAST: axeChops[1].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case EAST: 		axeChops[2].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTHEAST: axeChops[3].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTH: 	axeChops[4].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTHWEST: axeChops[5].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case WEST: 		axeChops[6].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case NORTHWEST: axeChops[7].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
		}
	}
	
	public final void renderMine(final Graphics2D g2d) {
		switch(Player.facing){
			case NORTH: 	mines[0].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case NORTHEAST: mines[1].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case EAST:	    mines[2].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTHEAST: mines[3].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTH:     mines[4].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case SOUTHWEST: mines[5].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case WEST:      mines[6].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
			case NORTHWEST: mines[7].drawAnimation(g2d, Player.pos.x - Player.width/2, Player.pos.y - Player.height / 2); break;
		}
	}
	
	public final void renderGetHit(final Graphics2D g2d) {
			g2d.drawImage(getHits[Player.facing - 1], (int)(Player.pos.x - Player.width/2), (int)(Player.pos.y - Player.height/2), null);
	}

/********************************************************************/
}
