Esempio n. 1
0
        public void ShowPopup()
        {
            //get a clone of the UIPopup, with the given PopupName, from the UIPopup Database
            UIPopup popup = UIPopup.GetPopup(PopupName);

            //make sure that a popup clone was actually created
            if (popup == null)
            {
                return;
            }

            //we assume (because we know) this UIPopup has a Title and a Message text objects referenced, thus we set their values
            popup.Data.SetLabelsTexts(Title, Message);

            //update the hide settings
            popup.HideOnBackButton     = HideOnBackButton;
            popup.HideOnClickAnywhere  = HideOnClickAnywhere;
            popup.HideOnClickOverlay   = HideOnClickOverlay;
            popup.HideOnClickContainer = HideOnClickContainer;

            //if the developer did not enable at least one hide option, make the UIPopup automatically hide itself (to avoid blocking the UI)
            if (!HideOnBackButton && !HideOnClickAnywhere && !HideOnClickOverlay && !HideOnClickContainer)
            {
                popup.AutoHideAfterShow      = true;
                popup.AutoHideAfterShowDelay = 3f;
                DDebug.Log("Popup '" + PopupName + "' is set to auto-hide in " + popup.AutoHideAfterShowDelay + " seconds because you did not enable any hide option");
            }

            popup.Show(); //show the popup
        }
Esempio n. 2
0
        public void ShowPopup(PopupType popupType)
        {
            //get a clone of the UIPopup, with the given PopupName, from the UIPopup Database
            m_popup = UIPopup.GetPopup(PopupName);

            //make sure that a popup clone was actually created
            if (m_popup == null)
            {
                return;
            }

            var icon    = m_popup.Data.Images[0];
            var title   = m_popup.Data.Labels[0].GetComponent <Text>(); //we know this has a Text component because we created it
            var message = m_popup.Data.Labels[1].GetComponent <Text>();

            switch (popupType)
            {
            case PopupType.Error:
                m_popup.Data.SetImagesSprites(ErrorSprite);                //set icon (we know we have one because we created this UIPopup with it)
                m_popup.Data.SetLabelsTexts(ErrorTitle, ErrorMessage);     //set the title and the message (we know they exist and their order because we created them)
                icon.color    = ErrorTextColor;                            //set the icon color (we use white icons, so we can set any tint color)
                title.color   = ErrorTextColor;                            //set title text color
                message.color = ErrorTextColor;                            //set message text color
                break;

            case PopupType.Info:
                m_popup.Data.SetImagesSprites(InfoSprite);               //set icon (we know we have one because we created this UIPopup with it)
                m_popup.Data.SetLabelsTexts(InfoTitle, InfoMessage);     //set the title and the message (we know they exist and their order because we created them)
                icon.color    = InfoTextColor;                           //set the icon color (we use white icons, so we can set any tint color)
                title.color   = InfoTextColor;                           //set title text color
                message.color = InfoTextColor;                           //set message text color
                break;

            case PopupType.Warning:
                m_popup.Data.SetImagesSprites(WarningSprite);                  //set icon (we know we have one because we created this UIPopup with it)
                m_popup.Data.SetLabelsTexts(WarningTitle, WarningMessage);     //set the title and the message (we know they exist and their order because we created them)
                icon.color    = WarningTextColor;                              //set the icon color (we use white icons, so we can set any tint color)
                title.color   = WarningTextColor;                              //set title text color
                message.color = WarningTextColor;                              //set message text color
                break;

            case PopupType.Whatever:
                m_popup.Data.SetImagesSprites(WhateverSprite);                   //set icon (we know we have one because we created this UIPopup with it)
                m_popup.Data.SetLabelsTexts(WhateverTitle, WhateverMessage);     //set the title and the message (we know they exist and their order because we created them)
                icon.color    = WhateverTextColor;                               //set the icon color (we use white icons, so we can set any tint color)
                title.color   = WhateverTextColor;                               //set title text color
                message.color = WhateverTextColor;                               //set message text color
                break;

            default: throw new ArgumentOutOfRangeException("popupType", popupType, null);
            }

            m_popup.Show(); //show the popup
        }
        public void ChangeScene(string _nextSceneName)
        {
            if (UICanvas.GetUICanvas("FadeCanvas") == null)
            {
                var fadeCanvas = UICanvas.CreateUICanvas("FadeCanvas");
                DontDestroyOnLoad(fadeCanvas);
                fadeCanvas.GetComponent <Canvas>().sortingOrder = 20000;
            }
            UIPopup fade = UIPopup.GetPopup("Fade");

            fade.GetComponent <FadeOverlay>().Show(_nextSceneName);
        }
