Example #1
0
        // Update is called once per frame
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting
            GUI.Box(new Rect(0, 0, 185, 140), "");

            bool prev = enableClearFogOnClick;

            enableClearFogOnClick = GUI.Toggle(new Rect(10, 20, 150, 30), enableClearFogOnClick, "Toggle Clear Fog");
            if (enableClearFogOnClick != prev && enableClearFogOnClick)
            {
                enableClearFogCountryOnClick = false;
            }

            prev = enableClearFogCountryOnClick;
            enableClearFogCountryOnClick = GUI.Toggle(new Rect(10, 50, 150, 30), enableClearFogCountryOnClick, "Toggle Country Fog");
            if (enableClearFogCountryOnClick != prev && enableClearFogCountryOnClick)
            {
                enableClearFogOnClick = false;
            }

            // buttons background color
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            // Add button to toggle Earth texture
            if (GUI.Button(new Rect(10, 90, 160, 30), "  Reset Fog of War", buttonStyle))
            {
                map.FogOfWarClear(true);
            }
        }
Example #2
0
        /// <summary>
        /// UI Buttons
        /// </summary>
        void OnGUI() {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            // Switches between tank move and change country ownership on click
            bool prev = enableToggleOwnership;
            enableToggleOwnership = GUI.Toggle(new Rect(10, 20, 200, 30), enableToggleOwnership, "Change Ownership on Click");
            if (enableToggleOwnership && prev != enableToggleOwnership) {
                enableClickToMoveTank = false;
            }

            prev = enableClickToMoveTank;
            enableClickToMoveTank = GUI.Toggle(new Rect(230, 20, 150, 30), enableClickToMoveTank, "Move Tank On Click");
            if (enableClickToMoveTank && prev != enableClickToMoveTank) {
                enableToggleOwnership = false;
            }

            // Show debug info
            map.pathFindingVisualizeMatrixCost = GUI.Toggle(new Rect(500, 20, 200, 30), map.pathFindingVisualizeMatrixCost, "Debug Matrix Cost");

            // Block / clear frontier between Spain and France
            if (GUI.Button(new Rect(10, 50, 250, 28), "Block/Clear Spain-France Frontier")) {
                ToggleFrontierSpainFrance();
            }
        }
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            GUI.Label(new Rect(10, 15, 500, 30), "Wrap horizontally enabled to allow infinite horizontal scrolling. Move ship around.");

            // buttons background color
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            // Add button to toggle Earth texture
            if (GUI.Button(new Rect(10, 40, 130, 30), "  Locate Ship", buttonStyle))
            {
                map.FlyToLocation(ship.currentMap2DLocation, 2f, 0.05f);
            }
            if (GUI.Button(new Rect(10, 80, 130, 30), "  Reposition Ship", buttonStyle))
            {
                LaunchShip();
            }
            if (GUI.Button(new Rect(10, 120, 130, 30), "  Clear Trail", buttonStyle))
            {
                if (trailParent != null)
                {
                    Destroy(trailParent);
                }
            }
        }
Example #4
0
        void OnGUI()
        {
            GUIResizer.AutoResize();
            Rect rect = new Rect(10, 10, 500, 20);

            GUI.Box(rect, "");
            GUI.Label(rect, "  Click on a region to remove it.");
        }
