Inheritance: MonoBehaviour
Exemplo n.º 1
0
    void LoadTreasureChestsToggleOptions()
    {
        // Get map UI options
        GameOptions.Instance.mapUIOpt.toggleTreasureChests = PlayerPrefs.GetInt("MapUIShowTreasureChests", 0); // default 0 - disable "always show heroes names" toggle
        // Get toggle
        TextToggle textToggle = MapOptions.transform.Find("ToggleTreasureChests").GetComponent <TextToggle>();

        // verify if it was enabled before
        if (GameOptions.Instance.mapUIOpt.toggleTreasureChests == 0)
        {
            // disable toggle
            textToggle.selected = false;
            textToggle.SetNormalStatus();
            // hide cities names
            MapManager.Instance.SetTreasureChestsVisible(false);
        }
        else
        {
            // enable toggle
            textToggle.selected = true;
            textToggle.SetPressedStatus();
            // always show city names
            MapManager.Instance.SetTreasureChestsVisible(true);
        }
    }
Exemplo n.º 2
0
        public PlaceholderPageViewModel()
        {
            EffectOn.Value = true;


            ColorToggle.Subscribe(x => {
                PlaceColor.Value = x ? Color.Silver : Color.Red;
            });

            TextToggle.Subscribe(x => {
                PlaceText.Value = x ? "Placeholder Text" :
                                  "Placeholder Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text End";
            });

            ColorToggle.Value = true;
            TextToggle.Value  = true;

            ChangeTextCommand.Subscribe(_ => {
                if (string.IsNullOrEmpty(EditText.Value))
                {
                    EditText.Value = "Abcdef";
                }
                else
                {
                    EditText.Value = "";
                }
            });
        }
Exemplo n.º 3
0
 void DeleteSaveUI(TextToggle selectedToggle)
 {
     // remove current toggle
     Destroy(selectedToggle.gameObject);
     // select other save on next frame if there is any present
     StartCoroutine(savesMenu.SelectLastestSave());
 }
Exemplo n.º 4
0
    void LoadPlayerIncomeToggleOptions()
    {
        // Get map UI options
        GameOptions.Instance.mapUIOpt.togglePlayerIncome = PlayerPrefs.GetInt("MapUIShowPlayerIncome", 0); // default 0 - disable "always show heroes names" toggle
        // Get toggle
        TextToggle textToggle = MapOptions.transform.Find("TogglePlayerIncome").GetComponent <TextToggle>();

        // verify if it was enabled before
        if (GameOptions.Instance.mapUIOpt.togglePlayerIncome == 0)
        {
            // disable toggle
            textToggle.selected = false;
            textToggle.SetNormalStatus();
            // hide player income
            SetPlayerIncomeVisible(false);
        }
        else
        {
            // enable toggle
            textToggle.selected = true;
            textToggle.SetPressedStatus();
            // show player income
            SetPlayerIncomeVisible(true);
        }
    }
Exemplo n.º 5
0
 public void SetActive(ColorsConfig colorsConfig, UnityAction SaveEvent, UnityAction CancelEvent)
 {
     // remove possible previous listeners attached to this button
     saveButton.OnClick.RemoveAllListeners();
     // setup our listener
     saveButton.OnClick.AddListener(SaveEvent);
     saveButton.OnClick.AddListener(Close);
     // same for Cancel button
     cancelButton.OnClick.RemoveAllListeners();
     cancelButton.OnClick.AddListener(CancelEvent);
     cancelButton.OnClick.AddListener(Close);
     // loop through all colors in config
     foreach (Color color in colorsConfig.colors)
     {
         // create color toggle
         TextToggle colorToggle = Instantiate(colorToggleTemplate.gameObject, colorsToggleGroup.transform).GetComponent <TextToggle>();
         // set color toggle group
         colorToggle.toggleGroup = colorsToggleGroup;
         // activate toggle
         colorToggle.gameObject.SetActive(true);
         // set color
         colorToggle.GetComponentInChildren <RawImage>().color = color;
     }
     // preselect first toggle by simulating mouse click on it
     colorsToggleGroup.GetComponentsInChildren <TextToggle>()[0].ActOnLeftMouseClick();
     // activate this menu
     gameObject.SetActive(true);
 }
