all repos — RPG @ d5cc90a99daa18d6b6678c9643453ad88b1ce9fd

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

Assets/Scripts/Battle/Ability.cs (view raw)

 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5[System.Serializable]
 6public abstract class Ability : Action
 7{
 8    public string dbName;
 9    public string guiName;
10    public bool hasTarget;
11    public double MP_cost;
12    public bool ow_usable;
13    
14    public override string ExecuteSafe(Fighter source, Fighter target, out bool output)
15    {
16        if (source.stats.MP < MP_cost)
17        {
18            output = false;
19            return "Not enough MP!";
20        }
21        else
22        {
23            string tmp = Execute(source, target, out output);
24            if (output)
25            {
26                source.stats.MP -= MP_cost;
27            }
28            return tmp;
29        }
30    }
31
32    public override string ToString()
33    {
34        if (MP_cost == 0)
35        {
36            return guiName;
37        } else
38        {
39            return guiName + " (-" + MP_cost + "MP)";
40        }
41    }
42}