Example #5
0
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            string msg = "Select destination cell!";

            GUI.Label(new Rect(11, 11, 300, 20), msg, labelStyleShadow);
            GUI.Label(new Rect(10, 10, 300, 20), msg, labelStyle);

            if (map.cellHighlightedIndex >= 0)
            {
                msg = "Current cell: " + map.cellHighlightedIndex;
                GUI.Label(new Rect(11, 31, 300, 20), msg, labelStyleShadow);
                GUI.Label(new Rect(10, 30, 300, 20), msg, labelStyle);
            }

            if (GUI.Button(new Rect(10, 60, 100, 20), "Draw Barrier", buttonStyle))
            {
                // Very basic sample of how to draw some lines to create a visual barrier over the edges of some hexagonal cells
                map.AddLine(101133, CELL_SIDE.Top, Color.cyan, 0.1f);
                map.AddLine(101134, CELL_SIDE.TopLeft, Color.cyan, 0.1f);
                map.AddLine(101134, CELL_SIDE.Top, Color.cyan, 0.1f);
                map.AddLine(101134, CELL_SIDE.TopRight, Color.cyan, 0.1f);
                map.AddLine(101135, CELL_SIDE.Top, Color.cyan, 0.1f);
                map.AddLine(101136, CELL_SIDE.TopLeft, Color.cyan, 0.1f);
                map.AddLine(101136, CELL_SIDE.Top, Color.cyan, 0.1f);
                map.AddLine(101136, CELL_SIDE.TopRight, Color.cyan, 0.1f);
                // Set crossing costs for barrier for each edge. Note that here I'm using the hard coded cell numbers for this example. If you change the number of rows or columns of the grid
                // this will obviously fail.
                int cost = 10000;
                map.PathFindingCellSetSideCost(101133, 101645, cost);
                map.PathFindingCellSetSideCost(101134, 101645, cost);
                map.PathFindingCellSetSideCost(101134, 101646, cost);
                map.PathFindingCellSetSideCost(101134, 101647, cost);
                map.PathFindingCellSetSideCost(101135, 101647, cost);
                map.PathFindingCellSetSideCost(101136, 101647, cost);
                map.PathFindingCellSetSideCost(101136, 101648, cost);
                map.PathFindingCellSetSideCost(101136, 101649, cost);
            }

            GUI.Label(new Rect(10, 100, 250, 30), "Non colored terrain cost: 1 point");
            GUI.Label(new Rect(10, 120, 250, 30), "Green movement cost: 2 point");
            GUI.Label(new Rect(10, 140, 250, 30), "Gray movement cost: 3 points");
            GUI.Label(new Rect(10, 160, 250, 30), "Press R to show movement range.");

            if (tank.maxSearchCost > 5 || ((int)Time.time) % 2 != 0)
            {
                GUI.Label(new Rect(10, 180, 250, 30), "Tank move points: " + tank.maxSearchCost);
            }
            if (tank.maxSearchCost < 5)
            {
                GUI.Label(new Rect(10, 200, 250, 30), "Press M to add more move points.");
            }
        }
        /// <summary>
        /// UI Buttons
        /// </summary>
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            GUI.Box(new Rect(0, 0, 160, 160), "");

            // Path line controls
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            GUI.Button(new Rect(10, 50, 150, 30), "  Curvature", buttonStyle);
            GUI.backgroundColor         = Color.white;
            map.renderViewportCurvature = GUI.HorizontalSlider(new Rect(10, 85, 150, 35), map.renderViewportCurvature, -100f, 100f, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor         = new Color(0.1f, 0.1f, 0.3f, 0.95f);
        }
        /// <summary>
        /// UI Buttons
        /// </summary>
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            if (map.rectangleSelectionInProgress)
            {
                GUI.Box(new Rect(10, 10, 600, 40), "Drag and release to make a selection.", labelStyle);
            }
            else
            {
                GUI.Box(new Rect(10, 10, 600, 40), "Hold down LEFT SHIFT to initiate a rectangle selection.", labelStyle);
                if (selectedUnits.Count > 0)
                {
                    GUI.Box(new Rect(10, 25, 600, 40), "Press C to clear current selection.", labelStyle);
                }
            }
        }
Example #8
0
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            string msg;

            if (selectStage == 0)
            {
                msg = "Select starting country";
            }
            else
            {
                msg = "Move over other country to show countries path";
            }
            GUI.Label(new Rect(11, 11, 300, 20), msg, labelStyleShadow);
            GUI.Label(new Rect(10, 10, 300, 20), msg, labelStyle);
        }
Example #9
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);
        }
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            GUI.Box(new Rect(10, 10, 365, 75), "Fly to operations with viewport switching during movement.");

            // buttons background color
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            if (map.renderViewportIsEnabled)
            {
                if (GUI.Button(new Rect(85, 40, 100, 30), "2D Mode", buttonStyle))
                {
                    FlyZoomOut();
                }
            }
            else
            {
                if (GUI.Button(new Rect(85, 40, 100, 30), "Viewport Mode", buttonStyle))
                {
                    FollowTankZoomIn();
                }
            }


            if (tank.isMoving)
            {
                if (GUI.Button(new Rect(205, 40, 100, 30), "Stop Tank", buttonStyle))
                {
                    tank.Stop();
                }
            }
            else
            {
                if (GUI.Button(new Rect(205, 40, 100, 30), "Resume", buttonStyle))
                {
                    tank.MoveTo(tank.endingMap2DLocation, 0.1f);
                }
            }
        }
