public static void switchScene(Vector2 dir, bool clearDoorLabel = false) { GameObject player = gameManager.Instance.player; AtlasScene fromScene = getScene(); AtlasScene toScene = getNeighborWithCoords(getPlayerCoords() + dir); if (toScene == null || toScene.scene == "null") { return; } Vector2 d = (toScene.size + fromScene.size) * 0.5f; Vector2 t = (fromScene.getCenter() - toScene.getCenter()) * -SCREEN_HEIGHT; float startx = 0; float starty = 0; if (dir.x != 0) { startx = (toScene.size.x * SCREEN_WIDTH * 0.5f - 0.3f) * -dir.x; starty = player.transform.position.y + t.y; } else { startx = player.transform.position.x + t.x; starty = (toScene.size.y * SCREEN_HEIGHT * 0.5f - 0.4f) * dir.y; } if (clearDoorLabel) { gameManager.Instance.currentDoorLabel = "none"; } gameManager.Instance.switchScene(toScene.scene, startx, starty); }
static void loadScene() { List <AtlasScene> neighbors = AtlasSceneManager.getNeighbors(); AtlasScene currentScene = AtlasSceneManager.getScene(); foreach (AtlasScene n in neighbors) { if (n.scene != "null") { EditorSceneManager.OpenScene("Assets/Scenes/WorldMap/" + n.scene + ".unity", OpenSceneMode.Additive); Vector2 d = (n.size + currentScene.size) * 0.5f; Vector2 t = (n.getCenter() - currentScene.getCenter()); shiftScene(n.scene, t.x, -t.y); } } }