/// <summary> /// This function is hooked at Start() function and will be called when user clicks on a cell /// </summary> /// <param name="cellIndex">Cell index.</param> /// <param name="button">Mouse button index.</param> void CellClicked(int cellIndex, int button) { // if cell already is contained by country then cancel Vector2 cellCenter = map.GetCellPosition(cellIndex); int c = map.GetCountryIndex(cellCenter); if (c == countryIndex) { return; } // Transfer cell to the country shape map.CountryTransferCell(countryIndex, cellIndex, true); // true = redraw // Recolor the country so any new separated region gets the same color map.ToggleCountrySurface(countryIndex, true, countryColor); }
void ShowPathAndCosts(List <int> path) { int steps = path.Count; Color pathColor = new Color(0.5f, 0.5f, 0, 0.5f); for (int k = 1; k < steps; k++) // ignore step 0 since this is current tank cell { int cellIndex = path [k]; // Color path cells map.SetCellTemporaryColor(cellIndex, pathColor); // Show the accumulated cost int accumCost = map.GetCellPathCost(cellIndex); Vector3 cellPosition = map.GetCellPosition(cellIndex); TextMesh text = map.AddMarker2DText(accumCost.ToString(), cellPosition); text.transform.localScale *= 0.3f; // make font smaller texts.Add(text); } }