Esempio n. 4
0
        public override void ShowPopup()
        {
            UIPopup popup = UIPopup.GetPopup(_name);

            if (popup != null)
            {
                popup.Show();
            }
            else
            {
                Debug.LogError("Popup is null");
            }
        }
        private void Start()
        {
            SetDateText(m_selectedDate); // set present day

            m_dateButton.OnClick.OnTrigger.Event.AddListener(() =>
            {
                UIPopup calendarPopup = UIPopup.GetPopup("CalendarPopup");
                calendarPopup.Show();
                calendarPopup.Data.Buttons[0].OnClick.OnTrigger.Event.AddListener(() =>
                {
                    m_selectedDate = calendarPopup.GetComponent <CalendarController>().GetSelectedDate();
                    SetDateText(m_selectedDate);
                });
            });
        }
    private void ShowPopup(UnlockResult newUnlock)
    {
        UIPopup popup = UIPopup.GetPopup(Popups.UNLOCK_POPUP);

        if (popup == null)
        {
            return;
        }

        PopupUnlock popupUnlock = popup.GetComponent <PopupUnlock>();

        popupUnlock.Setup(newUnlock);

        popup.Show();
    }
Esempio n. 7
0
        public void Show()
        {
            popup = UIPopup.GetPopup(prefabPopup.name);

            if (popup == null)
            {
                return;
            }

            popup.GetComponent <Popup>().SetImage(imageButton);

            popup.HideOnBackButton     = false;
            popup.HideOnClickAnywhere  = true;
            popup.HideOnClickOverlay   = true;
            popup.HideOnClickContainer = true;

            popup.AutoHideAfterShow = false;

            popup.Show();
        }
Esempio n. 8
0
    public void ShowDialogueText(DialogueData data)
    {
        Debug.Log($"#Dialogue#Data text: '{data.text}' and bool {data.HasText}");

        if (data.HasSprite)
        {
            _portrait.gameObject.SetActive(true);
            SetPortrait(data.sprite);
        }
        else
        {
            _portrait.gameObject.SetActive(false);
        }
        if (data.HasDescriptionImage)
        {
            _currentPopup?.Hide();
            _currentPopup = UIPopup.GetPopup(POPUP_NAME);
            SetDescriptionImage(data.descriptionSprite);
        }
        SetDialogue(data.text, data.name);
        ShowDialogueTween(CutDialog());
    }
Esempio n. 9
0
        public void ShowPopup()
        {
            //get a clone of the UIPopup, with the given PopupName, from the UIPopup Database
            m_popup = UIPopup.GetPopup(PopupName);

            //make sure that a popup clone was actually created
            if (m_popup == null)
            {
                return;
            }

            //we assume (because we know) this UIPopup has a Title and a Message text objects referenced, thus we set their values
            m_popup.Data.SetLabelsTexts(Title, Message);

            //get the values from the label input fields
            LabelButtonOne = LabelButtonOneInput.text;
            LabelButtonTwo = LabelButtonTwoInput.text;

            //set the button labels
            m_popup.Data.SetButtonsLabels(LabelButtonOne, LabelButtonTwo);

            //set the buttons callbacks as methods
            m_popup.Data.SetButtonsCallbacks(ClickButtonOne, ClickButtonTwo);

            //OR set the buttons callbacks as lambda expressions
            //m_popup.Data.SetButtonsCallbacks(() => { ClickButtonOne(); }, () => { ClickButtonTwo(); });

            //if the developer did not enable at least one button to hide it, make the UIPopup hide when its Overlay is clicked
            if (!HideOnButtonOne && !HideOnButtonTwo)
            {
                m_popup.HideOnClickOverlay = true;
                DDebug.Log("Popup '" + PopupName + "' is set to close when clicking its Overlay because you did not enable any hide option");
            }

            m_popup.Show(); //show the popup
        }
Esempio n. 10
0
    public static void ShowPopup(string target)
    {
        UIPopup popup = UIPopup.GetPopup(target);

        popup.Show();
    }
Esempio n. 11
0
 private void Editor_Popup()
 {
     _currentPopup = UIPopup.GetPopup(POPUP_NAME);
     _currentPopup.Show();
 }
