void SetMenuPanelSelection(MenuSection ms)
    {
        if (ms == selectedMenuSection)
        {
            return;
        }
        else
        {
            switch (selectedMenuSection)
            {
            case MenuSection.Save:
                buttonsHolder.GetChild(SAVE_BTN_INDEX).GetComponent <Image>().overrideSprite = null;
                saveSystem.CloseButton();
                break;

            case MenuSection.Load:
                buttonsHolder.GetChild(LOAD_BTN_INDEX).GetComponent <Image>().overrideSprite = null;
                saveSystem.CloseButton();
                break;

            case MenuSection.Options:
                buttonsHolder.GetChild(OPTIONS_BTN_INDEX).GetComponent <Image>().overrideSprite = null;
                optionsPanel.SetActive(false);
                break;

            case MenuSection.Advice:
                buttonsHolder.GetChild(ADVICE_BTN_INDEX).GetComponent <Image>().overrideSprite = null;
                advicePanel.SetActive(false);
                break;
            }
            selectedMenuSection = ms;
            switch (selectedMenuSection)
            {
            case MenuSection.Save: buttonsHolder.GetChild(SAVE_BTN_INDEX).GetComponent <Image>().overrideSprite = PoolMaster.gui_overridingSprite; break;

            case MenuSection.Load: buttonsHolder.GetChild(LOAD_BTN_INDEX).GetComponent <Image>().overrideSprite = PoolMaster.gui_overridingSprite; break;

            case MenuSection.Options:
                buttonsHolder.GetChild(OPTIONS_BTN_INDEX).GetComponent <Image>().overrideSprite = PoolMaster.gui_overridingSprite;
                break;

            case MenuSection.Advice:
                buttonsHolder.GetChild(ADVICE_BTN_INDEX).GetComponent <Image>().overrideSprite = PoolMaster.gui_overridingSprite;
                advicePanel.GetComponent <AdvicesUI>().PrepareAdvice();
                advicePanel.SetActive(true);
                break;

            case MenuSection.NoSelection:
                break;
            }
        }
    }
Exemplo n.º 2
0
 public void SettingsButton()
 {
     if (saveSystem.gameObject.activeSelf)
     {
         saveSystem.CloseButton();
         saveButtonImage.overrideSprite = null;
         loadButtonImage.overrideSprite = null;
     }
     settingsPanel.SetActive(!settingsPanel.activeSelf);
 }
Exemplo n.º 3
0
    void SwitchVisualSelection(MenuSection ms)
    {
        if (ms == currentSection)
        {
            return;
        }
        if (currentSection != MenuSection.NoSelection)
        {
            switch (currentSection)
            {
            case MenuSection.NewGame:
                newGameButton.overrideSprite = null;
                newGamePanel.SetActive(false);
                break;

            case MenuSection.Loading:
                loadButton.overrideSprite = null;
                saveSystem.CloseButton();
                break;

            case MenuSection.Options:
                optionsButton.overrideSprite = null;
                optionsPanel.SetActive(false);
                break;

            case MenuSection.Editor:
                editorButton.overrideSprite = null;
                editorSettingPanel.SetActive(false);
                break;

            case MenuSection.Highscores:
                highscoresButton.overrideSprite = null;
                highscoresPanel.SetActive(false);
                break;

            case MenuSection.Authors:
                authorsButton.overrideSprite = null;
                authorsPanel.SetActive(false);
                authorsPanel.transform.GetChild(0).GetComponent <Text>().text = string.Empty;
                break;
            }
        }
        currentSection = ms;
        switch (currentSection)
        {
        case MenuSection.NewGame:
            newGameButton.overrideSprite = overridingSprite;
            newGamePanel.SetActive(true);
            NG_GenerateButton();
            break;

        case MenuSection.Loading:
            loadButton.overrideSprite = overridingSprite;
            saveSystem.Activate(false, false);
            break;

        case MenuSection.Options:
            if (!optionsPrepared)
            {
                var options = new List <Dropdown.OptionData>();
                foreach (string s in QualitySettings.names)
                {
                    options.Add(new Dropdown.OptionData(s));
                }
                qualityDropdown.options = options;

                options = new List <Dropdown.OptionData>()
                {
                    new Dropdown.OptionData("English"), new Dropdown.OptionData("Русский")
                };
                languageDropdown.options = options;

                optionsPrepared = true;
            }
            qualityDropdown.value = QualitySettings.GetQualityLevel();
            graphicsApplyButton.SetActive(false);
            languageDropdown.value       = Localization.currentLanguage == Language.English ? 0 : 1;
            optionsButton.overrideSprite = overridingSprite;
            optionsPanel.SetActive(true);
            break;

        case MenuSection.Editor:
            editorButton.overrideSprite = overridingSprite;
            editorSizeInputField.text   = Chunk.chunkSize.ToString();
            editorSettingPanel.SetActive(true);
            break;

        case MenuSection.Highscores:
            highscoresButton.overrideSprite = overridingSprite;
            RectTransform exampleItem = highscoresPanel.transform.GetChild(1).GetComponent <RectTransform>();
            var           highscores  = Highscore.GetHighscores();
            if (highscores == null)
            {
                exampleItem.GetChild(0).GetComponent <Text>().text        = Localization.GetPhrase(LocalizedPhrase.NoHighscores);
                exampleItem.GetChild(1).GetComponent <Text>().text        = string.Empty;
                exampleItem.GetChild(2).GetComponent <RawImage>().enabled = false;
                exampleItem.gameObject.SetActive(true);
            }
            else
            {
                Highscore h = highscores[0];
                exampleItem.GetChild(0).GetComponent <Text>().text = h.colonyName;
                exampleItem.GetChild(1).GetComponent <Text>().text = ((int)h.score).ToString();
                RawImage ri = exampleItem.GetChild(2).GetComponent <RawImage>();
                ri.uvRect  = GetEndGameIconRect(h.endType);
                ri.enabled = true;
                exampleItem.gameObject.SetActive(true);
                if (highscores.Length > 1)
                {
                    for (int i = 1; i < highscores.Length; i++)
                    {
                        RectTransform rt = Instantiate(exampleItem, exampleItem.parent);
                        rt.localPosition += Vector3.down * exampleItem.rect.height * (i - 1);
                        h = highscores[i];
                        if (h != null)
                        {
                            rt.GetChild(0).GetComponent <Text>().text = h.colonyName;
                            rt.GetChild(1).GetComponent <Text>().text = ((int)h.score).ToString();
                            ri         = rt.GetChild(2).GetComponent <RawImage>();
                            ri.uvRect  = GetEndGameIconRect(h.endType);
                            ri.enabled = true;
                        }
                    }
                }
            }
            highscoresPanel.SetActive(true);
            break;

        case MenuSection.Authors:
            authorsPanel.transform.GetChild(0).GetComponent <Text>().text = Localization.GetCredits();
            authorsPanel.SetActive(true);
            authorsButton.overrideSprite = overridingSprite;
            break;
        }
    }