all repos — RPG @ v0.0.1

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

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

 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4[System.Serializable]
 5public class FireBall : Ability
 6{
 7    public FireBall()
 8    {
 9        guiName = "Fireball";
10        hasTarget = true;
11        ow_usable = false;
12        MP_cost = 70;
13    }
14    public override string Execute(Fighter source, Fighter target, out bool output)
15    {
16        if(target.stats.HP == 0)
17        {
18            output = false;
19            return target + " is already dead!";
20        }
21        string str = source + " throws a fireball at " + target + "!";
22        double damage = 0;
23
24        damage = source.stats.MaxMP * 2 / 3;
25
26        damage += (damage * UnityEngine.Random.Range(-5, 5) / 100);
27        target.stats.HP -= damage;
28
29        UI.ShowDamage(target, (int)damage, false);
30        source.animator.SetTrigger("MagicAttack");
31        output = true;
32        return str;
33    }
34
35    public override string GetDescription()
36    {
37        return "A strong, fire-based, magic projectile.";
38    }
39}