all repos — RPG @ 0d2b7dd3aa83d4e0ad258b02569c7e84be40b803

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

Assets/Scripts/Battle/Fighters/Brady.cs (view raw)

 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5public class Brady : BadGuy
 6{
 7    public Brady()
 8    {
 9        stats = new Stats("Brady");
10        description = "Son of the dark lord, he's not too bad.";
11
12        goldDrop = 150;
13        itemsDrop = new Inventory();
14        itemsDrop.generateItem(new ItemInfo(new BottledBlessing(), 1));
15
16        dead = defending = false;
17    }
18    
19    public override string Combat_AI()
20    {
21        bool output;
22        int res;
23        Ability ability;
24        Fighter target;
25        do {
26            res = Random.Range(1, 101);
27            Debug.Log(res);
28            if (res < 70)
29            {
30                output = true;
31                //attack
32                Fighter[] ggs = GameObject.Find("BattleManager").GetComponent<BattleManager>().getGuys(false); //TODO: try FindObjectOfType
33            
34                /*
35                List<Fighter> goodGuys = new List<Fighter>();
36                foreach(Fighter f in ggs){
37                    if(!f.dead)
38                        goodGuys.Add(f);
39                }
40                */
41
42                target = ggs[Random.Range(0, ggs.Length)];
43
44                if(res < 35)
45                {
46                    //basic
47                    ability = new Attack();
48                } else {
49                    //magic
50                    ability = new FireBall();
51                }
52            } else
53            {
54                //heal
55                ability = new HealGreat();
56                target = this;
57                if(this.stats.HP < this.stats.MaxHP)
58                {
59                    output = true;
60                } else {
61                    output = false;
62                }
63            }
64        } while (output == false);
65        
66        
67        return AbilityDB.Process(this, ability, target, true, out output);
68    }
69}