public OpenDoors(Room.PlayerExit exit) { //Doing multi-line assignment because I am lazy switch (exit) { case Room.PlayerExit.TOP: Top = true; Right = Left = Bottom = false; break; case Room.PlayerExit.BOTTOM: Bottom = true; Right = Left = Top = false; break; case Room.PlayerExit.LEFT: Left = true; Right = Top = Bottom = false; break; case Room.PlayerExit.RIGHT: Right = true; Top = Left = Bottom = false; break; default: Left = Right = Top = Bottom = false; break; } }
public static List <Room.PlayerExit> GetMeaningfulExits(this Room.PlayerExit exit) { List <Room.PlayerExit> toReturn = new List <Room.PlayerExit>(); var opposite = exit.GetOppositeExit(); foreach (var temp in (Room.PlayerExit[])Enum.GetValues(typeof(Room.PlayerExit))) { if (temp != opposite) { toReturn.Add(temp); } } return(toReturn); }
public static List <Room.PlayerExit> GetOtherExits(this Room.PlayerExit exit) { //TODO: Return here if you add a NONE direction List <Room.PlayerExit> toReturn = new List <Room.PlayerExit>(); foreach (var temp in (Room.PlayerExit[])Enum.GetValues(typeof(Room.PlayerExit))) { if (temp != exit) { toReturn.Add(temp); } } return(toReturn); }
void MovePlayer(Room.PlayerExit exit) { if (elapsed >= secondsBetweenRoomMoves) { elapsed = 0; var pos = player.transform.position; if (exit == Room.PlayerExit.TOP || exit == Room.PlayerExit.BOTTOM) { pos.y *= -1; } else if (exit == Room.PlayerExit.LEFT || exit == Room.PlayerExit.RIGHT) { pos.x *= -1; } Debug.Log("Moving player to position: " + pos); player.transform.position = pos; OnPlayerTransported.Invoke(exit); } }
public static char GetLetter(this Room.PlayerExit exit) { switch (exit) { case Room.PlayerExit.TOP: return('U'); case Room.PlayerExit.BOTTOM: return('D'); case Room.PlayerExit.LEFT: return('L'); case Room.PlayerExit.RIGHT: return('R'); default: return('*'); } }
public static Room.PlayerExit GetOppositeExit(this Room.PlayerExit exit) { switch (exit) { case Room.PlayerExit.TOP: return(Room.PlayerExit.BOTTOM); case Room.PlayerExit.BOTTOM: return(Room.PlayerExit.TOP); case Room.PlayerExit.LEFT: return(Room.PlayerExit.RIGHT); case Room.PlayerExit.RIGHT: return(Room.PlayerExit.LEFT); default: return(Room.PlayerExit.TOP); } }
public bool IsOpen(Room.PlayerExit door) { switch (door) { case Room.PlayerExit.TOP: return(Top); case Room.PlayerExit.BOTTOM: return(Bottom); case Room.PlayerExit.LEFT: return(Left); case Room.PlayerExit.RIGHT: return(Right); default: return(false); } }
public static Vector2Int GetAddition(this Room.PlayerExit direction) { Vector2Int move = new Vector2Int(0, 0); if (direction == Room.PlayerExit.TOP) { move.y = 1; } else if (direction == Room.PlayerExit.BOTTOM) { move.y = -1; } else if (direction == Room.PlayerExit.LEFT) { move.x = -1; } else if (direction == Room.PlayerExit.RIGHT) { move.x = 1; } return(move); }
public void OpenDoor(Room.PlayerExit door) { switch (door) { case Room.PlayerExit.TOP: Top = true; break; case Room.PlayerExit.BOTTOM: Bottom = true; break; case Room.PlayerExit.LEFT: Left = true; break; case Room.PlayerExit.RIGHT: Right = true; break; default: break; } }
public static Vector2Int Adjust(this Vector2Int origin, Room.PlayerExit direction) { return(origin + direction.GetAddition()); }
public static Vector2Int AddRoom(this Dictionary <Vector2Int, OpenDoors> grid, Vector2Int position, Room.PlayerExit direction) { if (!grid.ContainsKey(position)) { OpenDoors doors = new OpenDoors(); doors.OpenDoor(direction); grid.Add(position, doors); } else { var doors = grid[position]; doors.OpenDoor(direction); grid[position] = doors; } var newPosition = position + GetAddition(direction); var oppositeDirection = direction.GetOppositeExit(); if (!grid.ContainsKey(newPosition)) { OpenDoors newDoors = new OpenDoors(oppositeDirection); grid.Add(newPosition, newDoors); } else { var doors = grid[newPosition]; doors.OpenDoor(oppositeDirection); grid[newPosition] = doors; } //Debug.Log("" + position + ": " + direction + ": " + newPosition); return(newPosition); }
void InstantiateNewRoom(Room.PlayerExit direction) { Debug.Log(direction); GetNewRoom(currentLocation.Adjust(direction)); }