public bool IsEastValid(GridLocation location) { if (location.GetX() == GetDungeonSize() - 1) { return(false); } TileSet tile = TileGrid[location.GetX(), location.GetZ()]; switch (tile) { case TileSet.EndEast: case TileSet.NorthEast: case TileSet.EastSouth: case TileSet.EastWest: case TileSet.NoNorth: case TileSet.NoSouth: case TileSet.NoWest: case TileSet.Cross: case TileSet.Room: return(true); default: return(false); } }
ArrayList CheckIfWestPossible(GridLocation location, ArrayList possibleTiles) { if (location.GetX() > 0 && TileGrid[location.GetX() - 1, location.GetZ()] != TileSet.Empty) { if (IsEastValid(new GridLocation(location.GetX() - 1, location.GetZ()))) { possibleTiles.Remove(TileSet.NorthEast); possibleTiles.Remove(TileSet.NorthSouth); possibleTiles.Remove(TileSet.EastSouth); possibleTiles.Remove(TileSet.NoWest); } else { possibleTiles.Remove(TileSet.NorthWest); possibleTiles.Remove(TileSet.EastWest); possibleTiles.Remove(TileSet.SouthWest); possibleTiles.Remove(TileSet.NoNorth); possibleTiles.Remove(TileSet.NoEast); possibleTiles.Remove(TileSet.NoSouth); possibleTiles.Remove(TileSet.Cross); possibleTiles.Remove(TileSet.Room); } } return(possibleTiles); }
ArrayList CheckIfNorthPossible(GridLocation location, ArrayList possibleTiles) { if (location.GetZ() < GetDungeonSize() - 1 && TileGrid[location.GetX(), location.GetZ() + 1] != TileSet.Empty) { if (IsSouthValid(new GridLocation(location.GetX(), location.GetZ() + 1))) { possibleTiles.Remove(TileSet.EastSouth); possibleTiles.Remove(TileSet.EastWest); possibleTiles.Remove(TileSet.SouthWest); possibleTiles.Remove(TileSet.NoNorth); } else { possibleTiles.Remove(TileSet.NorthEast); possibleTiles.Remove(TileSet.NorthSouth); possibleTiles.Remove(TileSet.NorthWest); possibleTiles.Remove(TileSet.NoEast); possibleTiles.Remove(TileSet.NoSouth); possibleTiles.Remove(TileSet.NoWest); possibleTiles.Remove(TileSet.Cross); possibleTiles.Remove(TileSet.Room); } } return(possibleTiles); }
public bool IsWestValid(GridLocation location) { if (location.GetX() == 0) { return(false); } TileSet tile = TileGrid[location.GetX(), location.GetZ()]; switch (tile) { case TileSet.EndWest: case TileSet.NorthWest: case TileSet.EastWest: case TileSet.SouthWest: case TileSet.NoNorth: case TileSet.NoEast: case TileSet.NoSouth: case TileSet.Cross: case TileSet.Room: return(true); default: return(false); } }
ArrayList CheckIfAtGridEdge(GridLocation location, ArrayList possibleTiles) { if (location.GetZ() == GetDungeonSize() - 1) { possibleTiles.Remove(TileSet.NorthEast); possibleTiles.Remove(TileSet.NorthSouth); possibleTiles.Remove(TileSet.NorthWest); possibleTiles.Remove(TileSet.NoEast); possibleTiles.Remove(TileSet.NoSouth); possibleTiles.Remove(TileSet.NoWest); possibleTiles.Remove(TileSet.Cross); possibleTiles.Remove(TileSet.Room); } if (location.GetX() == GetDungeonSize() - 1) { possibleTiles.Remove(TileSet.NorthEast); possibleTiles.Remove(TileSet.EastSouth); possibleTiles.Remove(TileSet.EastWest); possibleTiles.Remove(TileSet.NoNorth); possibleTiles.Remove(TileSet.NoSouth); possibleTiles.Remove(TileSet.NoWest); possibleTiles.Remove(TileSet.Cross); possibleTiles.Remove(TileSet.Room); } if (location.GetZ() == 0) { possibleTiles.Remove(TileSet.NorthSouth); possibleTiles.Remove(TileSet.EastSouth); possibleTiles.Remove(TileSet.SouthWest); possibleTiles.Remove(TileSet.NoNorth); possibleTiles.Remove(TileSet.NoEast); possibleTiles.Remove(TileSet.NoWest); possibleTiles.Remove(TileSet.Cross); possibleTiles.Remove(TileSet.Room); } if (location.GetX() == 0) { possibleTiles.Remove(TileSet.NorthWest); possibleTiles.Remove(TileSet.EastWest); possibleTiles.Remove(TileSet.SouthWest); possibleTiles.Remove(TileSet.NoNorth); possibleTiles.Remove(TileSet.NoEast); possibleTiles.Remove(TileSet.NoSouth); possibleTiles.Remove(TileSet.Cross); possibleTiles.Remove(TileSet.Room); } return(possibleTiles); }
public void SetSpecterLocation(GridLocation location) { SpecterLocation = location; float positionX = transform.position.x + (location.GetX() * GetTileSize()); float positionZ = transform.position.z + (location.GetZ() * GetTileSize()); Specter.transform.position = new Vector3(positionX, 1.0f, positionZ); }
void CreateLevel() { FillGrid(); PlaceObjects(); InitializeTiles(); SetAdventurerLocation(new GridLocation(StairsUpLocation.GetX(), StairsUpLocation.GetZ()), Quaternion.identity); SetSpecterLocation(new GridLocation(StairsDownLocation.GetX(), StairsDownLocation.GetZ())); Adventurer.SetKeyFound(false); Specter.StartWandering(); }
public void SetAdventurerLocation(GridLocation location, Quaternion direction) { AdventurerLocation = location; float positionX = transform.position.x + (location.GetX() * GetTileSize()); float positionZ = transform.position.z + (location.GetZ() * GetTileSize()); Adventurer.transform.position = new Vector3(positionX, 1.0f, positionZ); Adventurer.transform.rotation = direction; Camera.transform.position = new Vector3(positionX, 13.0f, positionZ); }
void InitializeOilCan(GridLocation location) { int oilCanGridX = location.GetX(); int oilCanGridZ = location.GetZ(); float oilCanLocationX = transform.position.x + (oilCanGridX * GetTileSize()); float oilCanLocationZ = transform.position.z + (oilCanGridZ * GetTileSize()); Transform createOilCan = (Transform)Instantiate(OilCan, new Vector3(oilCanLocationX, 0.9f, oilCanLocationZ), Quaternion.Euler(0, 180, 0)); OilCanLocation = new GridLocation(oilCanGridX, oilCanGridZ); createOilCan.parent = OilCanParent; }
void InitializeKey(GridLocation location) { int keyGridX = location.GetX(); int keyGridZ = location.GetZ(); float keyLocationX = transform.position.x + (keyGridX * GetTileSize()); float keyLocationZ = transform.position.z + (keyGridZ * GetTileSize()); Transform createKey = (Transform)Instantiate(Key, new Vector3(keyLocationX, 0.6f, keyLocationZ), Quaternion.Euler(0, 135, -90)); KeyLocation = new GridLocation(keyGridX, keyGridZ); createKey.parent = KeyParent; }
void InitializeStairsDown(GridLocation location) { int stairsDownGridX = location.GetX(); int stairsDownGridZ = location.GetZ(); float stairsDownLocationX = transform.position.x + (stairsDownGridX * GetTileSize()); float stairsDownLocationZ = transform.position.z + (stairsDownGridZ * GetTileSize()); Transform createStairsDown = (Transform)Instantiate(StairsDown, new Vector3(stairsDownLocationX, 0.6f, stairsDownLocationZ), Quaternion.identity); StairsDownLocation = new GridLocation(stairsDownGridX, stairsDownGridZ); createStairsDown.parent = StairsParent; }
bool IsTileConnected(int startLocationX, int startLocationZ, int endLocationX, int endLocationZ, ref ArrayList existingConnections) { ArrayList searchedList = new ArrayList(); ArrayList toSearchList = new ArrayList(); bool pathFound = false; bool searchCompleted = false; toSearchList.Add(new GridLocation(startLocationX, startLocationZ)); while (!searchCompleted) { if (toSearchList.Count == 0) { searchCompleted = true; break; } GridLocation toSearch = (GridLocation)toSearchList[0]; toSearchList.RemoveAt(0); if (searchedList.Contains(toSearch) == false) { searchedList.Add(toSearch); } if ((toSearch.GetX() == endLocationX && toSearch.GetZ() == endLocationZ) || existingConnections.Contains(toSearch)) { searchCompleted = true; pathFound = true; foreach (GridLocation position in searchedList) { existingConnections.Add(position); } foreach (GridLocation position in toSearchList) { existingConnections.Add(position); } break; } else { if (IsNorthValid(new GridLocation(toSearch.GetX(), toSearch.GetZ()))) { GridLocation newLocation = new GridLocation(toSearch.GetX(), toSearch.GetZ() + 1); if (toSearchList.Contains(newLocation) == false && searchedList.Contains(newLocation) == false) { toSearchList.Add(newLocation); } } if (IsEastValid(new GridLocation(toSearch.GetX(), toSearch.GetZ()))) { GridLocation newLocation = new GridLocation(toSearch.GetX() + 1, toSearch.GetZ()); if (toSearchList.Contains(newLocation) == false && searchedList.Contains(newLocation) == false) { toSearchList.Add(newLocation); } } if (IsSouthValid(new GridLocation(toSearch.GetX(), toSearch.GetZ()))) { GridLocation newLocation = new GridLocation(toSearch.GetX(), toSearch.GetZ() - 1); if (toSearchList.Contains(newLocation) == false && searchedList.Contains(newLocation) == false) { toSearchList.Add(newLocation); } } if (IsWestValid(new GridLocation(toSearch.GetX(), toSearch.GetZ()))) { GridLocation newLocation = new GridLocation(toSearch.GetX() - 1, toSearch.GetZ()); if (toSearchList.Contains(newLocation) == false && searchedList.Contains(newLocation) == false) { toSearchList.Add(newLocation); } } } } return(pathFound); }