/// <summary> /// Get all the neighbours of a tile that monsters can travel to /// </summary> /// <param name="tileMap">Tile map to query</param> /// <param name="source">Tile to query for neighbors</param> /// <returns>Array of tiles neighbors</returns> static private Vector3Int[] getNeighbors(Dictionary <Vector3Int, TDTileType> tileMap, Vector3Int source) { #if UNITY_EDITOR Assert.IsTrue(tileMap.ContainsKey(source)); #endif List <Vector3Int> neighbors = new List <Vector3Int>(); for (int i = 0; i < moveDirs.Length; ++i) { Vector3Int tileIndex = source + moveDirs[i]; if (!tileMap.ContainsKey(tileIndex)) { continue; } TDTileType tile = tileMap[tileIndex]; if (!canTravelTo(tile)) { continue; } neighbors.Add(tileIndex); } return(neighbors.ToArray()); }
/// <summary> /// Get if monsters could travel to this tile /// </summary> /// <param name="tileType">Type of the tile</param> /// <returns>If monster can travel to tile</returns> static private bool canTravelTo(TDTileType tileType) { return(tileType == TDTileType.Path || tileType == TDTileType.Spawn); }