package MapItem;

import com.jln.ld.GameEntity;
import com.jln.ld.Shared;

import menus.GameMenu;

public class MessagePoint implements GameEntity {

	private float x,y, speed, alpha;
	private int cpt = 110;
	private String message;
	private int type;
	private boolean destroy;
	
	public static final int TYPE_POINTS = 0;
	public static final int TYPE_POWERUPS = 1;
	public static final int TYPE_INFORMATION = 2;
	
	public MessagePoint(float x, float y,String message, int type){
		this.x = x - (message.length()*3);
		this.y = y;
		this.speed = 1;
		this.message = message;
		this.destroy = false;
		this.alpha = 1f;
		this.type = type;
	}
	
	@Override
	public void update(GameMenu game) {
		if(!destroy){
			cpt--;
			if(cpt<=0){
				destroy = true;
			}else{
				y+=speed;
				if(cpt%4==0){
					speed+=0.1;
				}
			}
			if(cpt<100){
				alpha = ((cpt*1f)/100f);
			}
		}
		
	}

	@Override
	public void render(GameMenu game) {
		if(!destroy){
			Shared.FONT_SMALL.setColor(0.3f, 0.3f, 0.3f, alpha);
			Shared.FONT_SMALL.draw(Shared.GAME_BATCH,message,x,y);
			
			if(type==TYPE_POINTS){
				Shared.FONT_SMALL.setColor(1f, 0.7f, 0.4f, alpha);
			}else if(type == TYPE_POWERUPS){
				Shared.FONT_SMALL.setColor(0.6f, 1f, 0.4f, alpha);
			}else if(type == TYPE_INFORMATION){
				Shared.FONT_SMALL.setColor(0.9f, 9f, 0.9f, alpha);
			}
			
			Shared.FONT_SMALL.draw(Shared.GAME_BATCH,message,x,y+1);
		}
		
	}
	
	public boolean isDestroy(){
		return destroy;
	}

}
