/// <summary> /// When the user attempts to change rooms, the WorldManager is check to see if this is allowed. If so then the /// co-ordinates of the room are gotten and the player's location is changed to that.</summary> void OnTriggerStay2D(Collider2D other) { if (other.gameObject.tag == "Player") { if (GameManager.inst.WorldManager.canGoTo(roomToGoTo)) { other.transform.position = RoomLocations.getRoomCoords(roomToGoTo); } } }
void CheckPlayersWaiting() { curPlayerCount = GetComponent<GameManager>().playerCount; if (playersGoingBottom.Count >= curPlayerCount - 1) { SendPlayersToBottomRoom(); currentRoomLocation = RoomLocations.Bottom; SubObjectiveCheck_OnRoomChanged(); if (!roomSubObjectiveAccomplishedArray[(int)currentRoomLocation]) { BottomRoomDoorArrow.SetActive(true); } if(GhostAI != null) GhostAI.GetComponent<GhostAI>().currentRoom = GetComponent<RoomGenerator>().BottomBaseRoomPiece; } else if (playersGoingLeft.Count >= curPlayerCount - 1) { SendPlayersToLeftRoom(); currentRoomLocation = RoomLocations.Left; SubObjectiveCheck_OnRoomChanged(); if (!roomSubObjectiveAccomplishedArray[(int)currentRoomLocation]) { LeftRoomDoorArrow.SetActive(true); } if (GhostAI != null) GhostAI.GetComponent<GhostAI>().currentRoom = GetComponent<RoomGenerator>().LeftBaseRoomPiece; } else if (playersGoingRight.Count >= curPlayerCount - 1) { SendPlayersToRightRoom(); currentRoomLocation = RoomLocations.Right; SubObjectiveCheck_OnRoomChanged(); if (!roomSubObjectiveAccomplishedArray[(int)currentRoomLocation]) { RightRoomDoorArrow.SetActive(true); } if (GhostAI != null) GhostAI.GetComponent<GhostAI>().currentRoom = GetComponent<RoomGenerator>().RightBaseRoomPiece; } else if (playersGoingBack.Count >= curPlayerCount - 1) { SendPlayersToCenterRoom(currentRoomLocation); currentRoomLocation = RoomLocations.Center; SubObjectiveCheck_OnRoomChanged(); if (!roomSubObjectiveAccomplishedArray[(int)currentRoomLocation]) { foreach (GameObject go in CenterRoomDoorArrows) { go.SetActive(true); } } if (GhostAI != null) GhostAI.GetComponent<GhostAI>().currentRoom = GetComponent<RoomGenerator>().MainBaseRoomPiece; } }
private void SendPlayersToCenterRoom(RoomLocations roomPosition) { foreach (GameObject player in playersGoingBack) { Vector3 curRoomPosition = GetComponent<RoomGenerator>().MainBaseRoomPiece.transform.position; switch(roomPosition){ case RoomLocations.Left: player.transform.position = new Vector2(curRoomPosition.x - 10, Random.Range(curRoomPosition.y - 2, curRoomPosition.y + 2)); player.GetComponent<Rigidbody2D>().AddForce(-Vector2.left * 300); break; case RoomLocations.Bottom: player.transform.position = new Vector2(Random.Range(curRoomPosition.x - 2, curRoomPosition.x + 2), curRoomPosition.y - 6); player.GetComponent<Rigidbody2D>().AddForce(Vector2.up * 300); break; case RoomLocations.Right: player.transform.position = new Vector2(curRoomPosition.x + 10, Random.Range(curRoomPosition.y - 2, curRoomPosition.y + 2)); player.GetComponent<Rigidbody2D>().AddForce(Vector2.left * 300); break; } //player.transform.position = curRoomPosition; GetComponent<GameManager>().currentGhostPlayer.transform.position = curRoomPosition; } }
void FadeInDoors(RoomLocations currentRoom) { string doorID = "(" + currentRoom.ToString() + ")"; foreach (GameObject obj in doorSprites) { if (obj.name.Contains(doorID)) { obj.GetComponent<SpriteRenderer>().enabled = true; obj.GetComponent<SpriteRenderer>().color += new Color(0f, 0f, 0f, DoorFadeIncrement); if (obj.GetComponent<SpriteRenderer>().color.a >= 1f) obj.GetComponent<EdgeCollider2D>().enabled = false; } } if (!HasMadeRoomSound[(int)currentRoom]) { HasMadeRoomSound[(int)currentRoom] = true; soundManager.SOUND_MAN.playSound("Play_DoorOpen", gameObject); } }
void EnableGhostBarriers(RoomLocations room) { string searchString = ""; switch(room) { case RoomLocations.Bottom: searchString = "Bottom"; break; case RoomLocations.Center: searchString = "Center"; break; case RoomLocations.Left: searchString = "Left"; break; case RoomLocations.Right: searchString = "Right"; break; default: break; } foreach(GameObject door in doorSprites) { if (door.name.Contains(searchString)) { if (door.name != "SouthDoor_Left(Center)" && door.name != "SouthDoor_Left(Bottom)") { Transform ghostbarrier = door.transform.Find("GhostBarrier").GetComponent<Transform>(); if (ghostbarrier != null) { EdgeCollider2D[] edges = ghostbarrier.GetComponents<EdgeCollider2D>(); foreach (EdgeCollider2D edge in edges) edge.enabled = true; } } } } }