void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.5f);

            // Start a new path
            if (GUI.Button(new Rect(10, 10, 90, 30), "  Random Path", buttonStyle))
            {
                NewPath();
            }

            // Slider to show the travel progress
            GUI.Button(new Rect(150, 10, 90, 30), "  Progress", buttonStyle);
            float prevProgress = progress;

            GUI.backgroundColor = Color.white;
            progress            = GUI.HorizontalSlider(new Rect(250, 20, 200, 35), progress, 0, 1, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.5f);

            if (progress != prevProgress)
            {
                anim.MoveTo(progress);
            }
        }
Exemplo n.º 2
0
        void OnGUI()
        {
            GUIResizer.AutoResize();
            GUI.Label(new Rect(10, 10, 350, 30), "Click and drag over the Earth to paint", labelStyle);

            enableRotation        = GUI.Toggle(new Rect(10, 40, 350, 30), enableRotation, "Enable Earth rotation");
            map.allowUserRotation = enableRotation;

            GUI.Label(new Rect(10, 70, 85, 30), "  Pen Width", labelStyle);
            penWidth = (int)GUI.HorizontalSlider(new Rect(110, 75, 100, 35), penWidth, 2, 50, sliderStyle, sliderThumbStyle);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.5f);

            if (GUI.Button(new Rect(10, 95, 160, 30), "  Change Pen Color", buttonStyle))
            {
                colorPicker.showPicker = true;
            }

            if (GUI.Button(new Rect(10, 130, 90, 30), "  Reset Texture", buttonStyle))
            {
                ResetTexture();
            }


            if (colorPicker.showPicker)
            {
                penColor = colorPicker.setColor;
            }
        }
Exemplo n.º 3
0
 void OnGUI()
 {
     GUIResizer.AutoResize();
     GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.5f);
     if (GUI.Button(new Rect(10, 10, 160, 30), "  Start Plague Again", buttonStyle))
     {
         StartPlague();
     }
 }
        /// <summary>
        /// UI Buttons
        /// </summary>
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            if (map.rectangleSelectionInProgress)
            {
                GUI.Box(new Rect(10, 10, 600, 40), "Click and drag to make the selection.", labelStyle);
            }
            else
            {
                GUI.Box(new Rect(10, 10, 600, 40), "Press R to initiate a rectangle selection.", labelStyle);
            }
        }
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            GUI.Label(new Rect(10, 15, 430, 30), "Click on the globe to add a circle marker.", labelStyle);

            GUI.Button(new Rect(10, 45, 100, 30), "Circle radius", labelStyle);
            kmRadius = GUI.HorizontalSlider(new Rect(120, 50, 80, 20), kmRadius, 50, 1000, sliderStyle, sliderThumbStyle);

            GUI.Button(new Rect(10, 75, 100, 30), "Ring Width Start", labelStyle);
            ringWidthStart = GUI.HorizontalSlider(new Rect(120, 80, 80, 20), ringWidthStart, 0, 1f, sliderStyle, sliderThumbStyle);

            GUI.Button(new Rect(10, 105, 100, 30), "Ring Width End", labelStyle);
            ringWidthEnd = GUI.HorizontalSlider(new Rect(120, 110, 80, 20), ringWidthEnd, 0, 1f, sliderStyle, sliderThumbStyle);
        }
Exemplo n.º 6
0
        void OnGUI()
        {
            if (!showPicker)
            {
                return;
            }

            GUIResizer.AutoResize();

            int positionLeft = (GUIResizer.authoredScreenWidth / 2) - (textureWidth / 2);
            int positionTop  = (GUIResizer.authoredScreenHeight / 2) - (textureHeight / 2);

            GUI.Box(new Rect(positionLeft - 3, positionTop - 3, textureWidth + 60, textureHeight + 60), "");

            if (GUI.RepeatButton(new Rect(positionLeft, positionTop, textureWidth, textureHeight), displayPicker))
            {
                int a = (int)Input.mousePosition.x;
                int b = Screen.height - (int)Input.mousePosition.y;

                setColor     = displayPicker.GetPixel(a - positionLeft, -(b - positionTop));
                lastSetColor = setColor;
            }

            saturationSlider = GUI.VerticalSlider(new Rect(positionLeft + textureWidth + 3, positionTop, 10, textureHeight), saturationSlider, 1, -1);
            setColor         = lastSetColor + new Color(saturationSlider, saturationSlider, saturationSlider);
            GUI.Box(new Rect(positionLeft + textureWidth + 20, positionTop, 20, textureHeight), saturationTexture);

            if (GUI.Button(new Rect(positionLeft + textureWidth - 60, positionTop + textureHeight + 10, 60, 25), "Close"))
            {
                setColor = styleTexture.GetPixel(0, 0);

                // hide picker
                showPicker = false;
            }

            // color display
            GUIStyle style = new GUIStyle();

            styleTexture.SetPixel(0, 0, setColor);
            styleTexture.Apply();

            style.normal.background = styleTexture;
            GUI.Box(new Rect(positionLeft + textureWidth + 10, positionTop + textureHeight + 10, 30, 30), new GUIContent(""), style);
        }
