package projectzombie.task;

import bdf.types.BdfNamedList;
import bdf.types.BdfObject;
import projectzombie.Main;
import projectzombie.entity.Entity;
import projectzombie.menu.MenuDeath;

public class TaskDeathScreen extends Task
{
	int timer;

	public TaskDeathScreen(Entity parent) {
		super(parent);
		
		timer = 250;
	}
	
	public TaskDeathScreen(Entity parent, BdfObject bdf) {
		super(parent);
		BdfClassLoad(bdf);
	}
	
	@Override
	public void BdfClassLoad(BdfObject bdf) {
		super.BdfClassLoad(bdf);
		
		BdfNamedList nl = bdf.getNamedList();
		
		timer = nl.get("timer").getInteger();
	}
	
	@Override
	public void BdfClassSave(BdfObject bdf) {
		super.BdfClassSave(bdf);
		
		BdfNamedList nl = bdf.getNamedList();
		
		nl.set("timer", bdf.newObject().setInteger(timer));
	}

	@Override
	public void update()
	{
		timer -= 1;
		
		if(timer < 0) {
			Main.menu = new MenuDeath();
		}
	}

	@Override
	public boolean isDone() {
		return timer < 0;
	}

}
