using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class mapSelector : MonoBehaviour {

    public float cursorHeight = 1.5f;
    public Transform cursor;

    public RectTransform level1;
    public RectTransform level2;
    public RectTransform level3;

    int pointerSelector = 0;
    RectTransform recSelected;
    Vector2 levelSelected = Vector2.zero;

    void Update() 
    {
        int axisRaw = (int)Input.GetAxisRaw("Horizontal");       
        
        pointerSelector += axisRaw;
        getRectTransform(pointerSelector);
    }

    void getRectTransform(int i)
    {
        switch (i) { 
            case 0 : recSelected = level1;
                break;
            case 1: recSelected = level2;
                break;
            case 2: recSelected = level3;
                break;
      }
      getSelectedPos(i);
    }

    void getSelectedPos(int i)
    {
       Vector3 s = Vector3.zero;
       levelSelected = Camera.main.ScreenToWorldPoint(recSelected.rect.position);
    }

    void setCursorPoint()
    {
        if (cursor == null)
            return;

        cursor.position = levelSelected + Vector2.up * cursorHeight;
    }
}