Exemplo n.º 7
0
        void OnGUI()
        {
            GUIResizer.AutoResize();
            GUI.Label(new Rect(10, 10, 350, 30), "Click and drag over the Earth to clear Fog of War", labelStyle);

            enableRotation        = GUI.Toggle(new Rect(10, 40, 350, 30), enableRotation, "Enable Earth rotation");
            map.allowUserRotation = enableRotation;

            GUI.Label(new Rect(10, 70, 85, 25), "  Pen Width", labelStyle);
            penWidth = GUI.HorizontalSlider(new Rect(110, 75, 100, 20), penWidth, 0, 0.1f, sliderStyle, sliderThumbStyle);

            GUI.Label(new Rect(10, 100, 85, 25), "  Pen Strength", labelStyle);
            penStrength = GUI.HorizontalSlider(new Rect(110, 105, 100, 20), penStrength, 0, 0.2f, sliderStyle, sliderThumbStyle);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.5f);

            if (GUI.Button(new Rect(10, 130, 150, 30), "  Reset Fog Of War", buttonStyle))
            {
                map.SetFogOfWarAlpha(1);
            }
        }
Exemplo n.º 8
0
 void OnGUI()
 {
     // Do autoresizing of GUI layer
     GUIResizer.AutoResize();
     if (map.mouseIsOver)
     {
         string  text;
         Vector3 mousePos = Input.mousePosition;
         float   x, y;
         if (map.countryHighlighted != null || map.cityHighlighted != null)
         {
             City city = map.cityHighlighted;
             if (city != null)
             {
                 if (city.province != null && city.province.Length > 0)
                 {
                     text = "City: " + map.cityHighlighted.name + " (" + city.province + ", " + map.countries[map.cityHighlighted.countryIndex].name + ")";
                 }
                 else
                 {
                     text = "City: " + map.cityHighlighted.name + " (" + map.countries[map.cityHighlighted.countryIndex].name + ")";
                 }
             }
             else if (map.countryHighlighted != null)
             {
                 text = map.countryHighlighted.name + " (" + map.countryHighlighted.continent + ")";
             }
             else
             {
                 text = "";
             }
             x = GUIResizer.authoredScreenWidth * (mousePos.x / Screen.width);
             y = GUIResizer.authoredScreenHeight - GUIResizer.authoredScreenHeight * (mousePos.y / Screen.height) - 20 * (Input.touchSupported ? 3 : 1); // slightly up for touch devices
             GUI.Label(new Rect(x, y, 0, 10), text, labelStyle);
         }
     }
 }
