Scriptum/Assets/Scripts/DoorBehaviour.cs

77 lines
2.8 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DoorBehaviour : MonoBehaviour
{
public GameObject SaveController;
[SerializeField]
public Gateway gateway;
[SerializeField]
public bool isEnabled = true;
// 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()
{
2023-01-07 23:46:54 +01:00
// Only for Dungeon & Dungeon Manger
if(gameObject.GetComponent<EntryEventObserver>() != null)
{
gameObject.GetComponent<EntryEventObserver>().LeveEventInfo();
}
//saving info about used gate/door/teleport
2022-12-06 01:20:01 +01:00
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
2022-12-04 18:42:34 +01:00
SaveController.GetComponent<SaveController>().SavePlayerEquipmentItems();
SaveController.GetComponent<SaveController>().SavePlayerQuests();
SaveController.GetComponent<SaveController>().SavePlayerInventory();
SaveController.GetComponent<SaveController>().SaveHealth();
2022-12-06 01:20:01 +01:00
SaveController.GetComponent<SaveController>().SaveChests();
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();
SaveController.GetComponent<SaveController>().SaveItemsOnMap();
// 2. Change scene
SceneManager.LoadScene(gateway.nextMapName);
// 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();
}
}