all repos — RPG @ e4654d09764a984539ba6cb6880cea7492aff7b6

Fully functional 3D turn based role playing game coded in C# and base Unity.

Assets/Scripts/Battle/Abilities/Heal.cs (view raw)

 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5[System.Serializable]
 6public class Heal : Ability
 7{
 8    protected double heal_amount;
 9
10    public Heal()
11    {
12        guiName = "Heal";
13        hasTarget = true;
14        ow_usable = true;
15        MP_cost = 50;
16        heal_amount = 200;
17    }
18
19    public override string Execute(Fighter source, Fighter target, out bool output)
20    {
21        double amount = heal_amount;
22        output = false;
23        if(target.stats.HP <= 0)
24        {
25            return source + " can't heal " + target + " because they're dead!";
26        }
27        if(target.stats.HP == target.stats.MaxHP)
28        {
29            return target + " already has max HP, they don't need healing.";
30        }
31        amount += (amount * 0.05);
32        target.stats.HP += amount;
33        source.animator.SetTrigger("Heal");
34        UI.ShowDamage(target, -(int)amount, false); //this should give a negative result
35        output = true;
36        return target + " recovered " + (int)amount + " HP.";
37        
38    }
39
40    public override string GetDescription()
41    {
42        return "Heals about " + heal_amount + "HP to one target.";
43    }
44}