using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class AnimatedDoorBehaviour : TriggerDoor { public GameObject SaveController; [SerializeField] public Gateway gateway; Animator animator; void Awake() { DoorOpenAnimatorParamName = "DoorOpen"; } // Start is called before the first frame update void Start() { animator = GetComponent(); gateway.currentMapName = SceneManager.GetActiveScene().name; } // Update is called once per frame void Update() { } private IEnumerator coroutine; private IEnumerator Wait(float waitTime) { while (true) { yield return new WaitForSeconds(waitTime); } } public void ScenetToMoveTo() { //coroutine = Wait(2.0f); //StartCoroutine(coroutine); animator.SetBool(DoorOpenAnimatorParamName, true); //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().SavePlayerEquipmentItems(); SaveController.GetComponent().SavePlayerQuests(); SaveController.GetComponent().SavePlayerInventory(); SaveController.GetComponent().SaveHealth(); SaveController.GetComponent().SaveChests(); SaveController.GetComponent().SaveShops(); SaveController.GetComponent().SaveDialogues(); SaveController.GetComponent().SaveMissions(); SaveController.GetComponent().SaveItemsOnMap(); // 2. Change scene SceneManager.LoadScene(gateway.nextMapName); } }