Example #11
0
        /// <summary>
        /// UI Buttons
        /// </summary>
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            GUI.Box(new Rect(0, 0, 160, 160), "");

            // Path line controls
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            GUI.Button(new Rect(10, 50, 150, 30), "  Time of Day", buttonStyle);
            GUI.backgroundColor = Color.white;
            timeOfDay           = GUI.HorizontalSlider(new Rect(10, 85, 150, 35), timeOfDay, 0, 24f, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            timeOfDay += 0.01f;
            if (timeOfDay >= 24)
            {
                timeOfDay = 0;
            }
            map.timeOfDay = timeOfDay;
        }
Example #12
0
        /// <summary>
        /// UI Buttons
        /// </summary>
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            // buttons background color
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            // Add button to toggle Earth texture
            if (GUI.Button(new Rect(10, 10, 160, 30), "  Open Mini Map", buttonStyle))
            {
                float       left   = 0.8f;
                float       top    = 0.8f;
                float       width  = 0.2f;
                float       height = 0.2f;
                Vector4     normalizedScreenRect = new Vector4(left, top, width, height);
                WMSKMiniMap minimap = WMSKMiniMap.Show(normalizedScreenRect);
                minimap.duration  = 2f;
                minimap.zoomLevel = 0.1f;
            }

            if (WMSKMiniMap.IsVisible())
            {
                if (GUI.Button(new Rect(10, 50, 160, 30), "  Random Position", buttonStyle))
                {
                    float   left   = Random.value * 0.8f;
                    float   top    = Random.value * 0.8f;
                    float   width  = 0.2f;
                    float   height = 0.2f;
                    Vector4 normalizedScreenRect = new Vector4(left, top, width, height);
                    WMSKMiniMap.RepositionAt(normalizedScreenRect);
                }

                if (GUI.Button(new Rect(10, 90, 160, 30), "  Hide Mini Map", buttonStyle))
                {
                    WMSKMiniMap.Hide();
                }
            }
        }
Example #13
0
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            // Check whether a country or city is selected, then show a label with the entity name and its neighbours (new in V4.1!)
            if (map.cellHighlighted != null)
            {
                int    cellIndex = map.cellHighlightedIndex;
                string text      = "Cell index = " + cellIndex + ", row = " + map.cells [cellIndex].row + ", col = " + map.cells [cellIndex].column + ", center = " + map.cells [cellIndex].center;
                // shadow
                float x, y;
                x = Screen.width / 2.0f;
                y = Screen.height - 40;
                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);
                // texst face
                GUI.Label(new Rect(x, y, 0, 10), text, labelStyle);
            }

            // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting
            GUI.Box(new Rect(5, 0, 175, 180), "");
            map.showGrid            = GUI.Toggle(new Rect(10, 20, 170, 30), map.showGrid, "Toggle Grid");
            map.enableCellHighlight = GUI.Toggle(new Rect(10, 50, 170, 30), map.enableCellHighlight, "Enable Cell Highlighting");
            if (GUI.Toggle(new Rect(10, 80, 170, 30), mode == ACTION_MODE.FadeOut, "Toggle Fade Circle"))
            {
                mode = ACTION_MODE.FadeOut;
            }
            if (GUI.Toggle(new Rect(10, 110, 170, 30), mode == ACTION_MODE.Flash, "Toggle Flash Circle"))
            {
                mode = ACTION_MODE.Flash;
            }
            if (GUI.Toggle(new Rect(10, 140, 170, 30), mode == ACTION_MODE.Blink, "Toggle Blink Circle"))
            {
                mode = ACTION_MODE.Blink;
            }
            if (GUI.Toggle(new Rect(10, 170, 170, 30), mode == ACTION_MODE.Paint, "Toggle Colorize Cell"))
            {
                mode = ACTION_MODE.Paint;
            }
            if (GUI.Toggle(new Rect(10, 200, 170, 30), mode == ACTION_MODE.FadeCountry, "Toggle Fade Country"))
            {
                mode = ACTION_MODE.FadeCountry;
            }

            // buttons background color
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            // Clear painted cells
            if (GUI.Button(new Rect(10, 230, 160, 30), "  Clear Cells", buttonStyle))
            {
                map.HideCellSurfaces();
            }

            // Add buttons to show the color picker and change colors for the cells
            if (GUI.Button(new Rect(10, 265, 160, 30), "  Change Grid Color", buttonStyle))
            {
                colorPicker.showPicker = true;
            }
            if (colorPicker.showPicker)
            {
                map.gridColor = colorPicker.setColor;
            }

            // Slider to show the new set zoom level API in V4.1
            GUI.Button(new Rect(10, 300, 85, 30), "  Cells", buttonStyle);
            GUI.backgroundColor = Color.white;
            int prevCellsCount = (int)cellsCount;

            cellsCount = (int)GUI.HorizontalSlider(new Rect(100, 315, 80, 30), cellsCount, 32, 512, sliderStyle, sliderThumbStyle);
            if ((int)cellsCount != prevCellsCount)
            {
                map.gridColumns = (int)cellsCount;
                map.gridRows    = map.gridColumns / 2;
                cellsCount      = map.gridColumns;
            }
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

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

            GUI.backgroundColor = Color.white;
            zoomLevel           = GUI.HorizontalSlider(new Rect(100, 350, 80, 30), 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);
            }
        }
