2022-10-09 23:13:24 -06:00
|
|
|
using System;
|
2021-10-14 13:46:33 -06:00
|
|
|
using UnityEngine;
|
2021-10-21 12:05:56 -06:00
|
|
|
using UnityEngine.SceneManagement;
|
2021-10-14 13:46:33 -06:00
|
|
|
|
2022-10-07 14:54:24 -06:00
|
|
|
public class Goal : MonoBehaviour
|
2021-10-14 13:46:33 -06:00
|
|
|
{
|
2022-10-09 23:13:24 -06:00
|
|
|
private Scene currentScene;
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
currentScene = SceneManager.GetActiveScene();
|
|
|
|
}
|
|
|
|
|
2021-10-14 13:46:33 -06:00
|
|
|
private void OnCollisionEnter2D(Collision2D other)
|
|
|
|
{
|
2022-10-07 13:18:54 -06:00
|
|
|
if (other.collider.CompareTag("Player"))
|
2021-10-14 13:46:33 -06:00
|
|
|
{
|
2021-10-21 12:05:56 -06:00
|
|
|
GetComponent<AudioSource>().Play();
|
2022-10-09 23:13:24 -06:00
|
|
|
nextLevel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void nextLevel()
|
|
|
|
{
|
|
|
|
switch (currentScene.name)
|
|
|
|
{
|
|
|
|
case "level1":
|
|
|
|
SceneManager.LoadScene("level2");
|
|
|
|
break;
|
|
|
|
case "level2":
|
|
|
|
SceneManager.LoadScene("level3");
|
|
|
|
break;
|
|
|
|
case "level3":
|
|
|
|
SceneManager.LoadScene("winScreen");
|
|
|
|
break;
|
2021-10-14 13:46:33 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|