public Transform GetLocalSpawnTransform() { Transform spawnTransform = null; Transform defaultTransform = null; foreach (TeleportLocation tele in TeleportLocation.GetAll()) { if (tele != null && tele.spawnPtName.LastIndexOf(GameManager.Inst.LastLevel.ToString()) != -1) { spawnTransform = tele.gameObject.transform; } Door lastRoomDoor; if (spawnTransform == null && Door.GetDoorForReEntry(GameManager.Inst.LastLevel, GameManager.Inst.LastRoomID, out lastRoomDoor)) { if (teleportDoorLocationHelperGO == null) { teleportDoorLocationHelperGO = new GameObject("TeleportDoorLocationHelper"); DontDestroyOnLoad(teleportDoorLocationHelperGO); } teleportDoorLocationHelperGO.transform.rotation = lastRoomDoor.transform.rotation; teleportDoorLocationHelperGO.transform.position = lastRoomDoor.transform.position + 4f * lastRoomDoor.transform.forward; spawnTransform = teleportDoorLocationHelperGO.transform; } if (tele != null && defaultTransform == null && tele.spawnPtName.LastIndexOf('*') == tele.spawnPtName.Length - 1) { defaultTransform = tele.gameObject.transform; } } if (spawnTransform == null) { spawnTransform = defaultTransform != null ? defaultTransform : TeleportLocation.GetAll()[0].gameObject.transform; } return((avoidOtherUsersWhenSpawning) ? GetClosestTransformAvoidingPlayers(spawnTransform) : spawnTransform); }
public void DrawGUI(int x, int y) { if (!this.enabled) { return; } if (GameGUI.Inst.ButtonWithSound(new Rect(x, y, width, height), "Teleport")) { showList = !showList; } if (showList) { List <TeleportLocation> locations = TeleportLocation.GetAll(); for (int i = 0; i < locations.Count; ++i) { int verticalPos = Screen.height - height - ((height + spaceHeight) * (i + 1)); if (GameGUI.Inst.ButtonWithSound(new Rect(x, verticalPos, width, height), locations[i].name)) { GetComponent <PlayerManager>().SetLocalPlayerTransform(locations[i].transform); } } } }