Author Topic: Once a country is highlighted, you can only click on the neighbors. How to make?  (Read 34 times)

leonardoduarte

  • Newbie
  • *
  • Posts: 1
    • View Profile
Good Morning.
In my game, the player will start with a country of his choice and then he will be able to attack only one of his neighboring countries. For this, I need that after the initial country is clicked and the neighbors highlighted, it is only possible to click on those that make the border. I didn't find a function in the API that disables clicks on the rest of the map.
Can you help me?

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7565
    • View Profile
Hello!
Do you want to cancel highlight on the other countries (which are not neighbours)?

You can do so by using the OnCountryHighlight event, for example:


Code
...
map.OnCountryHighlight += OnCountryHighlight;
...
private void OnCountryHighlight(int countryIndex, int regionIndex, ref bool allowHighlight) {
    allowHighlight = <check if countryIndex is allowed here>;
}

In the OnCountryHighlight event, you place the code that checks if the countryIndex is valid for highlight and set the allowHighlight parameter to true or false accordingly.