using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ButtonsMethods : MonoBehaviour {
		
	[SerializeField] private float timeWalking = 2;
	private float timer = 0;
	[SerializeField] private Rigidbody2D playerRG;
	[SerializeField] private float speed = 2;
	private int dir = 0;

	void Update(){
		walk ();
		if (timer >= timeWalking) {
			if (dir == 1) {
				SceneManager.LoadScene ("Level_1");
			} else if (dir == -1) {
				Application.Quit ();
			}
		}
	}

	public void NewGame(){
			dir = 1;
		SceneManager.LoadScene ("Level_1");

	}

	public void Exit(){
//			dir = -1;
		Application.Quit();
	}

	public void showCredits(){
		SceneManager.LoadScene ("Credits");

	}

	public void goHomeMenu(){
		SceneManager.LoadScene ("Main_Menu");
	}

	 void walk(){
			playerRG.velocity = new Vector2 (dir * speed, 0);
		if(timer <= timeWalking)
			timer += Time.deltaTime * Mathf.Abs(dir);
	}

}
