using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SwipeDetect : MonoBehaviour {
    public bool SwipeUp;
    public bool SwipeDown;
    public bool Click;
    public float swipeIntensity;
    public Vector2 positionStart;
    public Vector2 positionEnd;
    public GameController controller;
    public AudioController audio;
    // Use this for initialization
    void Start () {
        SwipeUp = false;
        SwipeDown = false;
        Click = false;
	}
	
    public void ChangeTrack(int id)
    {
        controller.soundPlaying = id;
        Click = true;
        audio.startSong();
    }

	// Update is called once per frame
	void Update () {
        if (!Input.GetMouseButtonDown(0))
        {
            Click = false;
        }
        else positionStart = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
        if (Input.GetMouseButtonUp(0))
        {
            positionEnd = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            swipeIntensity = positionEnd.y - positionStart.y;
            if (swipeIntensity > 0)
            {
                //Debug.Log("swipeUp!");
                SwipeUp = true;
                SwipeDown = false;
            }
            else
            {
                //Debug.Log("swipeDown!");
                SwipeUp = false;
                SwipeDown = true;
            }
        }
        else {
            SwipeUp = false;
            SwipeDown = false;
        }
	}
}
