/// <summary> /// Creates a tank instance and adds it to specified city /// </summary> void DropTankOnCity() { // Get a random big city int cityIndex = map.GetCityIndex("Paris", "France"); // Get city location Vector2 cityPosition = map.cities [cityIndex].unity2DLocation; if (tank != null) { DestroyImmediate(tank.gameObject); } tank = DropTankOnPosition(cityPosition); // Zoom into tank map.FlyToLocation(cityPosition, 2.0f, 0.15f); // Enable move on click in this demo enableAddTowerOnClick = false; enableClickToMoveShip = false; enableClickToMoveTank = true; // Finally, signal me when tank starts and stops tank.OnMoveStart += (thisTank) => Debug.Log("Tank has starting moving to " + thisTank.destination + " location."); tank.OnMoveEnd += (thisTank) => Debug.Log("Tank has stopped at " + thisTank.currentMap2DLocation + " location."); tank.OnCountryEnter += (thisTank) => Debug.Log("Tank has entered country " + map.GetCountry(thisTank.currentMap2DLocation).name + "."); tank.OnProvinceEnter += (thisTank) => Debug.Log("Tank has entered province " + map.GetProvince(thisTank.currentMap2DLocation).name + "."); }
void BuildRoad() { int city1Index = map.GetCityIndex("Berlin", "Germany"); int city2Index = map.GetCityIndex("Paris", "France"); // Get starting and end cell Cell cell1 = map.GetCell(map.GetCity(city1Index).unity2DLocation); Cell cell2 = map.GetCell(map.GetCity(city2Index).unity2DLocation); // Get the path List <int> cellIndices = map.FindRoute(cell1, cell2, TERRAIN_CAPABILITY.OnlyGround); if (cellIndices == null) { return; } // Highlight road cells map.CellBlink(cellIndices, new Color(1, 1, 0.5f, 0.5f), 1f); // Get coordinates for the path int positionsCount = cellIndices.Count; Vector2[] positions = new Vector2[positionsCount]; for (int k = 0; k < positionsCount; k++) { positions [k] = map.cells [cellIndices [k]].center; } // Build a road along the map coordinates LineMarkerAnimator lma = map.AddLine(positions, Color.white, 0, 0.1f); lma.lineMaterial.mainTexture = roadTexture; lma.lineMaterial.mainTextureScale = new Vector2(8f, 1f); // Apply reduced costs to hex sides crossed by the road for (int k = 1; k < positionsCount; k++) { map.PathFindingCellSetSideCost(cellIndices [k - 1], cellIndices [k], 1); } }
/// <summary> /// Creates a tank instance and adds it to specified city /// </summary> void DropTankOnCity() { // Get a random big city int cityIndex = map.GetCityIndex("Paris", "France"); // Get city location Vector2 cityPosition = map.cities[cityIndex].unity2DLocation; GameObject tankGO = Instantiate(Resources.Load<GameObject>("Tank/CompleteTank")); tank = tankGO.WMSK_MoveTo(cityPosition); tank.autoRotation = true; tank.terrainCapability = TERRAIN_CAPABILITY.OnlyGround; // Set tank ownership tank.attrib["player"] = 1; }
/// <summary> /// Creates a tank instance and adds it to specified city /// </summary> void DropTankOnCity() { // Get a random big city int cityIndex = map.GetCityIndex("Lhasa", "China"); // Get city location Vector2 cityPosition = map.cities[cityIndex].unity2DLocation; if (tank != null) { DestroyImmediate(tank); } GameObject tankGO = Instantiate(Resources.Load <GameObject>("Tank/CompleteTank")); tank = tankGO.WMSK_MoveTo(cityPosition); tank.type = (int)UNIT_TYPE.TANK; tank.autoRotation = true; tank.terrainCapability = TERRAIN_CAPABILITY.OnlyGround; // Zoom into tank map.FlyToLocation(cityPosition, 2.0f, 0.15f); }