예제 #1
0
    public void GainXp(string xptype, int amount)
    {
        xpAmount += amount;
        //    StopCoroutine("SlideXpPopup");
        //    xpPopup.SetActive(false);
        xpPopupRectTransform.localPosition = xpPopupOriginalPos;
        //  xpPopupText.text = "+" + amount + "XP";
        xpPopup.SetActive(true);
        StartCoroutine("SlideXpPopup");
        StartCoroutine("RackupPoints");
        title.text = xptype + ":";
        switch (xptype)
        {
        case "Attack":
            int currentAttackXp = playerVariables.attackXp;
            int newAttackXp     = currentAttackXp + amount;
            playerVariables.SetAttackXp(currentAttackXp + amount);
            StartCoroutine(UpdateXpOverlay("Attack", currentAttackXp, newAttackXp));
            break;

        case "Crafting":
            int currentCraftingXp = playerVariables.craftingXp;
            int newCraftingXp     = currentCraftingXp + amount;
            playerVariables.SetCraftingXp(currentCraftingXp + amount);
            StartCoroutine(UpdateXpOverlay("Crafting", currentCraftingXp, newCraftingXp));
            break;

        case "Cooking":
            int currentCookingXp = playerVariables.cookingXp;
            int newCookingXp     = currentCookingXp + amount;
            playerVariables.SetCookingXp(currentCookingXp + amount);
            StartCoroutine(UpdateXpOverlay("Cooking", currentCookingXp, newCookingXp));
            break;

        case "Gathering":
            int currentGatheringXp = playerVariables.gatheringXp;
            int newGatheringXp     = currentGatheringXp + amount;
            playerVariables.SetGatheringXp(currentGatheringXp + amount);
            StartCoroutine(UpdateXpOverlay("Gathering", currentGatheringXp, newGatheringXp));
            break;

        case "Intelligence":
            playerVariables.SetAttackXp(playerVariables.cookingXp + amount);
            break;
        }
    }