package ru.vagrant_ai.questionmarkgame.util;
import java.util.ArrayList;
import java.util.List;
import org.newdawn.slick.Graphics;
import ru.vagrant_ai.questionmarkgame.main.GameplayState;
import ru.vagrant_ai.questionmarkgame.obj.mob.Eel;
import ru.vagrant_ai.questionmarkgame.obj.mob.Khatum;
import ru.vagrant_ai.questionmarkgame.obj.mob.Monster;
import ru.vagrant_ai.questionmarkgame.obj.mob.Waldo3;
import ru.vagrant_ai.questionmarkgame.obj.mob.Whim;
import ru.vagrant_ai.questionmarkgame.util.list.ML;
import ru.vagrant_ai.questionmarkgame.util.list.MS;
public class MonsterHandler {
public MonsterHandler()
{
monster_array.clear();
monster_queue.clear();
}
public void update()
{
if (monster_queue.size() > 0)
spawnMob();
}
public void render(Graphics g)
{
for (int i = 0; i < monster_array.size(); ++i)
{
Monster monster = monster_array.get(i);
if (!GameplayState.gamePaused() && !GameplayState.gameStateChanging())
{
monster.update();
if (monster.state == MS.NULL)
{
monster_array.remove(i);
i--;
}
}
monster.render(g);
}
}
/* MONSTER BEHAVIOR STATION */
public static List<Monster> monster_array = new ArrayList<Monster>();
private static List<ML> monster_queue = new ArrayList<ML>();
private final byte horde_timer = 60;
private byte util_timer = horde_timer;
private void spawnMob()
{
util_timer--;
if (util_timer > 0)
return;
else
util_timer = horde_timer;
ML mob = monster_queue.get(0);
Monster monster = null;
switch(mob)
{
case WHIM:
monster = new Whim();
break;
case KHATUM:
monster = new Khatum();
break;
case WALDO3:
monster = new Waldo3();
break;
case EEL:
monster = new Eel();
break;
}
monster_array.add(monster);
monster_queue.remove(0);
}
public static void spawnMob(ML monster)
{
ML mob = monster;
monster_queue.add(mob);
}
public static int monstersActive() //monster on screen + monster in queue
{
return monster_array.size()+monster_queue.size();
}
/**
* Clears Monster_array and Monster_queue
*/
public static void clear()
{
monster_array.clear();
monster_queue.clear();
}
}