Пример #1
0
 public void TestGetRerollSkip()
 {
     Assert.AreEqual(0, RerollManager.getRerollSkip(0));
     Assert.AreEqual(0, RerollManager.getRerollSkip(1));
     Assert.AreEqual(2, RerollManager.getRerollSkip(5));
     Assert.AreEqual(3, RerollManager.getRerollSkip(10));
     Assert.AreEqual(5, RerollManager.getRerollSkip(50));
     Assert.AreEqual(6, RerollManager.getRerollSkip(100));
     Assert.AreEqual(9, RerollManager.getRerollSkip(1000));
 }
Пример #2
0
    void showWinLosePanel(Color panelColor, Color textColor, Result result)
    {
        // Show panel
        victoryPanel.SetActive(true);
        victoryPanel.GetComponent <Image>().color = panelColor;
        Text victoryText = victoryPanel.GetComponentInChildren <Text>();

        victoryText.text = (result == Result.VICTORY) ? TextScript.get(TextScript.Sentence.VICTORY)
            : TextScript.get(TextScript.Sentence.DEFEAT);
        victoryText.color = textColor;
        victoryPanel.GetComponentInChildren <Outline>().effectColor = panelColor;
        Text returnText = victoryPanel.GetComponentInChildren <Button>().GetComponentInChildren <Text>();

        returnText.text = TextScript.get(TextScript.Sentence.RETURN);

        // Move help text panel
        RectTransform helpTextPanelrt = helpTextPanel.GetComponent <RectTransform>();

        helpTextPanel.transform.SetParent(victoryPanel.transform);
        helpTextPanelrt.anchoredPosition = new Vector2(50, 0);
        helpText.text = "";
        helpTextPanel.SetActive(true);

        // Add exp
        if (result == Result.VICTORY && !isTutorial)
        {
            double rewardExp = CardFactory.getAbsoluteCardPoints(enemy.difficultyId);
            // Enemy difficulty bonus
            rewardExp = System.Math.Floor(rewardExp * (1 + System.Math.Pow(enemy.difficultyId / 5d, 1.75d)) * Player.expModifier);
            // Arm aspect bonus
            foreach (ArmManager.ArmAspect armAspect in enemy.armAspects)
            {
                switch (armAspect)
                {
                case ArmManager.ArmAspect.SILVER:
                    rewardExp = System.Math.Floor(rewardExp * 1.25f);
                    break;

                case ArmManager.ArmAspect.GOLD:
                    rewardExp = System.Math.Floor(rewardExp * 1.5f);
                    break;
                }
            }
            // Add exp to player
            rewardExp = Player.gainExp(rewardExp);
            GameObject.Find("ExpText").GetComponent <Text>().text = "(+" + NumberStringConverter.convert(rewardExp) +
                                                                    " " + TextScript.get(TextScript.Sentence.EXP) + ")";
        }
        else
        {
            GameObject.Find("ExpText").GetComponent <Text>().text = "";
        }

        // Show prize cards
        Card[]    prizeCards     = getPrizeCards(result, enemy.difficultyId);
        Transform prizeCardPanel = victoryPanel.transform.Find("PrizeCardPanel");

        foreach (Card c in prizeCards)
        {
            Player.getNewCard(c);
            GameObject cardObj = Instantiate(cardObject, Vector3.zero, Quaternion.identity);
            cardObj.GetComponent <CardObject>().initialize(c);
            cardObj.transform.SetParent(prizeCardPanel);
            cardObj.GetComponent <RectTransform>().localScale = Vector3.one;
        }

        GridLayoutGroup glg = prizeCardPanel.GetComponent <GridLayoutGroup>();

        // Alignment
        if (prizeCards.Length <= 4) // Change alignment (1 row -> center it, 2 rows -> one on top of another)
        {
            glg.childAlignment = TextAnchor.MiddleCenter;
        }
        else
        {
            glg.childAlignment = TextAnchor.UpperCenter;
        }

        // Spacing
        if (prizeCards.Length == 2)
        {
            glg.spacing = new Vector2(150, 0);
        }
        else if (prizeCards.Length == 3)
        {
            glg.spacing = new Vector2(50, 0);
        }

        // Deactivate the Grid Layout to avoid reordering when hovering over a card
        StartCoroutine(removeGridLayoutGroupAfterAFrame(glg));

        // Unlock new enemies
        if (result == Result.VICTORY && !isTutorial && enemy.difficultyId == HubControl.maxUnlockedDifficultyId)
        {
            HubControl.maxUnlockedDifficultyId++;
            if (enemy.difficultyId < Player.stats[Player.Stat.GREATEST_RANK])
            {
                HubControl.maxUnlockedDifficultyId += RerollManager.getRerollSkip(Player.rerollPoints); // Skip enemies
                // Only up to the greatest rank ever reached
                if (HubControl.maxUnlockedDifficultyId > Player.stats[Player.Stat.GREATEST_RANK])
                {
                    HubControl.maxUnlockedDifficultyId = (int)Player.stats[Player.Stat.GREATEST_RANK];
                }
            }

            // Update greatest rank
            if (HubControl.maxUnlockedDifficultyId > Player.stats[Player.Stat.GREATEST_RANK])
            {
                Player.stats[Player.Stat.GREATEST_RANK] = HubControl.maxUnlockedDifficultyId;
            }

            // Move onwards
            HubControl.currentDifficultyId = HubControl.maxUnlockedDifficultyId;
        }

        // Update defeated silver/gold enemies
        if (result == Result.VICTORY && !isTutorial)
        {
            foreach (ArmManager.ArmAspect aspect in enemy.armAspects)
            {
                if (aspect == ArmManager.ArmAspect.SILVER)
                {
                    Player.stats[Player.Stat.SILVER_DEFEATED]++;
                }
                if (aspect == ArmManager.ArmAspect.GOLD)
                {
                    Player.stats[Player.Stat.GOLD_DEFEATED]++;
                }
            }
        }

        if (Player.keyboardModeOn)
        {
            victoryPanel.GetComponentInChildren <Button>().Select();
        }
    }