Пример #1
0
 void Start()
 {
     playerMovement.damageContainer.SetDamageCall(() => GetDamage());
     playerMovement.damageContainer.SetDoKnockbackCall(() => IsCurrnetAttackKnockingBack());
     coins = 0;
     CalculateStats();
     SetCoinText();
     SetHealthText();
     level.SetLevelText();
 }
Пример #2
0
    void Update()
    {
        if (Input.GetButtonDown("Interact") && currentInterObj)
        {
            if (currentInterObjScript.talks)
            {
                currentInterObjScript.Talk();

                if (currentInterObj.name == "LevelUpNPC")
                {
                    if (player.coins >= level.xpToLevelUp[level.currentLevel])
                    {
                        if (player.coins > 0)
                        {
                            player.coins -= level.xpToLevelUp[level.currentLevel];
                        }
                        level.currentLevel++;
                        player.SetCoinText();
                        level.SetLevelText();
                        print("Level up!");
                        player.SetHealthByLevel();
                        player.SetHealthText();
                    }
                    else
                    {
                        print("You need " + level.xpToLevelUp[level.currentLevel] + " coins to level up!");
                    }
                }
            }
        }

        if (Input.GetButtonDown("UseHealthPotion"))
        {
            if (player.Health != player.base_maxhealth)
            {
                GameObject potion = inventory.FindItemByType("Health Potion");
                float      heal   = potion.GetComponent <HealthPotions>().healPercent;
                if (potion != null)
                {
                    inventory.RemoveItem(potion);
                    player.AddHealth(heal);
                }
            }
            else
            {
                print("Already at full health");
            }
        }
    }