Example #14
0
 void OnGUI()
 {
     GUIResizer.AutoResize();
     GUI.Box(new Rect(10, 10, 460, 40), "Click on a region to change its elevation", labelStyle);
 }
Example #15
0
        // Update is called once per frame
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            // Check whether a country or city is selected, then show a label with the entity name and its neighbours (new in V4.1!)
            if (map.countryHighlighted != null || map.cityHighlighted != null || map.provinceHighlighted != null)
            {
                string text;
                if (map.cityHighlighted != null)
                {
                    if (!map.cityHighlighted.name.Equals(map.cityHighlighted.province))                       // show city name + province & country name
                    {
                        text = "City: " + map.cityHighlighted.name + " (" + map.cityHighlighted.province + ", " + map.countries[map.cityHighlighted.countryIndex].name + ")";
                    }
                    else                                // show city name + country name (city is a capital with same name as province)
                    {
                        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
                {
                    text = "";
                }
                float x, y;
                x = Screen.width / 2.0f;
                y = Screen.height - 40;

                // shadow
                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);
                // texst face
                GUI.Label(new Rect(x, y, 0, 10), text, labelStyle);
            }

            // buttons background color
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            // Add a button to colorize countries
            if (GUI.Button(new Rect(10, 20, 180, 30), "  Colorize France", buttonStyle))
            {
                ColorizeFrance();
            }

            if (GUI.Button(new Rect(10, 60, 180, 30), "  Colorize World", buttonStyle))
            {
                ColorizeProvinces(true);
            }

            if (GUI.Button(new Rect(10, 100, 180, 30), "  Reset Provinces", buttonStyle))
            {
                ColorizeProvinces(false);
            }

            if (GUI.Button(new Rect(10, 140, 180, 30), "  Province Border Points", buttonStyle))
            {
                ShowBorderPoints();
            }
        }
 void OnGUI()
 {
     GUIResizer.AutoResize();
     GUI.Box(new Rect(10, 10, 460, 40), "Click on any cell to add it to the country", labelStyle);
 }
 /// <summary>
 /// UI Buttons
 /// </summary>
 void OnGUI()
 {
     // Do autoresizing of GUI layer
     GUIResizer.AutoResize();
     GUI.Box(new Rect(10, 10, 460, 40), "Click on any tank and watch the console for unit-level and global-level events", labelStyle);
 }
Example #18
0
        // Update is called once per frame
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            // Check whether a province or city is selected, then show a label with the entity name and its neighbours (new in V4.1!)
            if (map.provinceHighlighted != null || map.provinceHighlighted != null)
            {
                string text;
                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
                {
                    text = "";
                }
                float x, y;
                x = Screen.width / 2.0f;
                y = Screen.height - 40;

                // shadow
                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);
                // text face
                GUI.Label(new Rect(x, y, 0, 10), text, labelStyle);
            }

            Rect rect = new Rect(10, 10, 500, 20);

            if (!autoExpand)
            {
                GUI.Box(rect, "");
                GUI.Label(rect, "  Left click to select principal province. Right click another province to merge.");
            }

            // buttons background color
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            // Add button to toggle Earth texture
            if (autoExpand)
            {
                string provinceName = (principalProvinceIndex >= 0 && principalProvinceIndex < map.provinces.Length) ? map.provinces[principalProvinceIndex].name : "";
                if (GUI.Button(new Rect(10, 10, 300, 30), "  Stop Expansion of " + provinceName, buttonStyle))
                {
                    autoExpand = false;
                }
            }
            else
            {
                if (GUI.Button(new Rect(10, 40, 180, 30), "  Automate Expansion", buttonStyle))
                {
                    autoExpand = true;
                    StartCoroutine(StartExpansion());
                }
                if (GUI.Button(new Rect(10, 75, 180, 30), "  Transfer Provinces Demo", buttonStyle))
                {
                    StartCoroutine(TransferProvinces());
                }
                if (GUI.Button(new Rect(10, 110, 80, 30), "  Reset Map", buttonStyle))
                {
                    map.ReloadData();
                    map.Redraw();
                }
            }
        }
