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

public class Goal : MonoBehaviour
{
	[SerializeField]
	private LevelDifficultyAsset difficulty;

	[SerializeField]
	private Vector3Asset playerPositionAsset;

	[SerializeField]
	private float radius = 1f;

	private void FixedUpdate()
	{
		CheckPlayerProgress();	
	}

	private void CheckPlayerProgress()
	{
		if(GetPlayerDistance() < radius)
		{
			NextLevel();
		}
	}

	private float GetPlayerDistance()
	{
		return Vector2.Distance(playerPositionAsset.GetVector(), transform.position);
	}

	private void NextLevel()
	{
		difficulty.IncreaseDifficulty();
		SceneManager.LoadScene(0);
	}
}
