Ejemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     generationProgressText.gameObject.SetActive(true);
     npnProgressText.gameObject.SetActive(false);
     
     PlayerStats.SetTutorialStepCompleted(TutorialStep.GoToCollection);
     // pageSwiper will force a pageChanged, which will complete SwipeCollection, so SetActive should be above pageSwiper filling
     tutorialSwipeCollectionPanel.SetActive(PlayerStats.GetShowTutorialStep(TutorialStep.SwipeCollection));
     pageSwiper = pageHolder.GetComponent<PageSwiper>();
     singleNPNPageSwiper = singleNPNPageHolder.GetComponent<PageSwiper>();
     singleCardImage = singleCard.GetComponent<Image>();
     favoriteButtonImage = favoriteButton.GetComponent<Image>();
     generationDropdown.ClearOptions();
     for (int i = 1; i <= CardFactory.numberOfGenerations; i++)
     {
         if (PlayerStats.IsGenerationUnlocked(i))
         {
             generationDropdown.options.Add(new TMP_Dropdown.OptionData("Gen " + i));
         }
     }
     generationDropdown.value = GameManager.SelectedGeneration - 1;
     // if GameManager.SelectedGeneration != 1, then line above will have triggered OnGenerationChanged
     if (GameManager.SelectedGeneration == 1)
     {
         OnGenerationChanged(generationDropdown);
     }
 }
Ejemplo n.º 2
0
    public void OnGenerationChanged(TMP_Dropdown dd)
    {
        // Destroy stuff of old generation
        foreach (GameObject page in pages.Values)
        {
            GameObject.Destroy(page);
        }
        pages.Clear();
        maxPageFilled = 0;

        GameManager.SelectedGeneration = generationDropdown.value + 1;
        generationProgressText.text = "You own cards for " + PlayerStats.GetGeneration(GameManager.SelectedGeneration).cards.Count + " out of " + CardFactory.numberOfNPNsInGeneration[GameManager.SelectedGeneration]
                                        + "\r\nNational Pokedex Numbers of this generation";
        // set up pages for new generation
        int totalPages = (CardFactory.numberOfNPNsInGeneration[GameManager.SelectedGeneration] + pageSize - 1) / pageSize;
        pageSwiper.totalPages = totalPages;
        RectTransform phRectTransform = pageHolder.GetComponent<RectTransform>();
        phRectTransform.sizeDelta = new Vector2(900 * totalPages, phRectTransform.sizeDelta.y);
        generation = PlayerStats.GetGeneration(GameManager.SelectedGeneration);
        for (int pageNumber = 0; pageNumber < totalPages; pageNumber++)
        {
            GameObject page = GameObject.Instantiate(pagePrefab);
            pages.Add(pageNumber, page);
            page.transform.SetParent(pageHolder.transform);
            page.transform.localPosition = new Vector3(900 * pageNumber, 0f, 0f);
            page.transform.localScale = new Vector3(1f, 1f, 1f);
        }
        numberOfDoubles = PlayerStats.CheckDoubles(GameManager.SelectedGeneration);
        doublesButton.SetActive(numberOfDoubles > 0);
        // 8 in 15000 chance that you get a double in your first pack
        tutorialTurnInDoublesPanel.SetActive(numberOfDoubles > 0 && PlayerStats.GetShowTutorialStep(TutorialStep.TurnInDoubles));
        // pageSwiper will publish event pageChanged which will fill some pages
        pageSwiper.BackToPage1();
    }
Ejemplo n.º 3
0
 public void OnYesTradeClick()
 {
     PlayerStats.TradeInDoubles(GameManager.SelectedGeneration);
     numberOfDoubles = 0;
     doublesButton.SetActive(false);
     turnInDoublesPanel.SetActive(false);
 }
Ejemplo n.º 4
0
 public void OnPointerClick(PossibleCard ownedCard, Image image)
 {
     if (singleNPNPageHolder.activeSelf)
     {
         // from NPN to singleCard
         PlayerStats.SetTutorialStepCompleted(TutorialStep.ZoomCard);
         tutorialZoomCardPanel.SetActive(false);
         singleCardImage.sprite = image.sprite;
         currentSingle = ownedCard;
         SetFavoriteButtonColor(ownedCard.id.Equals(PlayerStats.GetFavorite(ownedCard.nationalPokedexNumber)));
         favoriteButton.SetActive(true);
         tutorialMakeFavoritePanel.SetActive(PlayerStats.GetShowTutorialStep(TutorialStep.MakeFavorite));
         singleNPNPageHolder.SetActive(false);
         npnProgressText.gameObject.SetActive(false);
         singleCard.SetActive(true);
     }
     else
     {
         // for people clicking before swiping
         PlayerStats.SetTutorialStepCompleted(TutorialStep.SwipeCollection);
         tutorialSwipeCollectionPanel.SetActive(false);
         // for people with the 8 in 15000 chance AND clicking before swiping
         tutorialTurnInDoublesPanel.SetActive(false);
         // from generation to NPN
         SingleNPNStart(ownedCard.nationalPokedexNumber);
     }
 }