Example #19
0
        /// <summary>
        /// UI Buttons
        /// </summary>
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            GUI.Box(new Rect(0, 0, 160, 160), "");

            bool prev = enableAddTowerOnClick;

            enableAddTowerOnClick = GUI.Toggle(new Rect(10, 20, 150, 30), enableAddTowerOnClick, "Enable Tower On Click");
            if (enableAddTowerOnClick && prev != enableAddTowerOnClick)
            {
                enableClickToMoveTank = false;
                enableClickToMoveShip = false;
            }

            prev = enableClickToMoveTank;
            enableClickToMoveTank = GUI.Toggle(new Rect(180, 20, 200, 30), enableClickToMoveTank, "Enable Move Tank On Click");
            if (enableClickToMoveTank && prev != enableClickToMoveTank)
            {
                enableAddTowerOnClick = false;
                enableClickToMoveShip = false;
            }

            prev = enableClickToMoveShip;
            enableClickToMoveShip = GUI.Toggle(new Rect(390, 20, 200, 30), enableClickToMoveShip, "Enable Move Ship On Click");
            if (enableClickToMoveShip && prev != enableClickToMoveShip)
            {
                enableAddTowerOnClick = false;
                enableClickToMoveTank = false;
            }

            // buttons background color
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            if (GUI.Button(new Rect(10, 50, 150, 30), "  Add Random Tower", buttonStyle))
            {
                AddRandomTower();
            }

            if (GUI.Button(new Rect(10, 90, 150, 30), "  Add Random Sprite", buttonStyle))
            {
                AddRandomSprite();
            }

            if (GUI.Button(new Rect(10, 130, 150, 30), "  Drop Tank on Paris", buttonStyle))
            {
                DropTankOnCity();
            }

            if (GUI.Button(new Rect(10, 170, 150, 30), "  Move Tank & Follow", buttonStyle))
            {
                MoveTankAndFollow();
            }

            if (ship != null)
            {
                if (GUI.Button(new Rect(10, 210, 150, 30), "  Destroy Ship", buttonStyle))
                {
                    DestroyImmediate(ship.gameObject);
                    ship = null;
                }
            }
            else
            {
                if (GUI.Button(new Rect(10, 210, 150, 30), "  Launch Ship", buttonStyle))
                {
                    LaunchShip();
                }
            }

            if (GUI.Button(new Rect(10, 250, 150, 30), "  Start Flight", buttonStyle))
            {
                ShowAirplane();
            }

            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 50, 180, 30), "  Mass Create", buttonStyle))
            {
                MassCreate(50);
            }

            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 90, 180, 30), "  Find France Coast", buttonStyle))
            {
                FindFranceCoast();
            }

            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 130, 180, 30), "  Find France-Germany Line", buttonStyle))
            {
                FindFranceGermanyLine();
            }

            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 170, 180, 30), "  Find France-Germany Provinces", buttonStyle))
            {
                FindFranceGermanyProvinces();
            }

            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 210, 180, 30), "  Add Sphere", buttonStyle))
            {
                AddSphere();
            }
        }