Exemplo n.º 9
0
        // Update is called once per frame
        void OnGUI()
        {
            // Animates the camera field of view (just a cool effect at the begining)
            if (animatingField)
            {
                if (Camera.main.fieldOfView > 60)
                {
                    Camera.main.fieldOfView -= (181.0f - Camera.main.fieldOfView) / (220.0f - Camera.main.fieldOfView);
                }
                else
                {
                    Camera.main.fieldOfView = 60;
                    animatingField          = false;
                }
            }

            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            // Check whether a country or city is selected, then show a label
            if (map.mouseIsOver)
            {
                string  text;
                Vector3 mousePos = Input.mousePosition;
                float   x, y;
                if (map.countryHighlighted != null || map.cityHighlighted != null)
                {
                    if (map.cityHighlighted != null)
                    {
                        text = "City: " + map.cityHighlighted.name + " (" + map.countries[map.cityHighlighted.countryIndex].name + ")";
                    }
                    else if (map.countryHighlighted != null)
                    {
                        text = map.countryHighlighted.name + " (" + map.countryHighlighted.continent + ")";
                    }
                    else
                    {
                        text = "";
                    }
                    x = GUIResizer.authoredScreenWidth * (mousePos.x / Screen.width);
                    y = GUIResizer.authoredScreenHeight - GUIResizer.authoredScreenHeight * (mousePos.y / Screen.height) - 20 * (Input.touchSupported ? 3 : 1);                     // slightly up for touch devices
                    GUI.Label(new Rect(x - 1, y - 1, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x + 1, y + 2, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x + 2, y + 3, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x + 3, y + 4, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x, y, 0, 10), text, labelStyle);
                }
            }

            // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting
            map.showFrontiers          = GUI.Toggle(new Rect(10, 20, 150, 30), map.showFrontiers, "Toggle Frontiers");
            map.showEarth              = GUI.Toggle(new Rect(10, 50, 150, 30), map.showEarth, "Toggle Earth");
            map.showCities             = GUI.Toggle(new Rect(10, 80, 150, 30), map.showCities, "Toggle Cities");
            map.showCountryNames       = GUI.Toggle(new Rect(10, 110, 150, 30), map.showCountryNames, "Toggle Labels");
            map.enableCountryHighlight = GUI.Toggle(new Rect(10, 140, 170, 30), map.enableCountryHighlight, "Enable Country Highlight");

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.5f);

            // Add buttons to show the color picker and change colors for the frontiers or fill
            if (GUI.Button(new Rect(10, 170, 160, 30), "  Change Frontiers Color", buttonStyle))
            {
                colorPicker.showPicker = true;
                changingFrontiersColor = true;
            }
            if (GUI.Button(new Rect(10, 210, 160, 30), "  Change Fill Color", buttonStyle))
            {
                colorPicker.showPicker = true;
                changingFrontiersColor = false;
            }
            if (colorPicker.showPicker)
            {
                if (changingFrontiersColor)
                {
                    map.frontiersColor = colorPicker.setColor;
                }
                else
                {
                    map.fillColor = colorPicker.setColor;
                }
            }

            // Add a button which demonstrates the navigateTo functionality -- pass the name of a country
            // For a list of countries and their names, check map.Countries collection.
            if (GUI.Button(new Rect(10, 250, 180, 30), "  Fly to Argentina (Country)", buttonStyle))
            {
                FlyToCountry("Argentina");
            }
            if (GUI.Button(new Rect(10, 285, 180, 30), "  Fly to Mexico (Country)", buttonStyle))
            {
                FlyToCountry("Mexico");
            }
            if (GUI.Button(new Rect(10, 325, 180, 30), "  Fly to San Francisco (City)", buttonStyle))
            {
                FlyToCity("San Francisco");
            }
            if (GUI.Button(new Rect(10, 365, 180, 30), "  Fly to Madrid (City)", buttonStyle))
            {
                FlyToCity("Madrid");
            }

            // Slider to show the new set zoom level API in V4.1
            GUI.Button(new Rect(10, 430, 85, 30), "  Zoom Level", buttonStyle);
            float prevZoomLevel = zoomLevel;

            GUI.backgroundColor = Color.white;
            zoomLevel           = GUI.HorizontalSlider(new Rect(100, 445, 80, 85), zoomLevel, 0, 1, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            if (zoomLevel != prevZoomLevel)
            {
                prevZoomLevel = zoomLevel;
                map.SetZoomLevel(zoomLevel);
            }


            // Add a button to colorize countries
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 20, 180, 30), "  Colorize Europe", buttonStyle))
            {
                map.FlyToCity("Brussels");
                for (int colorizeIndex = 0; colorizeIndex < map.countries.Length; colorizeIndex++)
                {
                    if (map.countries [colorizeIndex].continent.Equals("Europe"))
                    {
                        Color color = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f));
                        map.ToggleCountrySurface(map.countries [colorizeIndex].name, true, color);
                    }
                }
            }

            // Colorize random country and fly to it
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 60, 180, 30), "  Colorize Random", buttonStyle))
            {
                map.FlyToCity("Brussels");
                int   countryIndex = Random.Range(0, map.countries.Length);
                Color color        = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f));
                map.ToggleCountrySurface(countryIndex, true, color);
                map.FlyToCountry(countryIndex);
            }

            // Button to clear colorized countries
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 100, 180, 30), "  Reset countries", buttonStyle))
            {
                map.HideCountrySurfaces();
            }

            // Moving the Earth sample
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 140, 180, 30), "  Toggle Minimize", buttonStyle))
            {
                ToggleMinimize();
            }

            // Add marker sample (gameobject)
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 180, 180, 30), "  Add Marker (Object)", buttonStyle))
            {
                AddMarkerGameObjectOnRandomCity();
            }

            // Add marker sample (gameobject)
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 220, 180, 30), "  Add Marker (Circle)", buttonStyle))
            {
                AddMarkerCircleOnRandomPosition();
            }

            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 260, 180, 30), "  Add Trajectories", buttonStyle))
            {
                AddTrajectories();
            }
        }
        bool avoidGUI;         // press SPACE during gameplay to hide GUI

        void OnGUI()
        {
            if (avoidGUI)
            {
                return;
            }

            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            // Check whether a country or city is selected, then show a label
            if (map.mouseIsOver)
            {
                string  text;
                Vector3 mousePos = Input.mousePosition;
                float   x, y;
                if (map.countryHighlighted != null || map.cityHighlighted != null || map.provinceHighlighted != null)
                {
                    City city = map.cityHighlighted;
                    if (city != null)
                    {
                        if (city.province != null && city.province.Length > 0)
                        {
                            text = "City: " + map.cityHighlighted.name + " (" + city.province + ", " + map.countries [map.cityHighlighted.countryIndex].name + ")";
                        }
                        else
                        {
                            text = "City: " + map.cityHighlighted.name + " (" + map.countries [map.cityHighlighted.countryIndex].name + ")";
                        }
                    }
                    else if (map.provinceHighlighted != null)
                    {
                        Debug.Log("map.provinceHighlighted.name" + map.provinceHighlighted.name);
                        text = map.provinceHighlighted.name + ", " + map.countryHighlighted.name;
                        List <Province> neighbours = map.ProvinceNeighboursOfCurrentRegion();
                        if (neighbours.Count > 0)
                        {
                            text += "\n" + EntityListToString <Province> (neighbours);
                        }
                    }
                    else if (map.countryHighlighted != null)
                    {
                        Debug.Log("map.countryHighlighted.name" + map.countryHighlighted.name);
                        text = map.countryHighlighted.name + " (" + map.countryHighlighted.continent + ")";
                        string data = check(map.countryHighlighted.name);

                        text += "\n" + data;
                    }
                    else
                    {
                        text = "";
                    }
                    x = GUIResizer.authoredScreenWidth * (mousePos.x / Screen.width);
                    y = GUIResizer.authoredScreenHeight - GUIResizer.authoredScreenHeight * (mousePos.y / Screen.height) - 20 * (Input.touchSupported ? 3 : 1);                     // slightly up for touch devices
                    GUI.Label(new Rect(x - 1, y - 1, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x + 1, y + 2, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x + 2, y + 3, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x + 3, y + 4, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x, y, 0, 10), text, labelStyle);
                }
                text = map.calc.prettyCurrentLatLon;
                x    = GUIResizer.authoredScreenWidth / 2.0f;
                y    = GUIResizer.authoredScreenHeight - 20;
                GUI.Label(new Rect(x, y, 0, 10), text, labelStyle);
            }
        }