Esempio n. 12
0
 public void OnClick()
 {
     UIPopup.GetPopup(m_popupName).Show();
 }
Esempio n. 13
0
 // Start is called before the first frame update
 void Start()
 {
     popup = UIPopup.GetPopup(popupName);
 }
Esempio n. 14
0
    void Start()
    {
        #region UI

        _point.Subscribe(_ =>
        {
            pointText.text = _point.Value.ToString();
        }).AddTo(this);

        #endregion

        #region main
        CurState.Where(s => s == GameState.None)
        .Subscribe(_ =>
        {
            gridsManager.Prepare(amount);
        }).AddTo(this);
        CurState.Where(s => s == GameState.Prepared)
        .DelayFrame(1)
        .Subscribe(_ =>
        {
            CurState.Value  = GameState.FirstEntities;
            _gridsHistories = UserData.data.Load <List <string> >("history", new List <string>());
            if (_gridsHistories.Count > 0)
            {
                gridsManager.HistoryToGrids(_gridsHistories[_gridsHistories.Count - 1]);
            }
            else
            {
                gridsManager.RandomGenerate();
                gridsManager.RandomGenerate(1);
                //_gridsManager.GeneralAt(0,0);
                //_gridsManager.GeneralAt(3,0);
                AddNowIntoHistory(gridsManager.GridsToHistory());
            }

            _point.Value   = gridsManager.points;
            CurState.Value = GameState.WaitInput;
        }).AddTo(this);


        CurState.Where(s => s == GameState.CheckOver)
        .Subscribe(_ =>
        {
            _point.Value = gridsManager.points;
            if (gridsManager.IsGameOver())
            {
                CurState.Value = GameState.Over;
            }
            else
            {
                CurState.Value = GameState.Generate;
            }
        }).AddTo(this);
        CurState.Where(s => s == GameState.Generate)
        .Subscribe(_ =>
        {
            gridsManager.RandomGenerate(1);
            AddNowIntoHistory(gridsManager.GridsToHistory());
            CurState.Value = GameState.WaitInput;
        }).AddTo(this);
        CurState.Where(s => s == GameState.Over)
        .Subscribe(_ =>
        {
            var bestScore = UserData.data.Load <int>("best", 0);
            bestScore     = Mathf.Max(bestScore, _point.Value);
            UserData.data.Save <int>("best", bestScore);
            UserData.Save("one game over");
            var popup = UIPopup.GetPopup("OverPop");
            if (popup == null)
            {
                return;
            }
            popup.Data.SetLabelsTexts("Game Over",
                                      $"Score:<indent=50%>{_point}</indent>",
                                      $"Best Score:<indent=50%>{bestScore}</indent>");
            popup.Data.SetButtonsCallbacks(() =>
            {
                UserData.data.DeleteKey("history");
                CurState.Value = GameState.None;
                if (popup != null)
                {
                    popup.Hide();
                }
            });
            popup.Show();
        }).AddTo(this);

        #endregion

        #region debug

        #if UNITY_EDITOR
        Observable.EveryUpdate()
        .Where(_ => CurState.Value == GameState.WaitInput && (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.W)))
        .Subscribe(_ =>
        {
            if (gridsManager.IsGameOver())
            {
                CurState.Value = GameState.Over;
            }
            else
            {
                CurState.Value = GameState.Move;
                if (Input.GetKeyDown(KeyCode.A))
                {
                    StartCoroutine(gridsManager.Move(MoveDir.Left));
                }
                if (Input.GetKeyDown(KeyCode.D))
                {
                    StartCoroutine(gridsManager.Move(MoveDir.Right));
                }
                if (Input.GetKeyDown(KeyCode.W))
                {
                    StartCoroutine(gridsManager.Move(MoveDir.Up));
                }
                if (Input.GetKeyDown(KeyCode.S))
                {
                    StartCoroutine(gridsManager.Move(MoveDir.Down));
                }
            }
        }).AddTo(this);
        #endif

        #endregion
    }
    // Used by assets
    public void ShowPopup(string popupName)
    {
        UIPopup popup = UIPopup.GetPopup(popupName);

        popup.Show();
    }
Esempio n. 16
0
        public void ShowExitPopup()
        {
            _popup = UIPopup.GetPopup("ExitGame");

            _popup.Show();
        }