all repos — RPG @ 0d2b7dd3aa83d4e0ad258b02569c7e84be40b803

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

fix brady AI
Marco Andronaco andronacomarco@gmail.com
Thu, 16 Apr 2020 17:34:52 +0200
commit

0d2b7dd3aa83d4e0ad258b02569c7e84be40b803

parent

39e7f8bd4adbfecce5a88f76fa1cd9cbb0f243f1

1 files changed, 45 insertions(+), 9 deletions(-)

jump to
M Assets/Scripts/Battle/Fighters/Brady.csAssets/Scripts/Battle/Fighters/Brady.cs

@@ -18,16 +18,52 @@ }

public override string Combat_AI() { - //attack a random goodGuy - Fighter[] ggs = GameObject.Find("BattleManager").GetComponent<BattleManager>().getGuys(false); - List<Ability> abs = stats.GetAbilities(); bool output; - string str; - do - { - str = AbilityDB.Process(this, abs[Random.Range(0, abs.Count)], ggs[Random.Range(0, ggs.Length)], true, out output); + int res; + Ability ability; + Fighter target; + do { + res = Random.Range(1, 101); + Debug.Log(res); + if (res < 70) + { + output = true; + //attack + Fighter[] ggs = GameObject.Find("BattleManager").GetComponent<BattleManager>().getGuys(false); //TODO: try FindObjectOfType + + /* + List<Fighter> goodGuys = new List<Fighter>(); + foreach(Fighter f in ggs){ + if(!f.dead) + goodGuys.Add(f); + } + */ + + target = ggs[Random.Range(0, ggs.Length)]; + + if(res < 35) + { + //basic + ability = new Attack(); + } else { + //magic + ability = new FireBall(); + } + } else + { + //heal + ability = new HealGreat(); + target = this; + if(this.stats.HP < this.stats.MaxHP) + { + output = true; + } else { + output = false; + } + } } while (output == false); - return str; + + + return AbilityDB.Process(this, ability, target, true, out output); } - }