Exemplo n.º 11
0
        bool avoidGUI;         // press SPACE during gameplay to hide GUI

        void OnGUI()
        {
            if (avoidGUI)
            {
                return;
            }

            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            // Check whether a country or city is selected, then show a label
            if (map.mouseIsOver)
            {
                string  text;
                Vector3 mousePos = Input.mousePosition;
                float   x, y;
                if (map.countryHighlighted != null || map.cityHighlighted != null || map.provinceHighlighted != null)
                {
                    City city = map.cityHighlighted;
                    if (city != null)
                    {
                        if (city.province != null && city.province.Length > 0)
                        {
                            text = "City: " + map.cityHighlighted.name + " (" + city.province + ", " + map.countries [map.cityHighlighted.countryIndex].name + ")";
                        }
                        else
                        {
                            text = "City: " + map.cityHighlighted.name + " (" + map.countries [map.cityHighlighted.countryIndex].name + ")";
                        }
                    }
                    else if (map.provinceHighlighted != null)
                    {
                        text = map.provinceHighlighted.name + ", " + map.countryHighlighted.name;
                        List <Province> neighbours = map.ProvinceNeighboursOfCurrentRegion();
                        if (neighbours.Count > 0)
                        {
                            text += "\n" + EntityListToString <Province> (neighbours);
                        }
                    }
                    else if (map.countryHighlighted != null)
                    {
                        text = map.countryHighlighted.name + " (" + map.countryHighlighted.continent + ")";
                        List <Country> neighbours = map.CountryNeighboursOfCurrentRegion();
                        if (neighbours.Count > 0)
                        {
                            text += "\n" + EntityListToString <Country> (neighbours);
                        }
                    }
                    else
                    {
                        text = "";
                    }
                    x = GUIResizer.authoredScreenWidth * (mousePos.x / Screen.width);
                    y = GUIResizer.authoredScreenHeight - GUIResizer.authoredScreenHeight * (mousePos.y / Screen.height) - 20 * (Input.touchSupported ? 3 : 1);                     // slightly up for touch devices
                    GUI.Label(new Rect(x - 1, y - 1, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x + 1, y + 2, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x + 2, y + 3, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x + 3, y + 4, 0, 10), text, labelStyleShadow);
                    GUI.Label(new Rect(x, y, 0, 10), text, labelStyle);
                }
                text = map.calc.prettyCurrentLatLon;
                x    = GUIResizer.authoredScreenWidth / 2.0f;
                y    = GUIResizer.authoredScreenHeight - 20;
                GUI.Label(new Rect(x, y, 0, 10), text, labelStyle);
            }

            // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting
            map.showFrontiers    = GUI.Toggle(new Rect(10, 20, 150, 30), map.showFrontiers, "Toggle Frontiers");
            map.showEarth        = GUI.Toggle(new Rect(10, 50, 150, 30), map.showEarth, "Toggle Earth");
            map.showCities       = GUI.Toggle(new Rect(10, 80, 150, 30), map.showCities, "Toggle Cities");
            map.showCountryNames = GUI.Toggle(new Rect(10, 110, 150, 30), map.showCountryNames, "Toggle Labels");
            map.showProvinces    = GUI.Toggle(new Rect(10, 140, 170, 30), map.showProvinces, "Toggle Provinces");

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.5f);

            // Add button to toggle Earth texture
            if (GUI.Button(new Rect(10, 170, 160, 30), "  Change Earth style", buttonStyle))
            {
                map.earthStyle = (EARTH_STYLE)(((int)map.earthStyle + 1) % 10);
            }

            // Add buttons to show the color picker and change colors for the frontiers or fill
            if (GUI.Button(new Rect(10, 210, 160, 30), "  Change Frontiers Color", buttonStyle))
            {
                colorPicker.showPicker = true;
                changingFrontiersColor = true;
            }
            if (GUI.Button(new Rect(10, 250, 160, 30), "  Change Fill Color", buttonStyle))
            {
                colorPicker.showPicker = true;
                changingFrontiersColor = false;
            }
            if (colorPicker.showPicker)
            {
                if (changingFrontiersColor)
                {
                    map.frontiersColor = colorPicker.setColor;
                }
                else
                {
                    map.fillColor = colorPicker.setColor;
                }
            }

            // Add a button which demonstrates the navigateTo functionality -- pass the name of a country
            // For a list of countries and their names, check map.Countries collection.
            if (GUI.Button(new Rect(10, 290, 180, 30), "  Fly to Australia (Country)", buttonStyle))
            {
                FlyToCountry("Australia");
            }
            if (GUI.Button(new Rect(10, 325, 180, 30), "  Fly to Mexico (Country)", buttonStyle))
            {
                FlyToCountry("Mexico");
            }
            if (GUI.Button(new Rect(10, 360, 180, 30), "  Fly to New York (City)", buttonStyle))
            {
                FlyToCity("New York");
            }
            if (GUI.Button(new Rect(10, 395, 180, 30), "  Fly to Madrid (City)", buttonStyle))
            {
                FlyToCity("Madrid");
            }

            // Slider to show the new set zoom level API in V4.1
            GUI.Button(new Rect(10, 430, 85, 30), "  Zoom Level", buttonStyle);
            float prevZoomLevel = zoomLevel;

            GUI.backgroundColor = Color.white;
            zoomLevel           = GUI.HorizontalSlider(new Rect(100, 445, 80, 85), zoomLevel, 0, 1, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            if (zoomLevel != prevZoomLevel)
            {
                prevZoomLevel = zoomLevel;
                map.SetZoomLevel(zoomLevel);
            }


            // Add a button to colorize countries
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 20, 180, 30), "  Colorize Europe", buttonStyle))
            {
                map.FlyToCity("Brussels");
                for (int colorizeIndex = 0; colorizeIndex < map.countries.Length; colorizeIndex++)
                {
                    if (map.countries [colorizeIndex].continent.Equals("Europe"))
                    {
                        Color color = new Color(UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f));
                        map.ToggleCountrySurface(map.countries [colorizeIndex].name, true, color);
                    }
                }
            }

            // Colorize random country and fly to it
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 60, 180, 30), "  Colorize Random", buttonStyle))
            {
                map.FlyToCity("Brussels");
                int   countryIndex = UnityEngine.Random.Range(0, map.countries.Length);
                Color color        = new Color(UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f));
                map.ToggleCountrySurface(countryIndex, true, color);
                map.FlyToCountry(countryIndex);
            }

            // Button to clear colorized countries
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 100, 180, 30), "  Reset countries", buttonStyle))
            {
                map.HideCountrySurfaces();
            }

            // Tickers sample
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 140, 180, 30), "  Tickers Sample", buttonStyle))
            {
                TickerSample();
            }

            // Decorator sample
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 180, 180, 30), "  Texture Sample", buttonStyle))
            {
                TextureSample();
            }

            // Moving the Earth sample
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 220, 180, 30), "  Toggle Minimize", buttonStyle))
            {
                ToggleMinimize();
            }

            // Add marker sample (gameobject)
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 260, 180, 30), "  Add Marker (Object)", buttonStyle))
            {
                AddMarkerGameObjectOnRandomCity();
            }

            // Add marker sample (gameobject)
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 300, 180, 30), "  Add Marker (Circle)", buttonStyle))
            {
                AddMarkerCircleOnRandomPosition();
            }

            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 340, 180, 30), "  Add Trajectories", buttonStyle))
            {
                AddTrajectories(10);
            }

            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 380, 180, 30), "  Locate Mount Point", buttonStyle))
            {
                LocateMountPoint();
            }

            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 420, 180, 30), "  Fire Bullet!", buttonStyle))
            {
                FireBullet();
            }
        }