Ejemplo n.º 5
0
 private void SingleNPNStart(int nationalPokedexNumber)
 {
     tutorialZoomCardPanel.SetActive(PlayerStats.GetShowTutorialStep(TutorialStep.ZoomCard));
     GameManager.selectedNPN = nationalPokedexNumber;
     generation = PlayerStats.GetGeneration(GameManager.SelectedGeneration);
     cardsOfNumber = generation.cards[nationalPokedexNumber];
     npnProgressText.text = "You own " + cardsOfNumber.Count + " out of " + CardFactory.GetNumberOfAvailableCards(GameManager.SelectedGeneration, nationalPokedexNumber)
                                     + "\r\ncards of this National Pokedex Number " + nationalPokedexNumber;
     // set up pages for new NPN
     int totalPages = (cardsOfNumber.Count + pageSize - 1) / pageSize;
     singleNPNPageSwiper = singleNPNPageHolder.GetComponent<PageSwiper>();
     singleNPNPageSwiper.totalPages = totalPages;
     RectTransform phRectTransform = singleNPNPageHolder.GetComponent<RectTransform>();
     phRectTransform.sizeDelta = new Vector2(900 * totalPages, phRectTransform.sizeDelta.y);
     for (int pageNumber = 0; pageNumber < totalPages; pageNumber++)
     {
         GameObject page = GameObject.Instantiate(pagePrefab);
         singleNPNPages.Add(pageNumber, page);
         page.transform.SetParent(singleNPNPageHolder.transform);
         page.transform.localPosition = new Vector3(900 * pageNumber, 0f, 0f);
         page.transform.localScale = new Vector3(1f, 1f, 1f);
     }
     // pageSwiper will publish event pageChanged which will fill some pages
     pageHolder.SetActive(false);
     generationDropdown.gameObject.SetActive(false);
     generationProgressText.gameObject.SetActive(false);
     singleNPNPageHolder.SetActive(true);
     npnProgressText.gameObject.SetActive(true);
     singleNPNPageSwiper.BackToPage1();
 }
Ejemplo n.º 6
0
    private void FillPage(int pageNumber, GameObject page)
    {
        for (int i = 0; i < pageSize; i++)
        {
            int nationalPokedexNumber = CardFactory.startNPNOfGeneration[GameManager.SelectedGeneration] + i + pageNumber * pageSize;
            if (nationalPokedexNumber < CardFactory.startNPNOfGeneration[GameManager.SelectedGeneration] + CardFactory.numberOfNPNsInGeneration[GameManager.SelectedGeneration])
            {
                if (generation.cards.ContainsKey(nationalPokedexNumber))
                { // we own cards of this NationalPokedexNumber
                    Dictionary<string, PossibleCard> cardsOfNumber = generation.cards[nationalPokedexNumber];
                    string favorite = PlayerStats.GetFavorite(nationalPokedexNumber);
                    PossibleCard lastFoundOrFavorite = null;
                    if (favorite != null)
                    {
                        lastFoundOrFavorite = cardsOfNumber[favorite];
                    }
                    if (lastFoundOrFavorite == null)
                    {
                        lastFoundOrFavorite = cardsOfNumber.Values.OrderBy(p => p.foundOn).Last();
                    }
                    PlaceSmallCard(lastFoundOrFavorite, page);
                }
                else if (CardFactory.GetNumberOfAvailableCards(GameManager.SelectedGeneration, nationalPokedexNumber) > 0)
                { // leave empty placeholder? show greyed-out back?
                    PlaceEmptyPanel(nationalPokedexNumber, page);
                } else
                {
                    PlaceUnavailablePanel(nationalPokedexNumber, page);
                }

                LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)page.transform);
            }
        }
    }
Ejemplo n.º 7
0
 public void OnFavoriteClick()
 {
     PlayerStats.SetTutorialStepCompleted(TutorialStep.MakeFavorite);
     tutorialMakeFavoritePanel.SetActive(false);
     SetFavoriteButtonColor(PlayerStats.ToggleFavorite(currentSingle));
     // yes, now smallImage contains a largeImage, but it's already loaded so I don't care
     smallImages[currentSingle.nationalPokedexNumber].sprite = singleCardImage.sprite;
 }
Ejemplo n.º 8
0
    public void OnDoublesClick()
    {
        PlayerStats.SetTutorialStepCompleted(TutorialStep.TurnInDoubles);
        tutorialTurnInDoublesPanel.SetActive(false);
        // small chance AND trade doubles before click or swipe
        PlayerStats.SetTutorialStepCompleted(TutorialStep.SwipeCollection);
        tutorialSwipeCollectionPanel.SetActive(false);
        doublesText.text = string.Format("You have\r\n{0} double card(s)\r\nof this generation.\r\n\r\nDo you want to\r\ntrade them for\r\nClick - Power?", numberOfDoubles);

        finalClickPowerText.text = string.Format("Your Click-Power\r\nwill go from\r\n{0:0.00} to {1:0.00}",
            PlayerStats.GetClickPower() / (float)GameManager.coinFactor,
            (PlayerStats.GetClickPower() + numberOfDoubles) / (float)GameManager.coinFactor);
        turnInDoublesPanel.SetActive(true);
    }
Ejemplo n.º 9
0
 public void OnPageChanged()
 {
     // pageSwiper pages start at 1, we start at 0
     int currentPage = pageSwiper.currentPage - 1;
     int newMax = Mathf.Min(pageSwiper.totalPages, currentPage + 2);
     for (int pageNumber = maxPageFilled; pageNumber < newMax; pageNumber++)
     {
         FillPage(pageNumber, pages[pageNumber]);
     }
     maxPageFilled = Mathf.Max(maxPageFilled, newMax);
     if (currentPage > 0)
     {
         PlayerStats.SetTutorialStepCompleted(TutorialStep.SwipeCollection);
         tutorialSwipeCollectionPanel.SetActive(false);
     }
 }