import res.Sprite;

class RedUnit extends Unit {
	var shotDelay:Float = 2;
	var shotTime:Float = 2;

	var bulletDelay:Float = 0.1;
	var bulletTime:Float = 0.1;

	var bullets:Int = 0;

	public function new(sprite:Sprite) {
		super(sprite);
		currentFrameIndex = 3;
	}

	override function update(dt:Float) {
		super.update(dt);

		if (shotTime <= 0) {
			if (bulletTime <= 0) {
				if (bullets < 10) {
					shotCb('big_bullet');
					bulletTime = bulletDelay;
					bullets++;
				} else {
					shotTime = shotDelay + shotTime;
					bullets = 0;
				}
			} else {
				bulletTime -= dt;
			}
		} else
			shotTime -= dt;
	}
}