Exemplo n.º 12
0
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            // Slider for the divisions the travel progress
            GUI.Label(new Rect(10, 10, 90, 30), "Divisions:", labelStyle);
            GUI.backgroundColor   = Color.white;
            map.hexaGridDivisions = (int)GUI.HorizontalSlider(new Rect(100, 20, 200, 35), map.hexaGridDivisions, 15, 200, sliderStyle, sliderThumbStyle);

            // Mask?
            map.hexaGridUseMask = GUI.Toggle(new Rect(10, 40, 150, 30), map.hexaGridUseMask, "Toggle Water Mask");

            // Path find
            if (GUI.Button(new Rect(10, 80, 120, 30), "  Random Path"))
            {
                RandomPathFind();
            }

            // Path find
            if (selectionMode != SELECTION_MODE.CUSTOM_PATH)
            {
                if (GUI.Button(new Rect(10, 120, 120, 30), "  Custom Path"))
                {
                    selectionMode  = SELECTION_MODE.CUSTOM_PATH;
                    selectionState = 0;
                }
            }
            else
            {
                if (GUI.Button(new Rect(10, 120, 120, 30), "  Cancel"))
                {
                    selectionMode = SELECTION_MODE.NONE;
                }
            }

            // Path find
            if (GUI.Button(new Rect(10, 160, 120, 30), "  Paint Country"))
            {
                PaintCountry();
            }

            // Neighbour costs
            if (selectionMode != SELECTION_MODE.CUSTOM_COST)
            {
                if (GUI.Button(new Rect(10, 200, 120, 30), "  Set Edge Cost"))
                {
                    selectionMode  = SELECTION_MODE.CUSTOM_COST;
                    selectionState = 0;
                }
            }
            else
            {
                if (GUI.Button(new Rect(10, 200, 120, 30), "  Cancel"))
                {
                    selectionMode = SELECTION_MODE.NONE;
                }
            }

            if (GUI.Button(new Rect(10, 240, 120, 30), "  Build Road"))
            {
                BuildRoad();
            }


            if (map.lastHighlightedCellIndex >= 0)
            {
                GUI.Label(new Rect(10, 280, 120, 30), "Current cell: " + map.lastHighlightedCellIndex);
            }

            switch (selectionMode)
            {
            case SELECTION_MODE.CUSTOM_PATH:
                if (selectionState == 0)
                {
                    GUI.Label(new Rect(10, 300, 200, 30), "Click to select first cell.");
                }
                else
                {
                    GUI.Label(new Rect(10, 300, 200, 30), "Click to select second cell.");
                }
                break;

            case SELECTION_MODE.CUSTOM_COST:
                if (selectionState == 0)
                {
                    GUI.Label(new Rect(10, 300, 200, 30), "Click to a cell.");
                }
                else
                {
                    GUI.Label(new Rect(10, 300, 200, 30), "Click to select adjacent cell.");
                }
                break;
            }
        }