public static Loadzone FindLoadzoneToSpawnAt(string sceneEnteredFrom, string currentSceneName) { var zones = GameObject.FindObjectsOfType <Loadzone>(); Loadzone loadZoneSpecifying = null; foreach (Loadzone zone in zones) { if (zone.loadSpecifiedRoomInsteadOfCardinal) { if (sceneEnteredFrom == zone.SceneToLoad) { loadZoneSpecifying = zone; } } else { string rnt = MapLayout.GetRoomNextTo(currentSceneName, zone.whichSideOfRoom); if (sceneEnteredFrom == rnt) { //GetOppositeCardinal(zone.whichSideOfRoom)) { return(zone); } } } return(loadZoneSpecifying); }
void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <PlayerCharacter>()) { if (loadSpecifiedRoomInsteadOfCardinal) { SceneSwitcher.Singleton().SwitchToScene(SceneToLoad); } else { string s = MapLayout.GetRoomNextTo(SceneManager.GetActiveScene().name, whichSideOfRoom); SceneSwitcher.Singleton().SwitchToScene(s); } SceneSwitcher.Singleton().PrepareToPlacePlayerAfterLoad(); } else { //Debug.Log("Non player character entered load zone"); } }