using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using System; using System.Diagnostics; using Debug = UnityEngine.Debug; public class ChangeScene : MonoBehaviour { float x, y, z; private Animator myanim; public void MoveToScene(int sceneID) { SceneManager.LoadScene(sceneID); } public void MoveToSceneFirst(int sceneID) { //Scene current = SceneManager.GetActiveScene(); //Debug.Log(PlayerPrefs.HasKey("HER")); if (!PlayerPrefs.HasKey("SceneSaved")) { SceneManager.LoadScene(5); } else { SceneManager.LoadScene(sceneID); } } void Start(){ } private void Awake() { } private void Update() { } private IEnumerator WaitForAnimationAndMoveToScene(float waitTime, Collision2D collision) { while (true) { yield return new WaitForSeconds(waitTime); collision.gameObject.GetComponent().ScenetToMoveTo(); } } // method is invoked only when script is assign to the player prefab object public void OnCollisionEnter2D(Collision2D collision) { if(collision.gameObject.tag == "SceneTransition" || collision.gameObject.tag == "AnimatedDoorSceneTransition") { if (collision.gameObject.GetComponent() != null && !collision.gameObject.GetComponent().isEnabled) { return; } if (collision.gameObject.GetComponent() != null && !collision.gameObject.GetComponent().isEnabled) { TriggerDoor.ableToOpen = false; return; } } if (collision.gameObject.tag == "SceneTransition") { collision.gameObject.GetComponent().ScenetToMoveTo(); } if (collision.gameObject.tag == "AnimatedDoorSceneTransition") { if (TriggerDoor.ableToOpen) { StartCoroutine(WaitForAnimationAndMoveToScene(0.3f, collision)); } } } }