Beispiel #1
0
        //Function for switching screens with buttons
        public void NextScreen()
        {
            if (_currentPage < _screens - 1)
            {
                if (!_lerp)
                {
                    StartScreenChange();
                }

                _lerp       = true;
                CurrentPage = _currentPage + 1;
                GetPositionforPage(_currentPage, ref _lerp_target);
                ScreenChange();

                VisibleCharacterUI.visibleCharacterUI.SetVisible(CurrentPage);

                if (PlayerPrefs.GetInt("charBuy_" + CurrentPage.ToString()) == 0)
                {
                    if (CurrentPage != 1)
                    {
                        levelGenerator.costText.text = "<sprite=0>" + 200;
                        charCost = 200;
                    }
                    else
                    {
                        levelGenerator.costText.text = "<sprite=0>" + 500;
                        charCost = 500;
                    }

                    levelGenerator.SetPipersName_(CurrentPage);
                    levelGenerator.BuyBtn.interactable = true;
                }
                else
                {
                    levelGenerator.BuyBtn.interactable = false;
                    levelGenerator.SetPipersName(CurrentPage);
                    levelGenerator.buyedText.text = "bought";
                }

                if (PlayerPrefs.GetInt("enabled_") == CurrentPage)
                {
                    levelGenerator.indicator.SetActive(true);
                }
                else
                {
                    levelGenerator.indicator.SetActive(false);
                }

                if (CurrentPage == 0)
                {
                    levelGenerator.BtnActivity(true, false);
                }
                else if (CurrentPage == 11)
                {
                    levelGenerator.BtnActivity(false, true);
                }
                else
                {
                    levelGenerator.BtnActivity(true, true);
                }
            }
        }
Beispiel #2
0
        // Use this for initialization
        void Awake()
        {
            if (scrollSnapBase == null)
            {
                scrollSnapBase = this;
            }
            levelGenerator = FindObjectOfType <LevelGenerator>();

            if (!PlayerPrefs.HasKey("charBuy_0"))
            {
                PlayerPrefs.SetInt("charBuy_0", 1);
                PlayerPrefs.SetInt("enabled_", 0);
                levelGenerator.BtnActivity(true, false);
                levelGenerator.BuyBtn.interactable = false;
                levelGenerator.buyedText.text      = "piper hero!";
                levelGenerator.SetPipersName(0);

                FindObjectOfType <VisibleCharacterUI>().SetVisible(0);

                for (int i = 1; i < 12; i++)
                {
                    PlayerPrefs.SetInt("charBuy_" + i.ToString(), 0);
                }
            }

            if (PlayerPrefs.HasKey("enabled_"))
            {
                StartingScreen = PlayerPrefs.GetInt("enabled_");
                levelGenerator.BuyBtn.interactable = false;
                FindObjectOfType <VisibleCharacterUI>().SetVisible(StartingScreen);

                if (StartingScreen == 0)
                {
                    levelGenerator.buyedText.text = "piper hero!";
                    levelGenerator.BtnActivity(true, false);
                }
                else
                {
                    levelGenerator.buyedText.text = "bought";
                }

                levelGenerator.SetPipersName(StartingScreen);
                if (StartingScreen == 11)
                {
                    levelGenerator.BtnActivity(false, true);
                }
            }

            if (_scroll_rect == null)
            {
                _scroll_rect = gameObject.GetComponent <ScrollRect>();
            }
            if (_scroll_rect.horizontalScrollbar && _scroll_rect.horizontal)
            {
                var hscroll = _scroll_rect.horizontalScrollbar.gameObject.AddComponent <ScrollSnapScrollbarHelper>();
                hscroll.ss = this;
            }
            if (_scroll_rect.verticalScrollbar && _scroll_rect.vertical)
            {
                var vscroll = _scroll_rect.verticalScrollbar.gameObject.AddComponent <ScrollSnapScrollbarHelper>();
                vscroll.ss = this;
            }
            panelDimensions = gameObject.GetComponent <RectTransform>().rect;

            if (StartingScreen < 0)
            {
                StartingScreen = 0;
            }

            _screensContainer = _scroll_rect.content;

            InitialiseChildObjects();

            if (NextButton)
            {
                NextButton.GetComponent <Button>().onClick.AddListener(() => { NextScreen(); });
            }

            if (PrevButton)
            {
                PrevButton.GetComponent <Button>().onClick.AddListener(() => { PreviousScreen(); });
            }
        }