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

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

	[SerializeField]
	private Vector3Asset playerPosition;

	[SerializeField]
	private float lavaSpeed = 0f;

	private void Start()
	{
		Initialize();
	}

	private void Initialize()
	{
		lavaSpeed = difficulty.GetDifficultySettings().GetLavaSpeed();
	}

	private void FixedUpdate()
	{
		transform.position += Vector3.up * lavaSpeed * Time.fixedDeltaTime;

		if(transform.position.y > playerPosition.GetVector().y)
		{
			KillPlayer();
		}
	}

	private void KillPlayer()
	{
		difficulty.ResetDifficulty();
		SceneManager.LoadScene(0);
	}
}
