package org.egordorichev.lasttry.entity;

import org.egordorichev.lasttry.util.Direction;

public abstract class Enemy extends Entity {
	public static final String SLIME_GREEN = "Green Slime";
	public static final String SLIME_BLUE = "Blue Slime";
	protected int currentAi;
	protected int maxAi;

	public Enemy(String name, int maxHp, int defense, int damage) {
		super(name, false, maxHp, defense, damage);

		this.currentAi = 0;
	}

	public Enemy(String name) {
		super(name, false);
		this.currentAi = 0;
	}

	@Override
	public void render() {
		this.animations[this.state.getId()]
				.getCurrentFrame().getFlippedCopy(this.direction == Direction.RIGHT, false)
				.draw(this.renderBounds.x, this.renderBounds.y);
	}

	@Override
	public void update(int dt) {
		super.update(dt);
		this.updateAI();
	}

	public void updateAI() {
		this.currentAi++;

		if(this.currentAi >= this.maxAi) {
			this.currentAi = 0;
		}
	}

	@Override
	public void onSpawn() {

	}

	public static Enemy create(String name) {
		if (name.equals(Enemy.SLIME_GREEN)) {
			return new GreenSlime();
		} else if(name.equals(SLIME_BLUE)) {	
			return new BlueSlime();
		} else {
			throw new RuntimeException("Entity with name " + name + " is not found.");
		}
	}
}

@@ -133,120 +133,8 @@
 y %7B%0A
-%09public static final String SLIME_GREEN = %22Green Slime%22;%0A%09public static final String SLIME_BLUE = %22Blue Slime%22;%0A
 %09pro
@@ -192,27 +192,22 @@
 c Enemy(
-String name
+int id
 , int ma
@@ -242,28 +242,26 @@
 ) %7B%0A%09%09super(
-name
+id
 , false, max
@@ -323,27 +323,22 @@
 c Enemy(
-String name
+int id
 ) %7B%0A%09%09su
@@ -341,20 +341,18 @@
 %09%09super(
-name
+id
 , false)
@@ -861,134 +861,150 @@
 ate(
-String name) %7B%0A%09%09if (name.equals(Enemy.SLIME_GREEN)) %7B%0A%09%09%09return new GreenSlime();%0A%09%09%7D else if(name.equals(SLIME_BLUE)) %7B%09%0A%09%09%09
+int id) %7B // TODO: think about better way to do this.%0A%09%09switch(id) %7B%0A%09%09%09case EntityID.none: defaul: return null;%0A%09%09%09case EntityID.greenSlime: 
 retu
@@ -1014,12 +1014,13 @@
 new 
-Blue
+Green
 Slim
@@ -1030,92 +1030,55 @@
 ;%0A%09%09
-%7D else %7B%0A%09%09%09throw new RuntimeException(%22Entity with name %22 + name + %22 is not found.%22
+%09case EntityID.blueSlime: return new BlueSlime(
 );%0A%09

Update Enemy.java