public override void markAoEPattern(Vector2i root) { TileMarker tileMarker = TileMarker.Instance; //grenade is radius 1, so simply mark the 5 tiles manually rather than iterating if (!tileMarker.attackTiles.ContainsKey(root)) { tileMarker.addAttackTile(root); } if (!tileMarker.attackTiles.ContainsKey(new Vector2i(root.x - 1, root.y))) { tileMarker.addAttackTile(new Vector2i(root.x - 1, root.y)); } if (!tileMarker.attackTiles.ContainsKey(new Vector2i(root.x + 1, root.y))) { tileMarker.addAttackTile(new Vector2i(root.x + 1, root.y)); } if (!tileMarker.attackTiles.ContainsKey(new Vector2i(root.x, root.y - 1))) { tileMarker.addAttackTile(new Vector2i(root.x, root.y - 1)); } if (!tileMarker.attackTiles.ContainsKey(new Vector2i(root.x, root.y + 1))) { tileMarker.addAttackTile(new Vector2i(root.x, root.y + 1)); } }
public override void markAoEPattern(Vector2i root) // root is redundant (always this weapon's unit) { TileMarker tileMarker = TileMarker.Instance; int range = Mathf.Max((int)(unit.combatEnergyAtk * 0.5f), 3); // minimum beam size is 3x3 (length extendable) if (root == new Vector2i(unit.pos.x - 1, unit.pos.y) || unit.pos.x - root.x > 1) { // mark beam to left of unit direction = new Vector2i(-1, 0); root = unit.pos; for (int j = -1; j <= 1; j++) { if (unit.pos.y + j < 0 || unit.pos.y + j > MapScript.Instance.mapHeight) { continue; // don't process tiles outside of map } for (int i = Mathf.Max(root.x - range, 0); i < root.x; i++) { tileMarker.addAttackTile(new Vector2i(i, root.y + j)); } } } else if (root == new Vector2i(unit.pos.x + 1, unit.pos.y) || unit.pos.x - root.x < -1) { // mark beam to right of unit direction = new Vector2i(1, 0); root = unit.pos; for (int j = -1; j <= 1; j++) { if (unit.pos.y + j < 0 || unit.pos.y + j > MapScript.Instance.mapHeight) { continue; // don't process tiles outside of map } for (int i = Mathf.Min(root.x + range, MapScript.Instance.mapHeight); i > root.x; i--) { tileMarker.addAttackTile(new Vector2i(i, root.y + j)); } } } else if (root == new Vector2i(unit.pos.x, unit.pos.y + 1) || unit.pos.y - root.y < -1) { // mark beam above unit direction = new Vector2i(0, 1); root = unit.pos; for (int j = -1; j <= 1; j++) { if (unit.pos.x + j < 0 || unit.pos.x + j > MapScript.Instance.mapWidth) { continue; // don't process tiles outside of map } for (int i = Mathf.Min(root.y + range, MapScript.Instance.mapHeight); i > root.y; i--) { tileMarker.addAttackTile(new Vector2i(root.x + j, i)); } } } else if (root == new Vector2i(unit.pos.x, unit.pos.y - 1) || unit.pos.y - root.y > 1) { // mark beam below unit direction = new Vector2i(0, -1); root = unit.pos; for (int j = -1; j <= 1; j++) { if (unit.pos.x + j < 0 || unit.pos.x + j > MapScript.Instance.mapHeight) { continue; // don't process tiles outside of map } for (int i = Mathf.Max(root.y - range, 0); i < root.y; i++) { tileMarker.addAttackTile(new Vector2i(root.x + j, i)); } } } }
// marks PURPLE TILES of all possible coverages for selection public override void markAoEAim(Vector2i root) { TileMarker tileMarker = TileMarker.Instance; unit.calcCombatStats(); int range = Mathf.Max((int)(unit.combatEnergyAtk * 0.5f), 3); // minimum beam size is 3x3 (length extendable) // mark left beam for (int i = -1; i <= 1; i++) { if (unit.pos.y + i < 0 || unit.pos.y + i > MapScript.Instance.mapHeight) { continue; // don't process tiles outside of map } for (int j = Mathf.Max(root.x - range, 0); j < root.x; j++) { Vector2i mark = new Vector2i(j, root.y + i); if (mark.Distance(unit.pos) == 2 && mark.x != unit.pos.x && mark.y != unit.pos.y) { if (!tileMarker.attackTiles.ContainsKey(mark)) { //tiles directly diagonal to unit are ambiguous; mark with attack tile instead of AoE tileMarker.addAttackTile(mark); } } else { tileMarker.addAoETile(mark); } } } // mark right beam for (int i = -1; i <= 1; i++) { if (unit.pos.y + i < 0 || unit.pos.y + i > MapScript.Instance.mapHeight) { continue; // don't process tiles outside of map } for (int j = Mathf.Min(root.x + range, MapScript.Instance.mapWidth); j > root.x; j--) { Vector2i mark = new Vector2i(j, root.y + i); if (mark.Distance(unit.pos) == 2 && mark.x != unit.pos.x && mark.y != unit.pos.y) { //tiles directly diagonal to unit are ambiguous; mark with attack tile instead of AoE if (!tileMarker.attackTiles.ContainsKey(mark)) { //tiles directly diagonal to unit are ambiguous; mark with attack tile instead of AoE tileMarker.addAttackTile(mark); } } else { tileMarker.addAoETile(mark); } } } // mark up beam for (int i = -1; i <= 1; i++) // i represents x now instead of y { if (unit.pos.x + i < 0 || unit.pos.x + i > MapScript.Instance.mapWidth) { continue; // don't process tiles outside of map } for (int j = Mathf.Min(root.y + 1, MapScript.Instance.Width); j <= root.y + range; j++) { Vector2i mark = new Vector2i(root.x + i, j); if (mark.Distance(unit.pos) == 2 && mark.x != unit.pos.x && mark.y != unit.pos.y) { if (!tileMarker.attackTiles.ContainsKey(mark)) { //tiles directly diagonal to unit are ambiguous; mark with attack tile instead of AoE tileMarker.addAttackTile(mark); } } else { tileMarker.addAoETile(mark); } } } // mark down beam for (int i = -1; i <= 1; i++) // i represents x now instead of y { if (unit.pos.x + i < 0 || unit.pos.x + i > MapScript.Instance.mapWidth) { continue; // don't process tiles outside of map } for (int j = Mathf.Max(root.y - 1, 0); j >= root.y - range; j--) { Vector2i mark = new Vector2i(root.x + i, j); if (mark.Distance(unit.pos) == 2 && mark.x != unit.pos.x && mark.y != unit.pos.y) { if (!tileMarker.attackTiles.ContainsKey(mark)) { //tiles directly diagonal to unit are ambiguous; mark with attack tile instead of AoE tileMarker.addAttackTile(mark); } } else { tileMarker.addAoETile(mark); } } } }
public override void markAoEPattern(Vector2i root) // root is redundant (always this weapon's unit) { TileMarker tileMarker = TileMarker.Instance; //mark all diagonal tiles from unit Vector2i curr = new Vector2i(unit.pos.x - 1, unit.pos.y + 1); // up left while (curr.x >= 0 && curr.y < MapScript.Instance.mapHeight) { if (curr.Distance(unit.pos) > max) { // keep track of maximum distance attack max = curr.Distance(unit.pos); } tileMarker.addAttackTile(curr); curr.x--; curr.y++; } // up right curr = new Vector2i(unit.pos.x + 1, unit.pos.y + 1); while (curr.x < MapScript.Instance.mapWidth && curr.y < MapScript.Instance.mapHeight) { if (curr.Distance(unit.pos) > max) { // keep track of maximum distance attack max = curr.Distance(unit.pos); } tileMarker.addAttackTile(curr); curr.x++; curr.y++; } // down left curr = new Vector2i(unit.pos.x - 1, unit.pos.y - 1); while (curr.x >= 0 && curr.y >= 0) { if (curr.Distance(unit.pos) > max) { // keep track of maximum distance attack max = curr.Distance(unit.pos); } tileMarker.addAttackTile(curr); curr.x--; curr.y--; } // down right curr = new Vector2i(unit.pos.x + 1, unit.pos.y - 1); while (curr.x < MapScript.Instance.mapWidth && curr.y >= 0) { if (curr.Distance(unit.pos) > max) { // keep track of maximum distance attack max = curr.Distance(unit.pos); } tileMarker.addAttackTile(curr); curr.x++; curr.y--; } }