void Start() { // Get a reference to the World Map API: map = WMSK.instance; // Get a reference to the viewport gameobject (we'll enable/disable it when changing modes) viewport = GameObject.Find("Viewport"); // Get the material of the fade plane fadePlane = Camera.main.transform.Find("FadePlane").gameObject; fadeMaterial = fadePlane.GetComponent <Renderer>().sharedMaterial; // UI Setup - non-important, only for this demo buttonStyle = new GUIStyle(); buttonStyle.alignment = TextAnchor.MiddleCenter; buttonStyle.normal.background = Texture2D.whiteTexture; buttonStyle.normal.textColor = Color.white; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); map.CenterMap(); // Create tank kathmanduLocation = map.GetCity("Kathmandu", "Nepal").unity2DLocation; beijingLocation = map.GetCity("Beijing", "China").unity2DLocation; tank = DropTankOnPosition(kathmanduLocation); // Start movement tank.MoveTo(beijingLocation, 0.1f); tank.OnMoveEnd += (anim) => SwitchDestination(); }
void Start() { // Get a reference to the World Map API: map = WMSK.instance; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); // Get list of European countries europeanCountries = new List <Country>(); for (int k = 0; k < map.countries.Length; k++) { Country country = map.countries[k]; if (country.continent.Equals("Europe")) { europeanCountries.Add(country); // Distribute countries between 2 players if (country.center.x < 0.04f) { country.attrib["player"] = 1; } else { country.attrib["player"] = 2; } } } // Colors player1Color = new Color(1, 0.5f, 0, 0.65f); player2Color = new Color(0, 0.5f, 1, 0.65f); // Setup map rect map.windowRect = new Rect(-0.0587777f, 0.1964018f, 0.1939751f, 0.1939751f); map.SetZoomLevel(0.1939751f); map.CenterMap(); // Paint countries PaintCountries(); // Drop our tester tank DropTankOnCity(); // On map click listener map.OnClick += (float x, float y, int buttonIndex) => { if (enableToggleOwnership) { ChangeCountryOwnerShip(x, y); } else if (enableClickToMoveTank) { MoveTankWithPathFinding(new Vector2(x, y)); } }; // Enable custom cost path finding matrix (we'll setup this matrix when moving the unit) map.pathFindingEnableCustomRouteMatrix = true; UpdatePathFindingMatrixCost(); }
void Start() { // Get a reference to the World Map API: map = WMSK.instance; // UI Setup - non-important, only for this demo labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.normal.textColor = Color.white; labelStyleShadow = new GUIStyle(labelStyle); labelStyleShadow.normal.textColor = Color.black; buttonStyle = new GUIStyle(labelStyle); buttonStyle.alignment = TextAnchor.MiddleLeft; buttonStyle.normal.background = Texture2D.whiteTexture; buttonStyle.normal.textColor = Color.white; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); /* Register events: this is optionally but allows your scripts to be informed instantly as the mouse enters or exits a country, province or city */ map.OnCityEnter += (int cityIndex) => Debug.Log("Entered city " + map.cities[cityIndex].name); map.OnCityExit += (int cityIndex) => Debug.Log("Exited city " + map.cities[cityIndex].name); map.OnCityClick += (int cityIndex, int buttonIndex) => Debug.Log("Clicked city " + map.cities[cityIndex].name); map.OnCountryEnter += (int countryIndex, int regionIndex) => Debug.Log("Entered country " + map.countries[countryIndex].name); map.OnCountryExit += (int countryIndex, int regionIndex) => Debug.Log("Exited country " + map.countries[countryIndex].name); map.OnCountryClick += (int countryIndex, int regionIndex, int buttonIndex) => Debug.Log("Clicked country " + map.countries[countryIndex].name); map.OnProvinceEnter += (int provinceIndex, int regionIndex) => Debug.Log("Entered province " + map.provinces[provinceIndex].name); map.OnProvinceExit += (int provinceIndex, int regionIndex) => Debug.Log("Exited province " + map.provinces[provinceIndex].name); map.OnProvinceClick += (int provinceIndex, int regionIndex, int buttonIndex) => Debug.Log("Clicked province " + map.provinces[provinceIndex].name); map.OnClick += (float x, float y, int buttonIndex) => MakeClick(x, y); map.CenterMap(); map.gridColumns = 300; map.gridRows = 300; map.showGrid = true; // Example: how to clear a group of cells inside a country // map.OnClick += (float x, float y, int buttonIndex) => { // List<int> cells = map.GetCellsInCountry(map.GetCountryIndex("Spain")); // map.FogOfWarSetCells(cells, 0.1f); // }; }
void Start() { // Get a reference to the World Map API: map = WMSK.instance; // UI Setup - non-important, only for this demo labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.normal.textColor = Color.white; labelStyleShadow = new GUIStyle(labelStyle); labelStyleShadow.normal.textColor = Color.black; buttonStyle = new GUIStyle(labelStyle); buttonStyle.alignment = TextAnchor.MiddleLeft; buttonStyle.normal.background = Texture2D.whiteTexture; buttonStyle.normal.textColor = Color.white; colorPicker = gameObject.GetComponent <ColorPicker>(); sliderStyle = new GUIStyle(); sliderStyle.normal.background = Texture2D.whiteTexture; sliderStyle.fixedHeight = 4.0f; sliderThumbStyle = new GUIStyle(); sliderThumbStyle.normal.background = Resources.Load <Texture2D>("GUI/thumb"); sliderThumbStyle.overflow = new RectOffset(0, 0, 8, 0); sliderThumbStyle.fixedWidth = 20.0f; sliderThumbStyle.fixedHeight = 12.0f; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); /* Register events: this is optionally but allows your scripts to be informed instantly as the mouse enters or exits a country, province or city */ map.OnCityEnter += (int cityIndex) => Debug.Log("Entered city " + map.cities[cityIndex].name); map.OnCityExit += (int cityIndex) => Debug.Log("Exited city " + map.cities[cityIndex].name); map.OnCityClick += (int cityIndex, int buttonIndex) => Debug.Log("Clicked city " + map.cities[cityIndex].name); map.OnCountryEnter += (int countryIndex, int regionIndex) => Debug.Log("Entered country " + map.countries[countryIndex].name); map.OnCountryExit += (int countryIndex, int regionIndex) => Debug.Log("Exited country " + map.countries[countryIndex].name); map.OnCountryClick += (int countryIndex, int regionIndex, int buttonIndex) => Debug.Log("Clicked country " + map.countries[countryIndex].name); map.OnProvinceEnter += (int provinceIndex, int regionIndex) => Debug.Log("Entered province " + map.provinces[provinceIndex].name); map.OnProvinceExit += (int provinceIndex, int regionIndex) => Debug.Log("Exited province " + map.provinces[provinceIndex].name); map.OnProvinceClick += (int provinceIndex, int regionIndex, int buttonIndex) => Debug.Log("Clicked province " + map.provinces[provinceIndex].name); map.CenterMap(); }
float timeOfDay = 0.0f; // in hours (0-23.99) void Start() { // Get a reference to the World Map API: map = WMSK.instance; // UI Setup - non-important, only for this demo labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.normal.textColor = Color.white; labelStyleShadow = new GUIStyle(labelStyle); labelStyleShadow.normal.textColor = Color.black; buttonStyle = new GUIStyle(labelStyle); buttonStyle.alignment = TextAnchor.MiddleLeft; buttonStyle.normal.background = Texture2D.whiteTexture; buttonStyle.normal.textColor = Color.white; sliderStyle = new GUIStyle(); sliderStyle.normal.background = Texture2D.whiteTexture; sliderStyle.fixedHeight = 4.0f; sliderThumbStyle = new GUIStyle(); sliderThumbStyle.normal.background = Resources.Load <Texture2D> ("GUI/thumb"); sliderThumbStyle.overflow = new RectOffset(0, 0, 8, 0); sliderThumbStyle.fixedWidth = 20.0f; sliderThumbStyle.fixedHeight = 12.0f; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); map.CenterMap(); // Instantiate game object and position it instantly over the city GameObject tower = Instantiate(Resources.Load <GameObject> ("Tower/Tower")); Vector2 position = map.GetCity("Lhasa", "China").unity2DLocation; tower.WMSK_MoveTo(position); // Zoom in map.FlyToLocation(position, 1f, 0.1f); }
void Start() { // Get a reference to the World Map API: map = WMSK.instance; // UI Setup - non-important, only for this demo labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.normal.textColor = Color.white; labelStyleShadow = new GUIStyle(labelStyle); labelStyleShadow.normal.textColor = Color.black; buttonStyle = new GUIStyle(labelStyle); buttonStyle.alignment = TextAnchor.MiddleLeft; buttonStyle.normal.background = Texture2D.whiteTexture; buttonStyle.normal.textColor = Color.white; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); map.OnClick += (float x, float y, int buttonIndex) => { if (enableAddTowerOnClick) { AddTowerAtPosition(x, y); } else if (enableClickToMoveTank) { MoveTankWithPathFinding(new Vector2(x, y)); } else if (enableClickToMoveShip && ship != null) { // as ship has terrainCapability set to Water the MoveTo() method will use path finding to route the ship to destination. MoveShipToDestination(new Vector2(x, y), 0.1f); } }; map.CenterMap(); }
// The map can be moved and scaled at will void ToggleMinimize() { minimizeState = !minimizeState; Camera.main.transform.position = Misc.Vector3back * 1.1f; Camera.main.transform.rotation = Quaternion.Euler(Misc.Vector3zero); if (minimizeState) { map.earthStyle = EARTH_STYLE.Alternate2; map.earthColor = Color.black; map.longitudeStepping = 4; map.latitudeStepping = 40; map.showCities = false; map.showCountryNames = false; map.showFrontiers = false; map.imaginaryLinesColor = new Color(0.06f, 0.23f, 0.398f); map.fitWindowWidth = false; map.fitWindowHeight = false; map.gameObject.transform.localScale = new Vector3(0.4f, 0.2f, 1f); map.gameObject.transform.position = new Vector3(0.9f, -0.5f, 0); } else { map.gameObject.transform.localScale = new Vector3(200, 100, 1f); map.CenterMap(); map.earthStyle = EARTH_STYLE.Natural; map.longitudeStepping = 15; map.latitudeStepping = 15; map.showCities = true; map.showCountryNames = true; map.showFrontiers = true; map.imaginaryLinesColor = new Color(0.16f, 0.33f, 0.498f); map.fitWindowWidth = true; map.fitWindowHeight = true; } }
void Start() { // Get a reference to the World Map API: map = WMSK.instance; // UI Setup - non-important, only for this demo labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.normal.textColor = Color.white; labelStyleShadow = new GUIStyle(labelStyle); labelStyleShadow.normal.textColor = Color.black; buttonStyle = new GUIStyle(labelStyle); buttonStyle.alignment = TextAnchor.MiddleLeft; buttonStyle.normal.background = Texture2D.whiteTexture; buttonStyle.normal.textColor = Color.white; sliderStyle = new GUIStyle(); sliderStyle.normal.background = Texture2D.whiteTexture; sliderStyle.fixedHeight = 4.0f; sliderThumbStyle = new GUIStyle(); sliderThumbStyle.normal.background = Resources.Load <Texture2D>("GUI/thumb"); sliderThumbStyle.overflow = new RectOffset(0, 0, 8, 0); sliderThumbStyle.fixedWidth = 20.0f; sliderThumbStyle.fixedHeight = 12.0f; // Prepare line texture lineMaterialAerial = Instantiate(Resources.Load <Material>("PathLine/aerialPath")); lineMaterialGround = Instantiate(Resources.Load <Material>("PathLine/groundPath")); // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); // plug our mouse click listener - it will be used to move the tank to target destination map.OnClick += (float x, float y, int buttonIndex) => { if (enableClickToMoveTank) { MoveTankWithPathFinding(new Vector2(x, y)); } }; // plug our mouse move listener - it received the x,y map position of the mouse map.OnMouseMove += (float x, float y) => { // while tank is moving avoid showing paths if (tank.isMoving) { return; } // if show linear path is enabled, then just show a straight (or curved line if arc elevation is specified) from tank to destination if (showLinearPath) { UpdateLinearPathLine(x, y); } else { // show route path is enabled, then we'll compute the path and draw a line that pass through those points UpdateRoutePathLine(x, y); } }; map.CenterMap(); // Drop the tank on the Tibet DropTankOnCity(); }