2022-05-15 16:40:58 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
public class DoorBehaviour : MonoBehaviour
|
|
|
|
{
|
2022-06-19 02:56:04 +02:00
|
|
|
public GameObject SaveController;
|
2022-10-01 15:39:24 +02:00
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
public Gateway gateway;
|
|
|
|
|
2023-01-10 21:20:48 +01:00
|
|
|
[SerializeField]
|
|
|
|
public bool isEnabled = true;
|
|
|
|
|
2022-05-15 16:40:58 +02:00
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
2022-12-13 02:28:49 +01:00
|
|
|
gateway.currentMapName = SceneManager.GetActiveScene().name;
|
2022-05-15 16:40:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-12-10 02:24:32 +01:00
|
|
|
public static IEnumerator Wait()
|
|
|
|
{
|
|
|
|
yield return new WaitForSeconds(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-15 16:40:58 +02:00
|
|
|
public void ScenetToMoveTo()
|
|
|
|
{
|
2023-01-07 23:46:54 +01:00
|
|
|
// Only for Dungeon & Dungeon Manger
|
|
|
|
if(gameObject.GetComponent<EntryEventObserver>() != null)
|
|
|
|
{
|
|
|
|
gameObject.GetComponent<EntryEventObserver>().LeveEventInfo();
|
|
|
|
}
|
|
|
|
|
2022-10-01 15:39:24 +02:00
|
|
|
//saving info about used gate/door/teleport
|
2022-12-06 01:20:01 +01:00
|
|
|
OnMapAppearanceMethod.SetTeleportedStatus();
|
2022-10-01 15:39:24 +02:00
|
|
|
|
|
|
|
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
|
2022-12-04 18:42:34 +01:00
|
|
|
SaveController.GetComponent<SaveController>().SavePlayerEquipmentItems();
|
|
|
|
SaveController.GetComponent<SaveController>().SavePlayerQuests();
|
|
|
|
SaveController.GetComponent<SaveController>().SavePlayerInventory();
|
2022-10-01 19:28:26 +02:00
|
|
|
SaveController.GetComponent<SaveController>().SaveHealth();
|
2023-01-15 13:48:26 +01:00
|
|
|
SaveController.GetComponent<SaveController>().SaveAccountBalance();
|
2022-11-24 03:48:23 +01:00
|
|
|
|
2022-12-06 01:20:01 +01:00
|
|
|
SaveController.GetComponent<SaveController>().SaveChests();
|
2022-12-19 03:34:45 +01:00
|
|
|
SaveController.GetComponent<SaveController>().SaveShops();
|
2023-01-02 00:05:47 +01:00
|
|
|
SaveController.GetComponent<SaveController>().SaveDialogues();
|
2023-01-03 22:44:24 +01:00
|
|
|
SaveController.GetComponent<SaveController>().SaveMissions();
|
2022-12-19 03:34:45 +01:00
|
|
|
|
2023-01-06 03:44:07 +01:00
|
|
|
SaveController.GetComponent<SaveController>().SaveItemsOnMap();
|
|
|
|
|
2022-06-19 02:56:04 +02:00
|
|
|
// 2. Change scene
|
2022-10-01 19:28:26 +02:00
|
|
|
SceneManager.LoadScene(gateway.nextMapName);
|
2023-01-10 04:21:36 +01:00
|
|
|
|
|
|
|
// 3. Save additional controls
|
|
|
|
SkillsUIManager.Instance.keyToOpen = (KeyCode) System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("Skills"));
|
|
|
|
DisplayExpStatus.keyToExp = (KeyCode) System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("EXP HEALTH"));
|
|
|
|
DisplayHealthStatus.keyToHealth = (KeyCode) System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("EXP HEALTH"));
|
|
|
|
DisplayExpStatus.keyToExp = (KeyCode) System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("ExpHlth"));
|
|
|
|
DisplayHealthStatus.keyToHealth = (KeyCode) System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("ExpHlth"));
|
|
|
|
PlayerPrefs.Save();
|
2022-05-15 16:40:58 +02:00
|
|
|
}
|
|
|
|
}
|