all repos — RPG @ master

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 guiName;
 9    public bool hasTarget;
10    public double MP_cost;
11    public bool ow_usable;
12    
13    public override string ExecuteSafe(Fighter source, Fighter target, out bool output)
14    {
15        if (source.stats.MP < MP_cost)
16        {
17            output = false;
18            return "Not enough MP!";
19        }
20        else
21        {
22            string tmp = Execute(source, target, out output);
23            if (output)
24            {
25                source.stats.MP -= MP_cost;
26            }
27            return tmp;
28        }
29    }
30
31    public override string ToString()
32    {
33        if (MP_cost == 0)
34        {
35            return guiName;
36        } else
37        {
38            return guiName + " (-" + MP_cost + "MP)";
39        }
40    }
41}