예제 #1
0
    public void EndOfFight(bool won)
    {
        this.won = won;
        //GameObject.Find ("PlayerData").SetActive (false);
        //GameObject.Find ("EnemyData").SetActive (false);
        GameObject.Find("CrystalsBG").SetActive(false);
        GameObject.Find("TurnTag").SetActive(false);
        title.text        = won?"VICTORY!":"DEFEAT!";
        playerStatus      = GameObject.Find("Player").GetComponent <PlayerController>().getXP();
        XPSlider.maxValue = (float)100 * playerStatus [0];
        XPSlider.value    = (float)playerStatus [1];
        XPText.text       = playerStatus[1] + "/" + XPSlider.maxValue;
        if (won)
        {
            //Add loot
            if (EnemySelection.created && !EnemySelection.Instance.getDefeated())
            {
                EnemySelection.Instance.setDefeated(true);
                //loot and progress should only be saved if selected enemy was not yet defeated
                loot.SetActive(true);
                lm           = loot.GetComponent <LootManager> ();
                lm.items [0] = ItemPool [Random.Range(0, ItemPool.Length)].GetComponent <Item> ();
                lm.items [1] = ItemPool [Random.Range(0, ItemPool.Length)].GetComponent <Item> ();
                while (lm.items [0] == lm.items [1])
                {
                    lm.items [1] = ItemPool [Random.Range(0, ItemPool.Length)].GetComponent <Item> ();
                }
                lm.Initialize();
            }
            else
            {
                ContinueButton.interactable = true;
            }
            //Add experience points

            XPGained = (EnemySelection.created ? EnemySelection.Instance.experiencePoints : 5);
            if (playerStatus [1] + XPGained >= 100 * playerStatus [0])
            {
                levelUpText.text = "level up! " + playerStatus [0] + " -> " + (playerStatus [0] + 1) + "\n" +
                                   "Damage: " + Mathf.RoundToInt(100f * (float)Mathf.Pow(1.2f, playerStatus [0] - 1)) + "% ->" + Mathf.RoundToInt(100f * (float)Mathf.Pow(1.2f, playerStatus [0])) + "%\n" +
                                   "HP: " + Mathf.RoundToInt(300f * (float)Mathf.Pow(1.2f, playerStatus [0] - 1)) + "->" + Mathf.RoundToInt(300f * (float)Mathf.Pow(1.2f, playerStatus [0]));
            }
            else
            {
                levelUpText.text = "";
            }
            StartCoroutine(AnimateXPBar());
        }
        else
        {
            loot.SetActive(false);
            levelUpText.text            = "";
            ContinueButton.interactable = true;
        }
    }