Exemplo n.º 6
0
 public void DeselectToggle()
 {
     selectedToggle.TurnOff();
     // clean up selectedToggle
     selectedToggle = null;
     // trigger regiestered functions
     OnToggleTurnOff.Invoke();
 }
Exemplo n.º 7
0
 public void DeleteSave()
 {
     Debug.Log("Delete save");
     // querry toggle group for currently selected toggle
     selectedToggle = savesMenu.GetComponent <TextToggleGroup>().GetSelectedToggle();
     // verify if there is any toggle selected now
     if (selectedToggle == null)
     {
         // no any save available
         // show error message
         string errMsg = "Error: no any save.";
         NotificationPopUp.Instance().DisplayMessage(errMsg);
     }
     else
     {
         // toggle is selected
         //  get file name from selected save
         string fileName = selectedToggle.GetComponent <Save>().SaveName;
         // verify if file name is set
         if (fileName == "")
         {
             // file name is empty
             string errMsg = "Error: file name is empty.";
             NotificationPopUp.Instance().DisplayMessage(errMsg);
         }
         else
         {
             //  construct full file name
             fullFilePath = ConfigManager.Instance.GameSaveConfig.GetSaveFullNameByFileName(fileName); // Application.persistentDataPath + "/" + fileName + fileExtension;
             Debug.Log("File name is " + fullFilePath + "");
             // verify if file exists
             if (File.Exists(fullFilePath))
             {
                 // file exists
                 // Ask user whether he wants to delete save
                 ConfirmationPopUp confirmationPopUp = ConfirmationPopUp.Instance();
                 // set actions
                 UnityAction YesAction = new UnityAction(OnDeleteSaveYesConfirmation);
                 UnityAction NoAction  = new UnityAction(OnDeleteSaveNoConfirmation);
                 // set message
                 string confirmationMessage = "Do you want to delete '" + selectedToggle.name + "' save?";
                 // send actions to Confirmation popup, so he knows how to react on no and yes btn presses
                 confirmationPopUp.Choice(confirmationMessage, YesAction, NoAction);
             }
             else
             {
                 // display error message
                 string errMsg = "Error: [" + fullFilePath + "] file not found. Please try to exit 'Load' menu and open it again.";
                 NotificationPopUp.Instance().DisplayMessage(errMsg);
                 // remove UI element
                 Destroy(selectedToggle.gameObject);
             }
         }
     }
 }
Exemplo n.º 8
0
 void SetSelectedSave(TextToggle saveToggle)
 {
     //// verify if we already have any save selected
     //if (selectedSave != null)
     //{
     //    // deleselect prevoius save
     //    DeselectSave();
     //}
     // select new save
     SelectSave(saveToggle.GetComponent <Save>());
 }
Exemplo n.º 9
0
        // 新建一个大任务
        public TextToggle CreateTask(string text, bool ison = false, bool isclose = false)
        {
            TextToggle textToggle = new TextToggle(text, ison, isclose);

            textToggle.UpdateToggleList();

            MyList.Children.Add(textToggle); // 添加到主列表中
            allTask.Add(textToggle);         // 添加到集合中统一管理

            textToggle.onSelect += OnSelectTextToggle;

            return(textToggle);
        }
Exemplo n.º 10
0
 public void SetSelectedToggle(TextToggle toggle)
 {
     // verify if we already have any toggle selected
     if (selectedToggle != null)
     {
         // deleselect prevoius toggle
         DeselectToggle();
     }
     // select new toggle
     SelectToggle(toggle);
     // trigger regiestered functions
     OnToggleTurnOn.Invoke(toggle);
 }
