package xaero.rotatenjump.game.touch;

import java.util.ArrayList;
import java.util.List;

import xaero.rotatenjump.GameView;

/**
 * Created by xaero on 15/07/2017.
 */

public class TouchHandler {

    List<TouchEvent> guiTouchEvents;
    List<TouchEvent> ingameTouchEvents;
    GameView view;

    public TouchHandler(GameView view){
        this.view = view;
        guiTouchEvents = new ArrayList<>();
        ingameTouchEvents = new ArrayList<>();
    }

    public void addGuiEvent(float x, float y, int type){
        guiTouchEvents.add(new TouchEvent(x, y, type));
    }

    public void addIngameEvent(float x, float y, int type){
        ingameTouchEvents.add(new TouchEvent(x, y, type));
    }

    public void handleGuiEvents(){
        while(guiTouchEvents.size() > 0){
            TouchEvent e = guiTouchEvents.remove(0);
            view.guiTouch(e.getX(), e.getY(), e.getType());
        }
    }

    public void handleIngameEvents(){
        while(ingameTouchEvents.size() > 0){
            TouchEvent e = ingameTouchEvents.remove(0);
            view.ingameTouch(e.getX(), e.getY(), e.getType());
        }
    }

}
