all repos — RPG @ 44a6fb4aa7a60749bfe9d30472e7550b824ffe51

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

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

 1using System;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6public abstract class Fighter : MonoBehaviour
 7{
 8    #region Public
 9    [HideInInspector] public bool defending;
10    [HideInInspector] public GameObject damage_tooltip;
11    [HideInInspector] public BattleManager battle;
12    [TextArea] public string description;
13
14    [Header("Settings")]
15    public Animator animator;
16    public bool dead;
17    public Stats stats;
18    
19    #endregion
20    
21    public int fighter_number = -1;
22
23
24    public static int SortByHp(Fighter f1, Fighter f2) //before = weaker
25    {
26        return f1.stats.HP.CompareTo(f2.stats.HP);
27    }
28
29    public static int SortByAgl(Fighter f1, Fighter f2) //before = faster
30    {
31        return f2.stats.AGL.CompareTo(f1.stats.AGL);
32    }
33
34    protected void Start()
35    {
36        //battle = GameObject.Find("BattleManager").GetComponent<BattleManager>();
37        animator = GetComponent<Animator>();
38        GetGUI();
39    }
40
41    public abstract void GetGUI();
42
43    public override string ToString()
44    {
45        return stats.Name;
46    }
47    
48}