all repos — RPG @ 62a0546261098a7868f5986f21adf997f247852f

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        dbName = "FireBall";
10        guiName = "Fireball";
11        hasTarget = true;
12        ow_usable = false;
13        MP_cost = 70;
14    }
15    public override string Execute(Fighter source, Fighter target, out bool output)
16    {
17        if(target.stats.HP == 0)
18        {
19            output = false;
20            return target + " is already dead!";
21        }
22        string str = source + " throws a fireball at " + target + "!";
23        double damage = 0;
24
25        //TODO: number logic
26        damage = 300;
27
28        damage += (damage * UnityEngine.Random.Range(-5, 5) / 100);
29        target.stats.HP -= damage;
30
31        UI.ShowDamage(target, (int)damage, false);
32        source.animator.SetTrigger("MagicAttack");
33        output = true;
34        return str;
35    }
36
37    public override string GetDescription()
38    {
39        return "A strong, fire-based, magic projectile.";
40    }
41}