2022-05-10 22:54:04 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.SceneManagement;
|
2022-05-15 16:40:58 +02:00
|
|
|
using System;
|
2023-01-07 00:39:19 +01:00
|
|
|
using System.Diagnostics;
|
|
|
|
using Debug = UnityEngine.Debug;
|
2022-05-10 22:54:04 +02:00
|
|
|
|
|
|
|
public class ChangeScene : MonoBehaviour
|
|
|
|
{
|
2022-06-02 14:25:22 +02:00
|
|
|
float x, y, z;
|
2023-01-07 00:39:19 +01:00
|
|
|
private Animator myanim;
|
|
|
|
|
|
|
|
|
2022-12-10 02:24:32 +01:00
|
|
|
|
2022-05-10 22:54:04 +02:00
|
|
|
public void MoveToScene(int sceneID)
|
|
|
|
{
|
|
|
|
SceneManager.LoadScene(sceneID);
|
|
|
|
}
|
2022-05-15 16:40:58 +02:00
|
|
|
|
2023-01-07 00:39:19 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-12-10 02:24:32 +01:00
|
|
|
void Start(){
|
|
|
|
|
|
|
|
}
|
2023-01-07 00:39:19 +01:00
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-12-10 02:24:32 +01:00
|
|
|
private IEnumerator WaitForAnimationAndMoveToScene(float waitTime, Collision2D collision)
|
|
|
|
{
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
yield return new WaitForSeconds(waitTime);
|
2023-01-14 10:58:04 +01:00
|
|
|
|
2022-12-10 02:24:32 +01:00
|
|
|
collision.gameObject.GetComponent<DoorBehaviour>().ScenetToMoveTo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-02 18:45:58 +02:00
|
|
|
// method is invoked only when script is assign to the player prefab object
|
2022-05-15 16:40:58 +02:00
|
|
|
public void OnCollisionEnter2D(Collision2D collision)
|
|
|
|
{
|
2023-01-14 10:58:04 +01:00
|
|
|
if(collision.gameObject.tag == "SceneTransition" || collision.gameObject.tag == "AnimatedDoorSceneTransition")
|
|
|
|
{
|
|
|
|
if (collision.gameObject.GetComponent<DoorBehaviour>() != null && !collision.gameObject.GetComponent<DoorBehaviour>().isEnabled)
|
2023-01-10 23:55:41 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2023-01-14 10:58:04 +01:00
|
|
|
|
|
|
|
if (collision.gameObject.GetComponent<AnimatedDoorBehaviour>() != null && !collision.gameObject.GetComponent<AnimatedDoorBehaviour>().isEnabled)
|
2023-01-10 21:20:48 +01:00
|
|
|
{
|
2023-01-14 10:58:04 +01:00
|
|
|
TriggerDoor.ableToOpen = false;
|
2023-01-10 21:20:48 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-15 14:13:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (collision.gameObject.tag == "SceneTransition")
|
|
|
|
{
|
2022-10-02 18:45:58 +02:00
|
|
|
collision.gameObject.GetComponent<DoorBehaviour>().ScenetToMoveTo();
|
2023-01-15 14:13:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (collision.gameObject.tag == "AnimatedDoorSceneTransition")
|
2022-12-10 02:24:32 +01:00
|
|
|
{
|
2023-01-07 00:39:19 +01:00
|
|
|
if (TriggerDoor.ableToOpen)
|
|
|
|
{
|
2022-12-10 02:24:32 +01:00
|
|
|
StartCoroutine(WaitForAnimationAndMoveToScene(0.3f, collision));
|
2023-01-07 00:39:19 +01:00
|
|
|
}
|
2022-12-10 02:24:32 +01:00
|
|
|
}
|
2022-05-15 16:40:58 +02:00
|
|
|
}
|
2023-01-07 00:39:19 +01:00
|
|
|
}
|