/// <summary> /// This method creates the list of all the AStar pathnodes. /// </summary> public static void GeneratePathfindingOverlay() { foreach (Vector3 graphNode in aStar.GraphNodes) { Vector3Int graphNodePosOnGrid = grid.WorldToCell(graphNode); RangeOverlayTiles.Add(graphNodePosOnGrid); } }
/// <summary> /// This method draws an overlay tile on the Unit's tile position, this is meant for spells that can be casted on the caster. /// </summary> /// <param name="selectedTilePos"></param> private static void DrawSelfOverlay(Vector3Int selectedTilePos) { if (floorsTilemap.HasTile(selectedTilePos)) { RangeOverlayTiles.Add(selectedTilePos); } rangeOverlayTilemap.SetTile(RangeOverlayTiles[0], confirmedTile); }
/// <summary> /// This method draws a square overlay. /// </summary> /// <param name="selectedTilePos"></param> /// <param name="range"></param> private static void DrawSquareOverlay(Vector3Int selectedTilePos, int range) { for (int x = 0; x <= range; x++) { for (int y = 0; y <= range; y++) { Vector3Int tile = new Vector3Int(selectedTilePos.x + x, selectedTilePos.y + y, 0); if (floorsTilemap.HasTile(tile)) { RangeOverlayTiles.Add(tile); } } } for (int x = 0; x <= range; x++) { for (int y = 0; y <= range; y++) { Vector3Int tile = new Vector3Int(selectedTilePos.x + x, selectedTilePos.y - y, 0); if (floorsTilemap.HasTile(tile)) { RangeOverlayTiles.Add(tile); } } } for (int x = 0; x <= range; x++) { for (int y = 0; y <= range; y++) { Vector3Int tile = new Vector3Int(selectedTilePos.x - x, selectedTilePos.y + y, 0); if (floorsTilemap.HasTile(tile)) { RangeOverlayTiles.Add(tile); } } } for (int x = 0; x <= range; x++) { for (int y = 0; y <= range; y++) { Vector3Int tile = new Vector3Int(selectedTilePos.x - x, selectedTilePos.y - y, 0); if (floorsTilemap.HasTile(tile)) { RangeOverlayTiles.Add(tile); } } } }
/// <summary> /// This method is going to draw a "diamond" shape overlay. /// </summary> /// <param name="selectedTilePos"></param> /// <param name="range"></param> private static void DrawDiamondOverlay(Vector3Int selectedTilePos, int range) { if (range > 0) { for (int x = 0; x <= range; x++) { for (int y = 0; y <= range - x; y++) { Vector3Int tile = new Vector3Int(selectedTilePos.x + x, selectedTilePos.y + y, 0); if (floorsTilemap.HasTile(tile) && !RangeOverlayTiles.Contains(tile)) { RangeOverlayTiles.Add(tile); } } } for (int x = 0; x <= range; x++) { for (int y = 0; y <= range - x; y++) { Vector3Int tile = new Vector3Int(selectedTilePos.x + x, selectedTilePos.y - y, 0); if (floorsTilemap.HasTile(tile) && !RangeOverlayTiles.Contains(tile)) { RangeOverlayTiles.Add(tile); } } } for (int x = 0; x <= range; x++) { for (int y = 0; y <= range - x; y++) { Vector3Int tile = new Vector3Int(selectedTilePos.x - x, selectedTilePos.y + y, 0); if (floorsTilemap.HasTile(tile) && !RangeOverlayTiles.Contains(tile)) { RangeOverlayTiles.Add(tile); } } } for (int x = 0; x <= range; x++) { for (int y = 0; y <= range - x; y++) { Vector3Int tile = new Vector3Int(selectedTilePos.x - x, selectedTilePos.y - y, 0); if (floorsTilemap.HasTile(tile) && !RangeOverlayTiles.Contains(tile)) { RangeOverlayTiles.Add(tile); } } } } else { Vector3Int tile = new Vector3Int(selectedTilePos.x, selectedTilePos.y, 0); if (floorsTilemap.HasTile(tile)) { RangeOverlayTiles.Add(tile); } } }
/// <summary> /// This method is going to draw a "+" overlay according to a certain range. /// </summary> /// <param name="selectedTilePos"></param> /// <param name="range"></param> private static void DrawCrossOverlay(Vector3Int selectedTilePos, int range) { for (int i = 0; i <= range; i++) { Vector3Int tile = new Vector3Int(selectedTilePos.x + i, selectedTilePos.y, 0); if (!RangeOverlayTiles.Contains(tile)) { if (floorsTilemap.HasTile(tile) && !CheckIfWall(tile) || !floorsTilemap.HasTile(tile) && CheckIfPit(tile) || !floorsTilemap.HasTile(tile) && CheckIfVoid(tile)) { RangeOverlayTiles.Add(tile); } else { break; } } } for (int i = 0; i <= range; i++) { Vector3Int tile = new Vector3Int(selectedTilePos.x, selectedTilePos.y + i, 0); if (!RangeOverlayTiles.Contains(tile)) { if (floorsTilemap.HasTile(tile) && !CheckIfWall(tile) || !floorsTilemap.HasTile(tile) && CheckIfPit(tile) || !floorsTilemap.HasTile(tile) && CheckIfVoid(tile)) { RangeOverlayTiles.Add(tile); } else { break; } } } for (int i = 0; i <= range; i++) { Vector3Int tile = new Vector3Int(selectedTilePos.x - i, selectedTilePos.y, 0); if (!RangeOverlayTiles.Contains(tile)) { if (floorsTilemap.HasTile(tile) && !CheckIfWall(tile) || !floorsTilemap.HasTile(tile) && CheckIfPit(tile) || !floorsTilemap.HasTile(tile) && CheckIfVoid(tile)) { RangeOverlayTiles.Add(tile); } else { break; } } } for (int i = 0; i <= range; i++) { Vector3Int tile = new Vector3Int(selectedTilePos.x, selectedTilePos.y - i, 0); if (!RangeOverlayTiles.Contains(tile)) { if (floorsTilemap.HasTile(tile) && !CheckIfWall(tile) || !floorsTilemap.HasTile(tile) && CheckIfPit(tile) || !floorsTilemap.HasTile(tile) && CheckIfVoid(tile)) { RangeOverlayTiles.Add(tile); } else { break; } } } }