Exemplo n.º 1
0
        private void OnGUI()
        {
            if (visible)
            {
                GUI.skin = Gui.Skin;
                Width    = Mathf.Clamp(Camera.main.pixelWidth / 2, 700, Camera.main.pixelWidth);
                MenuRect = new Rect(10, 10, Mathf.Clamp(Camera.main.pixelWidth / 2, 700, Camera.main.pixelWidth), Height);

                // apply label style if not existing
                if (labelStyle == null)
                {
                    labelStyle          = new GUIStyle(GUI.skin.label);
                    labelStyle.fontSize = 12;
                }

                GUI.Box(MenuRect, "", GUI.skin.window);

                CurrentTab = GUI.Toolbar(new Rect(MenuRect.xMin, MenuRect.yMin, MenuRect.width, ToolbarHeight), CurrentTab,
                                         new GUIContent[]
                {
                    new GUIContent("Cheats"),
                    new GUIContent("Environment"),
                    new GUIContent("Player"),
                    new GUIContent("Spawn"),
                    new GUIContent("Inventory"),
                    new GUIContent("Coop"),
                    new GUIContent("Dev"),
                    new GUIContent("Game")
                },
                                         GUI.skin.GetStyle("Tabs"));

                Y = MenuRect.yMin + ToolbarHeight; //+ Padding

                switch (CurrentTab)
                {
                case 0:     // Cheats
                {
                    ScrollPosition = GUI.BeginScrollView(new Rect(MenuRect.xMin, Y, Width, Height - ToolbarHeight - 5), ScrollPosition, new Rect(0, 0, Width - 24, this.scroller));
                    Y = Padding;

                    UI.AddCheckBox(ref Cheat.GodMode, "God Mode");

                    if (UI.AddButton("Set Anchor"))
                    {
                        _Raft.AddAnchor(_Raft.transform, false, null);
                    }
                    IncreaseY(-30);
                    if (UI.AddButton("Remove Anchor", 220))
                    {
                        _Raft.RemoveAnchor(_Raft.transform);
                    }

                    this.scroller = Y + 15;
                    GUI.EndScrollView();
                    break;
                }

                case 1:     //Environment
                {
                    ScrollPosition = GUI.BeginScrollView(new Rect(MenuRect.xMin, Y, Width, Height - ToolbarHeight - 5), ScrollPosition, new Rect(0, 0, Width - 24, this.scroller));
                    Y = Padding;

                    UI.AddLabel("Time");
                    UI.AddCheckBox(ref Cheat.fixTimeScale, "Pause");
                    if (_AzureSkyController)
                    {
                        if (UI.AddButton("+1h"))
                        {
                            float at = _AzureSkyController.Azure_Timeline;
                            at += 1f;
                            if (at >= 24f)
                            {
                                at -= 24f;
                            }
                            _AzureSkyController.AzureSetTime(at, _AzureSkyController.Azure_DayCycle);
                        }
                        IncreaseY(-30);
                        if (UI.AddButton("-1h", 220))
                        {
                            float at = _AzureSkyController.Azure_Timeline;
                            at -= 1f;
                            if (at <= 0f)
                            {
                                at += 24f;
                            }
                            _AzureSkyController.AzureSetTime(at, _AzureSkyController.Azure_DayCycle);
                        }

                        UI.AddSlider(ref _AzureSkyController.Azure_FogDistance, 50, 5000, "Fog Distance");
                    }

                    UI.AddLabel("Weather");
                    foreach (var weather in Cheat._WeatherConnection)
                    {
                        if (UI.AddButton(weather.weatherObject.name))
                        {
                            _WeatherManager.SetWeather(weather.weatherObject.name, true);
                        }
                    }

                    this.scroller = Y + 15;
                    GUI.EndScrollView();
                    break;
                }

                case 2:     //Player
                {
                    ScrollPosition = GUI.BeginScrollView(new Rect(MenuRect.xMin, Y, Width, Height - ToolbarHeight - 5), ScrollPosition, new Rect(0, 0, Width - 24, this.scroller));
                    Y = Padding;

                    UI.AddSlider(ref Cheat.SpeedMultiplier, 1, 20, "Player Speed");

                    if (UI.AddButton("Add Durability to HotSlot", 20, 300))
                    {
                        _Network_Player.Inventory.RemoveDurabillityFromHotSlot(-100);
                    }

                    this.scroller = Y + 15;
                    GUI.EndScrollView();
                    break;
                }

                case 3:     //Spawn
                {
                    break;
                }

                case 4:     //Inventory
                {
                    ScrollPosition = GUI.BeginScrollView(new Rect(MenuRect.xMin, Y, Width, Height - ToolbarHeight - 5), ScrollPosition, new Rect(0, 0, Width - 24, this.scroller));
                    Y = Padding;

                    var items = ItemManager.GetAllItems();
                    foreach (Item_Base current in items)
                    {
                        UnityEngine.GUI.Label(new Rect(20f, Y, 270f, 20f), current.UniqueName + " [" + current.UniqueIndex + "]", labelStyle);
                        if (UnityEngine.GUI.Button(new Rect(290f, Y, 40f, 20f), "+1"))
                        {
                            _Network_Player.Inventory.AddItem(current.UniqueName, 1);
                        }
                        if (UnityEngine.GUI.Button(new Rect(340f, Y, 40f, 20f), "+20"))
                        {
                            _Network_Player.Inventory.AddItem(current.UniqueName, 20);
                        }
                        Y += 30f;
                    }

                    this.scroller = Y + 15;
                    GUI.EndScrollView();
                    break;
                }

                case 5:     //Coop
                {
                    break;
                }

                case 6:     //Dev
                {
                    break;
                }

                case 7:     //Game
                {
                    ScrollPosition = GUI.BeginScrollView(new Rect(MenuRect.xMin, Y, Width, Height - ToolbarHeight - 5), ScrollPosition, new Rect(0, 0, Width - 24, this.scroller));
                    Y = Padding;

                    if (UI.AddButton("Go to Raft", 20, 300))
                    {
                        _Player.transform.position = _Raft.transform.position + (Vector3.up * 2);
                    }

                    this.scroller = Y + 15;
                    GUI.EndScrollView();
                    break;
                }
                }
            }
        }
