59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class DoorBehaviour : MonoBehaviour
|
|
{
|
|
public static DoorBehaviour Instance;
|
|
|
|
public GameObject SaveController;
|
|
|
|
[SerializeField]
|
|
public Gateway gateway;
|
|
|
|
private void Awake()
|
|
{
|
|
if(Instance == null)
|
|
{
|
|
Instance = this;
|
|
}else if (Instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void ScenetToMoveTo()
|
|
{
|
|
//saving info about used gate/door/teleport
|
|
OnMapAppearanceMethod.Gateway = OnMapAppearanceMethodEnum.Gateway;
|
|
|
|
PlayerPrefs.SetString("gateway.sourceMapName", gateway.currentMapName);
|
|
PlayerPrefs.SetString("gateway.nextMapName", gateway.nextMapName);
|
|
|
|
PlayerPrefs.SetFloat("gateway.respawnCoords.x", gateway.respawnCoords.x);
|
|
PlayerPrefs.SetFloat("gateway.respawnCoords.y", gateway.respawnCoords.y);
|
|
PlayerPrefs.SetFloat("gateway.respawnCoords.z", gateway.respawnCoords.z);
|
|
|
|
// 1. Save all before change scene
|
|
SaveController.GetComponent<SaveController>().SaveItems();
|
|
SaveController.GetComponent<SaveController>().SaveQuests();
|
|
SaveController.GetComponent<SaveController>().SaveInventory();
|
|
SaveController.GetComponent<SaveController>().SaveHealth();
|
|
// 2. Change scene
|
|
SceneManager.LoadScene(gateway.nextMapName);
|
|
}
|
|
}
|