Make all levels accessible.
This commit is contained in:
parent
3808710de8
commit
88ed9dfb6b
2 changed files with 25 additions and 3 deletions
|
@ -161411,7 +161411,7 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1955489873}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 17, z: 0}
|
||||
m_LocalPosition: {x: 0, y: 13, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
|
|
|
@ -1,15 +1,37 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Goal : MonoBehaviour
|
||||
{
|
||||
private Scene currentScene;
|
||||
private void Start()
|
||||
{
|
||||
currentScene = SceneManager.GetActiveScene();
|
||||
}
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D other)
|
||||
{
|
||||
if (other.collider.CompareTag("Player"))
|
||||
{
|
||||
Debug.Log("You win!!!");
|
||||
GetComponent<AudioSource>().Play();
|
||||
SceneManager.LoadScene("winScreen");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue