So I’m having a crack at a Battle System and it’s working great! Only problem is I have hit a wall, and so am turning to the infinite wisdom of the Unity community for guidence.
After every turn, I would like to call an event or something like that. When called, all the “Combatants” in battle (enemies and party) would have the unique logic of what ever buffs/debuffs they have execute. So if you could imagine, it would be something like this:
public class Combatant
{
public int health = 100; //Health of Combatant
public Stats stats = new Stats(); //Current Stats of Combatant
public Buff[ ] buffs; //Current buffs/debuffs on combatant
public void CallBuffLogic()
{
foreach(Buff b in buffs)
{
buffs.Call();
}
}
}
It could be something very different obviously, but I’m just trying to get across what I want to achieve to you. How can this be done?
You could use a gameManager that would detect your event in question. And make a public function on your characters.
Something like that.
public class GameManager
{
public Combattant[ ] combattantList;
void Update()
{
//detect your event
if(event)
{
for(int i = 0 ;i < combattantList.Lenght;i++)
{
combattantList*.CallBuffLogic();* } } } } public class Combatant { public int health = 100; //Health of Combatant public Stats stats = new Stats(); //Current Stats of Combatant public Buff[ ] buffs; //Current buffs/debuffs on combatant public void CallBuffLogic() { foreach(Buff b in buffs) { buffs.Call(); } } }
Yeah the problem is that Buffs are a bit of a suitcase term, like sports. Thai Kickboxing and Golf are both classified as sports, yet have very different logic. My problem, is that I need to define and execute code the same way.
I have Buffs, but one might want to remove 10hp from a Combatant every turn yet another might cause the Combatant to miss a turn or something. My question is more like, how do I actually code logic like this.