Scriptum/Assets/Scripts/DoorBehaviour.cs
2023-01-06 03:44:07 +01:00

60 lines
1.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DoorBehaviour : MonoBehaviour
{
public GameObject SaveController;
[SerializeField]
public Gateway gateway;
// Start is called before the first frame update
void Start()
{
gateway.currentMapName = SceneManager.GetActiveScene().name;
}
// Update is called once per frame
void Update()
{
}
public static IEnumerator Wait()
{
yield return new WaitForSeconds(2);
}
public void ScenetToMoveTo()
{
//saving info about used gate/door/teleport
OnMapAppearanceMethod.SetTeleportedStatus();
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>().SavePlayerEquipmentItems();
SaveController.GetComponent<SaveController>().SavePlayerQuests();
SaveController.GetComponent<SaveController>().SavePlayerInventory();
SaveController.GetComponent<SaveController>().SaveHealth();
SaveController.GetComponent<SaveController>().SaveChests();
SaveController.GetComponent<SaveController>().SaveShops();
SaveController.GetComponent<SaveController>().SaveDialogues();
SaveController.GetComponent<SaveController>().SaveMissions();
SaveController.GetComponent<SaveController>().SaveItemsOnMap();
// 2. Change scene
SceneManager.LoadScene(gateway.nextMapName);
}
}