using System.Collections; using System.Collections.Generic; using UnityEngine; public class NextLevelMover : MonoBehaviour { private GameObject currentDoor;//current door the player is interacting with public int levelNum = 0; //current level the player is on public bool finalLevelReached = false; //bool for when the player has finished the game void Update() { if (currentDoor != null) //if the player is colliding with a door, move the player to the doors destination { transform.position = currentDoor.GetComponent().getDestination().position; } } // Method called when another collider enters the trigger collider attached to this object void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Door")) { currentDoor = collision.gameObject; //current door = collided with door UpdateCheckpoint(); //updating the checkpoint AudioManager.Instance.PlaySFX("NextLevel"); //playing sound effect } } public void UpdateCheckpoint() { levelNum += 1; //increasing the level number } void OnTriggerExit2D(Collider2D collision) { if (collision.CompareTag("Door")) { if(collision.gameObject == currentDoor) //if the player exits a door { currentDoor = null; //disabled the door } } } public void FinalLevelCheck() { if (levelNum == 11) //updating the finalLevelReached bool { finalLevelReached = true; } } }