Esempio n. 1
0
    // the player will press a button to use one health potion in order to restore some of his missing health
    public void use_health_potoin()
    {
        //check if we have any health potion to use
        if (items[health_potion_index].quantity <= 0)
        {
            //play some sound indicating we don't have any health potion left
            return;
        }

        //health potion will restore % of player current maximum health
        //calculating the health to restore
        int health_to_restore = 0;

        health_to_restore = (int)(percent_health_to_restore / 100 * the_player_stats.maximum_hp());

        the_player_health.restore_health(health_to_restore);
        items[health_potion_index].quantity -= 1;
    }