Exemplo n.º 11
0
 void SetUniqueAbilitiesActive(bool doActivate)
 {
     // verify if we need to activate or deactivate abilities list
     if (doActivate)
     {
         // loop through all possible unique abilities configs
         foreach (UniqueAbilityConfig uniqueAbilityConfig in ConfigManager.Instance.UniqueAbilityConfigs)
         {
             // verify this ability is applicable only to specific factions
             if (uniqueAbilityConfig.doLimitUsageByFaction)
             {
                 // verify if that ability is allowed for this Faction
                 if (Array.Exists(uniqueAbilityConfig.applicableToFactions, element => element == factionSelectionGroup.GetSelectedFaction()))
                 {
                     TextToggle uniqueAbilityToggle = CreateNewAbilityToggle(uniqueAbilityConfig);
                     // adjust text color and toggle color schema to represent Faction-specific ability
                     uniqueAbilityToggle.GetComponent <Text>().color = factionSpecificAbilityNormalColor;
                     uniqueAbilityToggle.NormalColor      = factionSpecificAbilityNormalColor;
                     uniqueAbilityToggle.HighlightedColor = factionSpecificAbilityHighlightedColor;
                     uniqueAbilityToggle.PressedColor     = factionSpecificAbilityPressedColor;
                 }
             }
             else
             {
                 CreateNewAbilityToggle(uniqueAbilityConfig);
             }
         }
         // preselect first toggle
         uniqueAbilitiesToggleGroup.GetComponentsInChildren <TextToggle>()[0].ActOnLeftMouseClick();
     }
     else
     {
         // remove all previus abilities
         RecycleBin.RecycleChildrenOf(uniqueAbilitiesToggleGroup.gameObject);
         //// loop through all abilities in UI
         //foreach(Transform t in uniqueAbilitiesToggleGroup.transform)
         //{
         //    // move toggle to recycle bin and destroy it (move is required, because actual destroy is being done at the end of the frame,
         //    // but we need to preselect new toggle on reset SetUniqueAbilitiesActive(false/true)
         //    t.SetParent(RecycleBin.Instance.transform);
         //    Debug.Log("Destroy " + t.name);
         //    Destroy(t.gameObject);
         //}
     }
 }
Exemplo n.º 12
0
    TextToggle CreateNewAbilityToggle(UniqueAbilityConfig uniqueAbilityConfig)
    {
        // create toggle in UI
        TextToggle uniqueAbilityToggle = Instantiate(uniqueAbilityToggleTemplate.gameObject, uniqueAbilitiesToggleGroup.transform).GetComponent <TextToggle>();

        // set toggle group
        uniqueAbilityToggle.toggleGroup = uniqueAbilitiesToggleGroup;
        // set unique ability name
        uniqueAbilityToggle.GetComponent <Text>().text = uniqueAbilityConfig.displayName;
        // Set unique ability description
        foreach (Text text in uniqueAbilityToggle.GetComponentsInChildren <Text>())
        {
            // verify if we are not getting toggle = we are getting description
            if (text.gameObject != uniqueAbilityToggle.gameObject)
            {
                text.text = uniqueAbilityConfig.description;
            }
        }
        // set unique ability reference
        uniqueAbilityToggle.GetComponent <UniqueAbilitySelector>().UniqueAbilityConfig = uniqueAbilityConfig;
        // return reference to the new toggle
        return(uniqueAbilityToggle);
    }
