import java.awt.Image;
import java.io.IOException;
import javax.imageio.*;

public class WasaReimu extends Reimu implements java.io.Serializable {
	static final long serialVersionUID = 1L;
	public static final int type = 3;
	public static final String nameJ = "わされいむ";
	public static final String nameE = "WasaReimu";

	private static Image[][][] images = new Image[ImgFlag.NUM_OF_CONDITIONS][2][3];

	public static void loadImages (ClassLoader loader) throws IOException {
		final String path = "images/wasa/";
		final String dir[] = {"left/", "right/"};

		for (int i=ImgFlag.LEFT; i <= ImgFlag.RIGHT; i++) {
			images[ImgFlag.BODY][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"body.png"));
			images[ImgFlag.LICK][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"lick.png"));
			images[ImgFlag.BRAID][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"braid.png"));
			images[ImgFlag.ACCESSORY][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"ribbon.png"));
			images[ImgFlag.DAMAGED][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"damage.png"));
			images[ImgFlag.SHIT][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+"shit.png"));
			images[ImgFlag.CRUSHED][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+"crushed.png"));
			images[ImgFlag.PANTS][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"pants.png"));
			images[ImgFlag.STAIN][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"shit.png"));

			images[ImgFlag.SHIT][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+"shit.png"));
			images[ImgFlag.PANTS2][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+"pants.png"));

			images[ImgFlag.NORMAL][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/normal.png"));
			images[ImgFlag.SLEEPING][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/sleeping.png"));
			images[ImgFlag.CHEER][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/cheer.png"));
			images[ImgFlag.SMILE][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/smile.png"));
			images[ImgFlag.TIRED][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/tired.png"));
			images[ImgFlag.PUFF][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/puff.png"));
			images[ImgFlag.CRYING][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/crying.png"));
			images[ImgFlag.EXCITING][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/exciting.png"));
			images[ImgFlag.REFRESHED][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/refreshed.png"));
			images[ImgFlag.DEAD][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/dead.png"));
			images[ImgFlag.RUDE][i][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+dir[i]+"faces/normal.png"));
		}
		images[ImgFlag.ROLL][ImgFlag.LEFT][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+"roll_left.png"));
		images[ImgFlag.ROLL][ImgFlag.RIGHT][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+"roll_right.png"));
		images[ImgFlag.PANTS2_ROLL][ImgFlag.LEFT][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+"left_pants.png"));
		images[ImgFlag.PANTS2_ROLL][ImgFlag.RIGHT][adultIndex] = ImageIO.read(loader.getResourceAsStream(path+"right_pants.png"));

		for(Image[][] array2d : images)	{	
			for(Image[] array : array2d) {
				if(array[adultIndex] == null) {
					continue;
				}
				// Scale larger images down
				array[adultIndex] = array[adultIndex].getScaledInstance(adultSize, adultSize, Image.SCALE_AREA_AVERAGING);
				array[childIndex] = array[adultIndex].getScaledInstance(childSize, childSize, Image.SCALE_AREA_AVERAGING);
				array[babyIndex] = array[adultIndex].getScaledInstance(babySize, babySize, Image.SCALE_AREA_AVERAGING);
			}
		}
	}

	public Image getImage(int type, int direction) {
		return images[type][direction][ageState.ordinal()];
	}

	@Override
	public int getHybridType(int partnerType) {
		switch (partnerType) {
		default:
			return WasaReimu.type;
		}
	}

	@Override
	public WasaReimu clone() {
		return new WasaReimu(this);
	}

	// public methods
	public WasaReimu(int initX, int initY, int initZ, Body.AgeState initAgeState, Body p1, Body p2) {
		super(initX, initY, initZ, initAgeState, p1, p2);
	}

	protected WasaReimu(WasaReimu other) {
		super(other);
	}
}