/// <summary> /// Highlights any units that must be attacked this turn. Returns true if it finds units /// The shouldHighlight flag is needed because if being called by the AI units shouldn't be highlighted /// </summary> /// <param name="attackingNationality"></param> /// <param name="hex"></param> /// <param name="shouldHighlight"></param> private static bool HighlightUnitsThatMustBeAttacked(GlobalDefinitions.Nationality attackingNationality, GameObject hex, bool shouldHighlight) { bool foundUnit = false; foreach (HexDefinitions.HexSides hexSide in Enum.GetValues(typeof(HexDefinitions.HexSides))) { if ((hex.GetComponent <HexDatabaseFields>().Neighbors[(int)hexSide] != null) && (hex.GetComponent <HexDatabaseFields>().Neighbors[(int)hexSide].GetComponent <BooleanArrayData>().exertsZOC[GlobalDefinitions.ReturnHexSideOpposide((int)hexSide)] == true) && (hex.GetComponent <HexDatabaseFields>().Neighbors[(int)hexSide].GetComponent <HexDatabaseFields>().occupyingUnit.Count > 0) && (hex.GetComponent <HexDatabaseFields>().Neighbors[(int)hexSide].GetComponent <HexDatabaseFields>().occupyingUnit[0].GetComponent <UnitDatabaseFields>().nationality != attackingNationality)) { foreach (GameObject unit in hex.GetComponent <HexDatabaseFields>().Neighbors[(int)hexSide].GetComponent <HexDatabaseFields>().occupyingUnit) { if (!unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack) { foundUnit = true; if (shouldHighlight) { GlobalDefinitions.HighlightUnit(unit); } } } } } // Need to do a special case check here for being on a sea hex, the invasion target will be a mustBeAttacked even if it is a fortress if (hex.GetComponent <HexDatabaseFields>().sea&& hex.GetComponent <HexDatabaseFields>().invasionTarget.GetComponent <HexDatabaseFields>().fortress) { // Any units in a fortress that has units attacking from the sea will should be attacked foreach (GameObject unit in hex.GetComponent <HexDatabaseFields>().invasionTarget.GetComponent <HexDatabaseFields>().occupyingUnit) { if (!unit.GetComponent <UnitDatabaseFields>().isCommittedToAnAttack) { foundUnit = true; if (shouldHighlight) { GlobalDefinitions.HighlightUnit(unit); } } } } return(foundUnit); }