package com.sertaogames.terremoto.component;
import com.badlogic.gdx.audio.Sound;
import com.sertaogames.cactus2d.Cactus2DApplication;
import com.sertaogames.cactus2d.Component;
import com.sertaogames.cactus2d.GameObject;
import com.sertaogames.cactus2d.components.LabelComponent;
import com.sertaogames.terremoto.GameState;
import com.sertaogames.terremoto.TerremotoApplication;
import com.sertaogames.terremoto.factory.GameObjectsFactory;
public class TipComponent extends Component {
public static LabelComponent messageLabel = null;
private boolean active = false;
private GameObject tip = null;
String message = null;
GameState nextState = null;
public static Sound sound = Cactus2DApplication.loadSound("data/sound/msg.wav");;
@Override
public void init() {
sound.play();
createTip();
}
private void createTip() {
messageLabel = new LabelComponent(message);
messageLabel.setFontName(TerremotoApplication.fontName);
tip = GameObjectsFactory.createTip(messageLabel, nextState);
GameControllerComponent.tipGameObject = tip;
gameObject.parent.addGameObject(tip);
}
public TipComponent(boolean active, String message, GameState nextState) {
this.active = active;
this.message = message;
this.nextState = nextState;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public void update() {
if(active){
messageLabel.text = message;
tip.setActive(true);
} else {
tip.setActive(false);
}
}
@Override
public void onClick() {
createTip();
}
}