internal void UpdateGridHighlightedness() { foreach (GameObject go in highlightRectangles) { GameObject.Destroy(go); } highlightRectangles.Clear(); foreach (S_Tile tile in allTiles) { tile.SetHighlight(false); } S_Ability activeAbility = abilityPanel.activeAbility; if (activeAbility != null) { //bunch of long codey bits because it's paperwork to do this sort of thing in unity it seems switch (activeAbility.GetTargetingType()) { case S_Ability.TargetingType.Line: foreach (S_Tile tile in activeAbility.GetValidTiles(player.currentTile)) { int baseWidth = tile.x - player.currentTile.x; int baseHeight = tile.y - player.currentTile.y; int rWidth = baseWidth == 0 ? 1 : baseWidth; int rHeight = baseHeight == 0 ? 1 : baseHeight; rWidth *= S_Tile.height; rHeight *= S_Tile.width; rWidth += -S_Camera.scale * Util.ProperSign(rWidth); rHeight += -S_Camera.scale * Util.ProperSign(rHeight); GameObject go = Primitives.CreateRectangle(rWidth, rHeight, S_Camera.scale, Colours.LIGHT); Util.SetLayerContainer(go, Util.LayerName.Entities, 5); S_Tile origin = player.currentTile; if (baseWidth > 0) { origin = origin.GetTile(1, 0); } else if (baseHeight > 0) { origin = origin.GetTile(0, 1); } go.transform.position = new Vector2(origin.transform.position.x + (baseWidth < 0 ? -S_Camera.scale : 0), origin.transform.position.y + (baseHeight < 0 ? -S_Camera.scale : 0)); highlightRectangles.Add(go); go.transform.SetParent(Game.GetMisc("effects").transform); } break; case S_Ability.TargetingType.SingleTile: foreach (S_Tile tile in activeAbility.GetValidTiles(player.currentTile)) { tile.SetHighlight(true); } break; } } }
public List <S_Tile> GetTilesInLine(int dx, int dy, bool includeSelf = false) { List <S_Tile> result = new List <S_Tile>(); if (includeSelf) { result.Add(this); } S_Tile tile = GetTile(dx, dy); while (tile != null) { result.Add(tile); tile = tile.GetTile(dx, dy); } return(result); }