Exemplo n.º 13
0
        public SizeToFitPageViewModel()
        {
            EffectOn.Value = false;

            LabelHeight.Value = 40f;

            TextToggle.Subscribe(x => {
                if (!x)
                {
                    LabelText.Value = "ShortTextEnd";
                }
                else
                {
                    LabelText.Value = "LongTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextEnd";
                }
            });

            HeightToggle.Subscribe(x => {
                if (x)
                {
                    LabelHeight.Value = 400f;
                }
                else
                {
                    LabelHeight.Value = 40f;
                }
            });

            WidthToggle.Subscribe(x => {
                if (x)
                {
                    LabelWidth.Value = 320f;
                }
                else
                {
                    LabelWidth.Value = 150f;
                }
            });

            FontToggle.Subscribe(x => {
                if (x)
                {
                    FontSize.Value = 28f;
                }
                else
                {
                    FontSize.Value = 14f;
                }
            });


            ExpandToggle.Subscribe(x => {
                CanExpand.Value = x;
            });
            ExpandToggle.Value = true;

            HAlignCommand.Subscribe(_ => {
                if (TextAlign.Value == TextAlignment.Start)
                {
                    TextAlign.Value = TextAlignment.Center;
                }
                else if (TextAlign.Value == TextAlignment.Center)
                {
                    TextAlign.Value = TextAlignment.End;
                }
                else if (TextAlign.Value == TextAlignment.End)
                {
                    TextAlign.Value = TextAlignment.Start;
                }
            });

            VAlignCommand.Subscribe(_ => {
                if (VTextAlign.Value == TextAlignment.Start)
                {
                    VTextAlign.Value = TextAlignment.Center;
                }
                else if (VTextAlign.Value == TextAlignment.Center)
                {
                    VTextAlign.Value = TextAlignment.End;
                }
                else if (VTextAlign.Value == TextAlignment.End)
                {
                    VTextAlign.Value = TextAlignment.Start;
                }
            });
        }
Exemplo n.º 14
0
 public void RemoveTask(TextToggle item)
 {
     allTask.Remove(item);
     MyList.Children.Remove(item);
 }
Exemplo n.º 15
0
    public void Load()
    {
        Debug.Log("Load save");
        // querry toggle group for currently selected toggle
        TextToggle selectedToggle = savesMenu.GetComponent <TextToggleGroup>().GetSelectedToggle();

        // verify if there is any toggle selected now
        if (selectedToggle == null)
        {
            // no any save available
            // show error message
            string errMsg = "Error: no any save.";
            NotificationPopUp.Instance().DisplayMessage(errMsg);
        }
        else
        {
            // toggle is selected
            //  get file name from selected save
            string fileName = selectedToggle.GetComponent <Save>().SaveName;
            // verify if file name is set
            if (fileName == "")
            {
                // file name is empty
                string errMsg = "Error: file name is empty.";
                NotificationPopUp.Instance().DisplayMessage(errMsg);
            }
            else
            {
                //  construct full file name
                fullFilePath = ConfigManager.Instance.GameSaveConfig.GetSaveFullNameByFileName(fileName); // Application.persistentDataPath + "/" + fileName + fileExtension;
                //Debug.Log("File name is " + fullFilePath + "");
                // verify if file exists
                if (File.Exists(fullFilePath))
                {
                    // file exists
                    // verify if game is already running
                    // check if there is a Chapter in World
                    if (World.Instance.GetComponentInChildren <Chapter>(true) != null)
                    {
                        // game is already running
                        // Ask user whether he wants to load new game
                        ConfirmationPopUp confirmationPopUp = ConfirmationPopUp.Instance();
                        // set actions
                        UnityAction YesAction = new UnityAction(OnLoadSaveYesConfirmation);
                        UnityAction NoAction  = new UnityAction(OnLoadSaveNoConfirmation);
                        // set message
                        string confirmationMessage = "Do you want to terminate current game and load saved game? Not saved progress will be lost.";
                        // send actions to Confirmation popup, so he knows how to react on no and yes btn presses
                        confirmationPopUp.Choice(confirmationMessage, YesAction, NoAction);
                    }
                    else
                    {
                        // game is not running yet
                        // Load game data
                        LoadGameData();
                    }
                }
                else
                {
                    string errMsg = "Error: [" + fullFilePath + "] file not found. Please verify if file is present on disk drive.";
                    NotificationPopUp.Instance().DisplayMessage(errMsg);
                }
            }
        }
    }
Exemplo n.º 16
0
 public void OnSelectTextToggle(TextToggle textToggle)
 {
     // 选中焦点盒子
     curTextToggle = textToggle;
 }
Exemplo n.º 17
0
 void SelectToggle(TextToggle toggle)
 {
     // toggle selected toggle
     selectedToggle = toggle;
 }