Exemplo n.º 2
0
        private void OnGUI()
        {
            if (visible)
            {
                GUI.skin = Interface.Skin;
                Width    = Mathf.Clamp(Camera.main.pixelWidth / 2, 700, Camera.main.pixelWidth);
                MenuRect = new Rect(10, 10, Mathf.Clamp(Camera.main.pixelWidth / 2, 700, Camera.main.pixelWidth), Height);

                // apply label style if not existing
                if (labelStyle == null)
                {
                    labelStyle          = new GUIStyle(GUI.skin.label);
                    labelStyle.fontSize = 12;
                }

                GUI.Box(MenuRect, "", GUI.skin.window);

                CurrentTab = GUI.Toolbar(new Rect(MenuRect.xMin, MenuRect.yMin, MenuRect.width, ToolbarHeight), CurrentTab,
                                         new GUIContent[]
                {
                    new GUIContent("Cheats"),
                    new GUIContent("Environment"),
                    new GUIContent("Player"),
                    new GUIContent("Spawn"),
                    new GUIContent("Inventory"),
                    new GUIContent("Coop"),
                    new GUIContent("Dev"),
                    new GUIContent("Game")
                },
                                         GUI.skin.GetStyle("Tabs"));

                Y = MenuRect.yMin + ToolbarHeight; //+ Padding

                switch (CurrentTab)
                {
                case 0:     // Cheats
                {
                    ScrollPosition = GUI.BeginScrollView(new Rect(MenuRect.xMin, Y, Width, Height - ToolbarHeight - 5), ScrollPosition, new Rect(0, 0, Width - 24, this.scroller));
                    Y = Padding;

                    UI.AddCheckBox(ref Cheat.GodMode, "God Mode");

                    if (UI.AddButton("Set Anchor"))
                    {
                        _Raft.AddAnchor(false);
                    }
                    IncreaseY(-30);
                    if (UI.AddButton("Remove Anchor", 220))
                    {
                        _Raft.RemoveAnchor(1);
                    }

                    this.scroller = Y + 15;
                    GUI.EndScrollView();
                    break;
                }

                case 1:     //Environment
                {
                    ScrollPosition = GUI.BeginScrollView(new Rect(MenuRect.xMin, Y, Width, Height - ToolbarHeight - 5), ScrollPosition, new Rect(0, 0, Width - 24, this.scroller));
                    Y = Padding;

                    UI.AddLabel("Time");
                    UI.AddCheckBox(ref Cheat.fixTimeScale, "Pause");
                    if (_AzureSkyController)
                    {
                        if (UI.AddButton("+1h"))
                        {
                            _AzureSkyController.timeOfDay.hour += 1f;
                            if (_AzureSkyController.timeOfDay.hour >= 24f)
                            {
                                _AzureSkyController.timeOfDay.StartNextDay(_AzureSkyController.options.repeatMode);
                            }
                        }

                        IncreaseY(-30);
                        if (UI.AddButton("-1h", 220))
                        {
                            _AzureSkyController.timeOfDay.hour -= 1f;
                            if (_AzureSkyController.timeOfDay.hour <= 0f)
                            {
                                _AzureSkyController.timeOfDay.hour = 23f;
                            }
                        }

                        UI.AddSlider(ref Cheat.fogDistance, 50, 5000, "Fog Distance");
                        if (UI.AddButton("Set"))
                        {
                            Shader.SetGlobalFloat(Shader.PropertyToID("_Azure_FogDistance"), Cheat.fogDistance);
                        }
                    }

                    UI.AddLabel("Weather");
                    if (Cheat._weatherPools.ContainsItems <WeatherPool>())
                    {
                        using (System.Collections.Generic.List <WeatherPool> .Enumerator enumerator = Cheat._weatherPools.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                Weather[] allItems = enumerator.Current.randomizer.GetAllItems <Weather>();
                                if (allItems.ContainsItems())
                                {
                                    Weather[] array = allItems;
                                    for (int i = 0; i < array.Length; i++)
                                    {
                                        Weather weather = array[i];
                                        if (UI.AddButton(weather.name))
                                        {
                                            _WeatherManager.SetWeather(weather.name, true);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    this.scroller = Y + 15;
                    GUI.EndScrollView();
                    break;
                }

                case 2:     //Player
                {
                    ScrollPosition = GUI.BeginScrollView(new Rect(MenuRect.xMin, Y, Width, Height - ToolbarHeight - 5), ScrollPosition, new Rect(0, 0, Width - 24, this.scroller));
                    Y = Padding;

                    UI.AddSlider(ref Cheat.SpeedMultiplier, 1, 20, "Player Speed");

                    if (UI.AddButton("Add Durability to HotSlot", 20, 300))
                    {
                        _Network_Player.Inventory.RemoveDurabillityFromHotSlot(-100);
                    }

                    this.scroller = Y + 15;
                    GUI.EndScrollView();
                    break;
                }

                case 3:     //Spawn
                {
                    break;
                }

                case 4:     //Inventory
                {
                    ScrollPosition = GUI.BeginScrollView(new Rect(MenuRect.xMin, Y, Width, Height - ToolbarHeight - 5), ScrollPosition, new Rect(0, 0, Width - 24, this.scroller));
                    Y = Padding;

                    var items = ItemManager.GetAllItems();
                    foreach (Item_Base current in items)
                    {
                        UnityEngine.GUI.Label(new Rect(20f, Y, 270f, 20f), current.UniqueName + " [" + current.UniqueIndex + "]", labelStyle);
                        if (UnityEngine.GUI.Button(new Rect(290f, Y, 40f, 20f), "+1"))
                        {
                            _Network_Player.Inventory.AddItem(current.UniqueName, 1);
                        }
                        if (UnityEngine.GUI.Button(new Rect(340f, Y, 40f, 20f), "+20"))
                        {
                            _Network_Player.Inventory.AddItem(current.UniqueName, 20);
                        }
                        Y += 30f;
                    }

                    this.scroller = Y + 15;
                    GUI.EndScrollView();
                    break;
                }

                case 5:     //Coop
                {
                    break;
                }

                case 6:     //Dev
                {
                    break;
                }

                case 7:     //Game
                {
                    ScrollPosition = GUI.BeginScrollView(new Rect(MenuRect.xMin, Y, Width, Height - ToolbarHeight - 5), ScrollPosition, new Rect(0, 0, Width - 24, this.scroller));
                    Y = Padding;

                    if (UI.AddButton("Go to Raft", 20, 300))
                    {
                        _Player.transform.position = _Raft.transform.position + (Vector3.up * 2);
                    }

                    this.scroller = Y + 15;
                    GUI.EndScrollView();
                    break;
                }
                }
            }
        }