void ShowMoveRange() { int cellIndex = map.GetCellIndex(tank.currentMap2DLocation); if (cellIndex < 0) { return; } List <int> cells = tank.GetCellNeighbours(); map.CellBlink(cells, Color.blue, 1f); }
void Start() { // UI Setup - non-important, only for this demo labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleLeft; labelStyle.normal.textColor = Color.white; labelStyleShadow = new GUIStyle(labelStyle); labelStyleShadow.normal.textColor = Color.black; buttonStyle = new GUIStyle(labelStyle); buttonStyle.alignment = TextAnchor.MiddleCenter; buttonStyle.normal.background = Texture2D.whiteTexture; buttonStyle.normal.textColor = Color.black; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); // WMSK setup map = WMSK.instance; map.OnCellClick += HandleOnCellClick; map.OnCellEnter += HandleOnCellEnter; // Focus on Berlin City city = map.GetCity("Berlin", "Germany"); map.FlyToCity(city, 1f, 0.1f); // Creates a tank and positions it on the center of the hexagonal cell which contains Berlin Cell startCell = map.GetCell(city.unity2DLocation); DropTankOnPosition(startCell.center); startCellIndex = map.GetCellIndex(startCell); // Paint some country costs PaintCountries(); }
/// <summary> /// Creates a country with a name and list of cell columns and rows. /// </summary> /// <returns>The country index.</returns> int CreateHexCountry(string name, int[,] cells) { // 1) Create the empty country int countryIndex = map.CountryCreate("My country", "Continent"); // 2) Add cells to the country, building its frontiers for (int k = 0; k < cells.Length / 2; k++) { int cellIndex = map.GetCellIndex(cells[k, 0], cells[k, 1]); map.CountryTransferCell(countryIndex, cellIndex, false); // false = don't redraw because we'll redraw only once when all cells are added } // 3) Update the map map.Redraw(); return(countryIndex); }