package entities;

import com.haxepunk.Entity;
import com.haxepunk.graphics.Image;
import com.haxepunk.graphics.Spritemap;
import com.haxepunk.masks.Circle;

class Grave extends Entity 
{
	private var sprite: Spritemap;
	var GType: Int;
	public var RiseLevel: Int;
		
    public function new(x : Float, y : Float)
    {
//        super(x, y, Image.createRect(30,50,0x808080));
        super(x, y);

        sprite = new Spritemap("gfx/Graves.png", 30, 50);
//        sprite.add("move", [0, 1, 2, 3], 8);
        graphic = sprite;
//        sprite.play("move");
		
        type = "grave";
		
		GType = Std.random(2);
		
		RiseLevel = 0;
		sprite.setFrame(0,GType);
    }
	
	public function Rise(): Bool
	{
		var locColor: Int = 0;
		
		RiseLevel += 1;
		if (RiseLevel == 5) { RiseLevel = 0; }
/*		
		switch (RiseLevel)
		{
			case 0 : locColor = 0x808080;
			case 1 : locColor = 0xFF8080;
			case 2 : locColor = 0xFF5050;
			case 3 : locColor = 0xFF2020;
			case 4 : locColor = 0xFF0000;
		}
		
		graphic = Image.createRect(30, 50, locColor);
*/
		sprite.setFrame(RiseLevel,GType);
		
		return (RiseLevel == 0);
	}
	
	public function Hit(): Bool
	{
		var locColor: Int = 0;
		
		RiseLevel -= 1;
		if (RiseLevel < 0) { RiseLevel = 0; }
/*		
		switch (RiseLevel) 
		{
			case 0 : locColor = 0x808080;
			case 1 : locColor = 0xFF8080;
			case 2 : locColor = 0xFF5050;
			case 3 : locColor = 0xFF2020;
		}
		
		graphic = Image.createRect(30, 50, locColor);
*/
		sprite.setFrame(RiseLevel,GType);
		
		return (RiseLevel > 0);
	}
}