void HandleOnCellEnter(int destinationCellIndex)
 {
     if (!tank.isMoving && startCellIndex >= 0 && startCellIndex != destinationCellIndex)
     {
         // Clear existing path
         ClearPreviousPath();
         // Find a cell path between starting cell and destination cell, only over ground, at any altitude and with a maximum traversing cost of tank.maxSearchCost
         path = map.FindRoute(map.GetCell(startCellIndex), map.GetCell(destinationCellIndex), out pathCost, tank.terrainCapability, tank.maxSearchCost, tank.minAltitude, tank.maxAltitude);
         // If a path has been found, paint it!
         if (path != null)
         {
             ShowPathAndCosts(path);
         }
         else
         {
             // Otherwise, show it's not possible to reach that cell.
             Debug.Log("Cell #" + destinationCellIndex + " is not reachable from cell #" + startCellIndex);
         }
     }
 }
Esempio n. 2
0
 void HandleOnCountryEnter(int destinationCountryIndex, int regionIndex)
 {
     if (startCountryIndex >= 0 && startCountryIndex != destinationCountryIndex)
     {
         // Clear existing path
         Refresh();
         // Find a country path between starting country and destination country
         List <int> countriesInPath = map.FindRoute(map.GetCountry(startCountryIndex), map.GetCountry(destinationCountryIndex));
         // If a path has been found, paint it!
         if (countriesInPath != null)
         {
             countriesInPath.ForEach(countryIndex => map.ToggleCountrySurface(countryIndex, true, Color.grey));
         }
         else
         {
             // Otherwise, show it's not possible to reach that country.
             Debug.Log(map.countries[destinationCountryIndex].name + " is not reachable from " + map.countries[startCountryIndex].name + "! You may need to adjust the neighbours property of some countries to enable crossing.");
         }
     }
 }
        public void DemoRoute()
        {
            Vector2 cityStartRoute = map.GetCity("Madrid", "Spain").unity2DLocation;
            Vector2 cityEndRoute   = map.GetCity("Rome", "Italy").unity2DLocation;
            Cell    startCell      = map.GetCell(cityStartRoute);
            Cell    endCell        = map.GetCell(cityEndRoute);

            List <int> cellIndices = map.FindRoute(startCell, endCell, TERRAIN_CAPABILITY.OnlyGround);

            // Highlight cells in path
            map.CellBlink(cellIndices, Color.yellow, 4f);

            // Closer look
            map.FlyToLocation(cityStartRoute, 0.5f, 0.2f);
        }
 void HandleOnProvinceEnter(int destinationProvinceIndex, int regionIndex)
 {
     if (startProvinceIndex >= 0 && startProvinceIndex != destinationProvinceIndex)
     {
         // Clear existing path
         Refresh();
         // Find a province path between starting province and destination province
         List <int> provincesInPath = map.FindRoute(map.GetProvince(startProvinceIndex), map.GetProvince(destinationProvinceIndex));
         // If a path has been found, paint it!
         if (provincesInPath != null)
         {
             provincesInPath.ForEach(provinceIndex => map.ToggleProvinceSurface(provinceIndex, true, Color.grey));
         }
         else
         {
             // Otherwise, show it's not possible to reach that province.
             Debug.Log(map.provinces[destinationProvinceIndex].name + " is not reachable from " + map.provinces[startProvinceIndex].name + "! You may need to adjust the neighbours property of some provinces to enable crossing.");
         }
     }
 }