45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using System;
|
|
|
|
public class ChangeScene : MonoBehaviour
|
|
{
|
|
float x, y, z;
|
|
|
|
public void MoveToScene(int sceneID)
|
|
{
|
|
SceneManager.LoadScene(sceneID);
|
|
}
|
|
|
|
void Start(){
|
|
|
|
}
|
|
|
|
private IEnumerator WaitForAnimationAndMoveToScene(float waitTime, Collision2D collision)
|
|
{
|
|
while (true)
|
|
{
|
|
yield return new WaitForSeconds(waitTime);
|
|
collision.gameObject.GetComponent<DoorBehaviour>().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.GetComponent<DoorBehaviour>().ScenetToMoveTo();
|
|
}
|
|
if(collision.gameObject.tag == "AnimatedDoorSceneTransition")
|
|
{
|
|
Debug.Log("Starting coroutine");
|
|
StartCoroutine(WaitForAnimationAndMoveToScene(0.3f, collision));
|
|
}
|
|
}
|
|
}
|