Example #20
0
        /// <summary>
        /// UI Buttons
        /// </summary>
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            GUI.Box(new Rect(0, 0, 160, 160), "");

            bool prev = showLinearPath;

            showLinearPath = GUI.Toggle(new Rect(10, 20, 150, 30), showLinearPath, "Show Linear Path");
            if (showLinearPath != prev && showLinearPath)
            {
                showRoutePath    = false;
                pathArcElevation = 2f;
            }
            prev          = showRoutePath;
            showRoutePath = GUI.Toggle(new Rect(180, 20, 150, 30), showRoutePath, "Show Route Path");
            if (showRoutePath != prev && showRoutePath)
            {
                showLinearPath   = false;
                pathArcElevation = 0;
            }
            enableClickToMoveTank = GUI.Toggle(new Rect(350, 20, 200, 30), enableClickToMoveTank, "Enable Move Tank On Click");
            showCircle            = GUI.Toggle(new Rect(570, 20, 120, 30), showCircle, "Show Circle");
            showEndCap            = GUI.Toggle(new Rect(690, 20, 120, 30), showEndCap, "Show End Cap");

            // Path line controls
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            GUI.Button(new Rect(10, 50, 150, 30), "  Drawing Duration", buttonStyle);
            GUI.backgroundColor = Color.white;
            pathDrawingDuration = GUI.HorizontalSlider(new Rect(10, 85, 150, 35), pathDrawingDuration, 0, 3f, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            GUI.Button(new Rect(10, 120, 150, 30), "  Arc Elevation", buttonStyle);
            GUI.backgroundColor = Color.white;
            pathArcElevation    = GUI.HorizontalSlider(new Rect(10, 155, 150, 35), pathArcElevation, 0, 10f, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            GUI.Button(new Rect(10, 190, 150, 30), "  Line Width", buttonStyle);
            GUI.backgroundColor = Color.white;
            pathLineWidth       = GUI.HorizontalSlider(new Rect(10, 225, 150, 35), pathLineWidth, 0.05f, 1f, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            GUI.Button(new Rect(10, 260, 150, 30), "  Dash Size", buttonStyle);
            GUI.backgroundColor = Color.white;
            pathDashInterval    = GUI.HorizontalSlider(new Rect(10, 295, 150, 35), pathDashInterval, 0, 0.01f, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            GUI.Button(new Rect(10, 330, 150, 30), "  Dash Speed", buttonStyle);
            GUI.backgroundColor       = Color.white;
            pathDashAnimationDuration = GUI.HorizontalSlider(new Rect(10, 365, 150, 35), pathDashAnimationDuration, 0, 2f, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor       = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 50, 150, 30), "  Circle Radius", buttonStyle);
            GUI.backgroundColor = Color.white;
            circleRadius        = GUI.HorizontalSlider(new Rect(GUIResizer.authoredScreenWidth - 190, 85, 150, 35), circleRadius, 0, 1000f, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 120, 150, 30), "  Circle Ring Start", buttonStyle);
            GUI.backgroundColor = Color.white;
            circleRingStart     = GUI.HorizontalSlider(new Rect(GUIResizer.authoredScreenWidth - 190, 155, 150, 35), circleRingStart, 0, 1f, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
            GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 190, 150, 30), "  Circle Ring End", buttonStyle);
            GUI.backgroundColor = Color.white;
            circleRingEnd       = GUI.HorizontalSlider(new Rect(GUIResizer.authoredScreenWidth - 190, 225, 150, 35), circleRingEnd, 0, 1f, sliderStyle, sliderThumbStyle);
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);
        }
