public void ColorTiles(List <Tile> tiles, Tile.TileColor color) { foreach (var t in tiles) { t.SetTileColor(color); } }
public List <Tile> GetActionRange(Action action) { List <Tile> totalRange = map.GetTilesInRange(activeUnit.CurrentTile, action.Range); List <Tile> adjustedRange = new List <Tile>(); Tile.TileColor color = action.Target == Target.Self || action.Target == Target.Ally ? Tile.TileColor.ally : Tile.TileColor.attack; foreach (var t in totalRange) { if (t.UnitOnTile == null) { adjustedRange.Add(t); } else if (t.UnitOnTile == activeUnit && (action.Target == Target.Self || action.Target == Target.Ally)) { adjustedRange.Add(t); } else if (t.UnitOnTile.PlayerNumber == activeUnit.PlayerNumber && action.Target == Target.Ally) { adjustedRange.Add(t); } else if (t.UnitOnTile.PlayerNumber != activeUnit.PlayerNumber && action.Target == Target.Enemy) { adjustedRange.Add(t); } else if (action.Target == Target.Everyone) { adjustedRange.Add(t); } } return(adjustedRange); }
public void ShowActionRange(Action action) { List <Tile> inRange = GetActionRange(action); Tile.TileColor color = (action.Target == Target.Self || action.Target == Target.Ally) ? Tile.TileColor.ally : Tile.TileColor.attack; foreach (var t in inRange) { t.SetTileColor(color); } }
public void UpdateDisplay(int strength = 1, Tile.TileColor color = Tile.TileColor.VALID) { // TODO: Draw arrows tile.SelectDisplay(strength, color); }
//show hovered Unit UI public void HoveredUI(Unit unit) { if (unit.PlayerNumber == 0) { highlightedUnit.GetComponent <Image>().color = new Color32(74, 81, 161, 141); } else { highlightedUnit.GetComponent <Image>().color = new Color32(144, 42, 42, 141); } if (highlightedUnit.activeSelf == false) { highlightedUnit.SetActive(true); highlightedUnitText.text = ""; highlightedUnitTextInfo.text = ""; float currentHP = unit.GetMaxHP() - unit.GetDamage(); highlightedUnitTextInfo.text = " Current HP: " + currentHP; List <ModuleType> list = unit.GetModuleTypes(); if (unit.getUnitType() == UnitType.fighter) { highlightedFrigate.gameObject.SetActive(false); highlightedFrigateEnemy.gameObject.SetActive(false); highlightedUnitText.text = "Fighter"; if (unit.PlayerNumber == 0) { highlightedFighter.gameObject.SetActive(true); highlightedFighterEnemy.gameObject.SetActive(false); } else { highlightedFighter.gameObject.SetActive(false); highlightedFighterEnemy.gameObject.SetActive(true); } } else if (unit.getUnitType() == UnitType.frigate) { highlightedFighter.gameObject.SetActive(false); highlightedFighterEnemy.gameObject.SetActive(false); highlightedUnitText.text = "Frigate"; if (unit.PlayerNumber == 0) { highlightedFrigate.gameObject.SetActive(true); highlightedFrigateEnemy.gameObject.SetActive(false); } else { highlightedFrigate.gameObject.SetActive(false); highlightedFrigateEnemy.gameObject.SetActive(true); } } if (unit.BossUnit == true) { highlightedUnitText.text = "BOSS"; } List <Action> actionsList = unit.GetActions(); List <ModuleType> modList = unit.GetModuleTypes(); string modstr = ""; foreach (ModuleType mod in modList) { if (mod == ModuleType.shortRange) { modstr += "Short Range"; modstr += " "; } else if (mod == ModuleType.longRange) { modstr += "Long Range"; modstr += " "; } else if (mod == ModuleType.heal) { modstr += "Heal"; modstr += " "; } else if (mod == ModuleType.slow) { modstr += "Slow"; modstr += " "; } } highlightedUnitTextInfo.text += " Type: " + unit.GetShipType() + "\n Mods: " + modstr; if (actionState) { List <Action> actions = activeUnit.GetActions(); Action action = null; ActionType chosenAction = ActionType.Slow; if (actionChosen == 0) { chosenAction = ActionType.LongAttack; } else if (actionChosen == (ActionChosen)1) { chosenAction = ActionType.MeleeAttack; } else if (actionChosen == (ActionChosen)2) { chosenAction = ActionType.Heal; } int power = 0; foreach (Action a in actions) { if (a.Type == chosenAction) { power = a.Power; action = a; break; } } List <Tile> inRange = GetActionRange(action); Tile.TileColor color = (action.Target == Target.Self || action.Target == Target.Ally) ? Tile.TileColor.ally : Tile.TileColor.attack; bool testUnit = false; foreach (var t in inRange) { if (t.gameObject.name == unit.CurrentTile.gameObject.name) { testUnit = true; break; } } if (testUnit) { float expectedHealthHeal = currentHP + power; float expectedHealthDmg = currentHP - power; if (expectedHealthHeal > unit.GetMaxHP()) { expectedHealthHeal = unit.GetMaxHP(); } if (expectedHealthDmg < 0) { expectedHealthDmg = 0; } if (actionChosen == ActionChosen.heal) { highlightedUnitTextInfo.text = " Action = Heal\n New HP: " + expectedHealthHeal + " (" + currentHP + " + " + power + ")\n Max HP: " + unit.GetMaxHP(); } else if (actionChosen == ActionChosen.slow) { highlightedUnitTextInfo.text = " Action = Slow\n Target's move distance will be decreased"; } else if (actionChosen == ActionChosen.shortRange) { highlightedUnitTextInfo.text = " Action = Short Range\n New HP: " + expectedHealthDmg + " (" + currentHP + " - " + power + ")"; } else if (actionChosen == ActionChosen.longRange) { highlightedUnitTextInfo.text = " Action = Long Range\n New HP: " + expectedHealthDmg + " (" + currentHP + " - " + power + ")"; } } } } else { highlightedUnit.SetActive(false); } }