void AttackCity() { bool newTargetCity = true; if (m_targetObj != null) { City targetCity = m_targetObj.GetComponent <City>(); if (targetCity.GetOwnerID() != m_playerAI.GetID()) { newTargetCity = false; } } if (newTargetCity) { if (m_playerAI.GetTargetPlayer() != null) { List <GameObject> targetCities = m_playerAI.GetTargetPlayer().GetCities(); City targetCity = null; foreach (GameObject city in targetCities) { if (targetCity == null) { targetCity = city.GetComponent <City>(); } else if (city.GetComponent <City>().GetCurrentHealth() < targetCity.GetCurrentHealth()) { targetCity = city.GetComponent <City>(); } } if (targetCity != null) { m_targetObj = targetCity.gameObject; m_targetTile = targetCity.GetOriginTile(); } } } if (m_targetObj != null) { List <Tile> nearbyTiles = Tile.GetTilesInRange(m_unit.GetCurrentTile(), m_unit.GetVisionRange()); foreach (Tile tile in nearbyTiles) { Unit unit = tile.GetUnitInTile(); if (unit != null) { if (unit.GetUnitType() == UnitType.CombatUnit) { if (unit.GetOwnerID() != m_playerAI.GetID()) { m_targetObj = unit.gameObject; m_targetTile = unit.GetCurrentTile(); break; } } } } m_unit.SetPath(m_playerAI.m_mapGrid.CreatePath(m_unit.GetCurrentTile(), m_targetTile, m_unit), m_targetTile); } }