Example #21
0
        void OnGUI()
        {
            if (avoidGUI)
            {
                return;
            }

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

            // Check whether a country or city is selected, then show a label with the entity name and its neighbours (new in V4.1!)
            if (map.countryHighlighted != null || map.cityHighlighted != null || map.provinceHighlighted != null)
            {
                string text;
                if (map.cityHighlighted != null)
                {
                    if (!map.cityHighlighted.name.Equals(map.cityHighlighted.province))   // show city name + province & country name
                    {
                        text = "City: " + map.cityHighlighted.name + " (" + map.cityHighlighted.province + ", " + map.countries[map.cityHighlighted.countryIndex].name + ")";
                    }
                    else        // show city name + country name (city is a capital with same name as province)
                    {
                        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 = "";
                }
                float x, y;
                if (minimizeState)
                {
                    x = Screen.width - 130;
                    y = Screen.height - 140;
                }
                else
                {
                    x = Screen.width / 2.0f;
                    y = Screen.height - 40;
                }
                // shadow
                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);
                // texst face
                GUI.Label(new Rect(x, y, 0, 10), text, labelStyle);
            }

            // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting
            GUI.Box(new Rect(0, 0, 150, 200), "");
            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 Highlight");

            // buttons background color
            GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f);

            // 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) % 4);
            }

            // 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", "United States of America");
            }
            if (GUI.Button(new Rect(10, 395, 180, 30), "  Fly to Madrid (City)", buttonStyle))
            {
                FlyToCity("Madrid", "Spain");
            }


            // 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);
            }

            if (GUI.Button(new Rect(10, 475, 180, 30), "  Alpha Texture Fill", buttonStyle))
            {
                TransparentTextureFill();
            }



            // Add a button to colorize countries
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 20, 180, 30), "  Colorize Europe", buttonStyle))
            {
                for (int countryIndex = 0; countryIndex < map.countries.Length; countryIndex++)
                {
                    if (map.countries[countryIndex].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), 0.5f);
                        map.ToggleCountrySurface(countryIndex, true, color);
                    }
                }
            }

            // Colorize random country and fly to it
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 60, 180, 30), "  Colorize Random", buttonStyle))
            {
                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.BlinkCountry(countryIndex, Color.green, Color.black, 0.8f, 0.2f);
            }

            // Add a button to colorize countries
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 100, 180, 30), "  Colorize Continents", buttonStyle))
            {
                Dictionary <string, Color> continentColors = new Dictionary <string, Color>();
                for (int countryIndex = 0; countryIndex < map.countries.Length; countryIndex++)
                {
                    Country country = map.countries[countryIndex];
                    Color   continentColor;
                    if (continentColors.ContainsKey(country.continent))
                    {
                        continentColor = continentColors[country.continent];
                    }
                    else
                    {
                        continentColor = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), 0.5f);
                        continentColors.Add(country.continent, continentColor);
                    }
                    map.ToggleCountrySurface(countryIndex, true, continentColor);
                }
            }


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

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

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

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

            // Add marker sample (Sprite)
            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 300, 180, 30), "  Add Marker (2D Sprite)", buttonStyle))
            {
                AddMarkerSpriteOnRandomCity();
            }

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

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

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

            if (GUI.Button(new Rect(GUIResizer.authoredScreenWidth - 190, 460, 180, 30), "  One Country Borders", buttonStyle))
            {
                ShowCountryBorders();
            }
        }
Example #22
0
        void OnGUI()
        {
            // Do autoresizing of GUI layer
            GUIResizer.AutoResize();

            switch (state)
            {
            case 0:
                if (GUI.Button(new Rect(10, 10, 160, 30), "Merge North America", buttonStyle))
                {
                    int countryUSA    = map.GetCountryIndex("United States of America");
                    int countryCanada = map.GetCountryIndex("Canada");
                    map.CountryTransferCountry(countryUSA, countryCanada, true);

                    countryUSA = map.GetCountryIndex("United States of America");
                    int countryMexico = map.GetCountryIndex("Mexico");
                    map.CountryTransferCountry(countryUSA, countryMexico, true);
                    state++;
                }
                break;

            case 1:
                if (GUI.Button(new Rect(10, 10, 160, 30), "Save Current Frontiers", buttonStyle))
                {
                    SaveAllData();
                    state++;
                                        #if UNITY_EDITOR
                    EditorUtility.DisplayDialog("Saved Data", "Data stored in temporary variables. You can now click reset frontiers to simulate a game restart and then Load Saved Data to restore the saved data.", "Ok");
                                        #endif
                }
                break;

            case 2:
                if (GUI.Button(new Rect(10, 10, 160, 30), "Reset Frontiers", buttonStyle))
                {
                    map.ReloadData();
                    map.Redraw();
                    state++;
                }
                break;

            case 3:
                if (GUI.Button(new Rect(10, 10, 160, 30), "Load Saved Data", buttonStyle))
                {
                    LoadAllData();
                    state++;
                                        #if UNITY_EDITOR
                    EditorUtility.DisplayDialog("Data Loaded!", "Data has been loaded from the temporary variables.", "Ok");
                                        #endif
                }
                break;

            case 4:
                if (GUI.Button(new Rect(10, 50, 160, 30), "Reset Frontiers", buttonStyle))
                {
                    map.ReloadData();
                    map.Redraw();
                    state = 0;
                }
                break;
            }
        }
Example #23
0
 /// <summary>
 /// UI Buttons
 /// </summary>
 void OnGUI()
 {
     // Do autoresizing of GUI layer
     GUIResizer.AutoResize();
     GUI.Box(new Rect(10, 10, 460, 40), "Left click: look at. Right click: fire!", labelStyle);
 }