I need help to make a status effect system for my turn based combat RPG. I’m new to delegates and events and am only familiar with basics of unity and know C#. Basically, I have two Scriptable Objects each containing functions for players’ behaviors and enemies’ behaviors. I also have a script containing Character statuses. When an action button is clicked by the player or when the Enemy AI chooses an action for their particular turns, and I want some of the actions of particular character to initiate certain effects on certain character or themselves. For example, if the player uses a Defense BUFF, all damage taken should reduce by 30% or if Magic BUFF is used, Mana consumption should be reduced by a 30% for a certain number of turns, and if a character casts a DEBUFF on the opponent, like a Health DEBUFF, then the opponent will lose 30HP every turn for a certain number of turns. Can someone please help me figure out the best method for me to do that?
You are looking for some sort of software architecture?
It’s not super clear because I don’t know what is your current architecture. But can’t you just create a list of buffs in each Character. Then at the start of each turn, you can just apply the effects to the characters and remove the buffs that finished their number of turns.
With the buff class like that for instance:
public abstract class Buff
{
private int numberOfTurns;
public Buff(int numberOfTurns)
{
this.numberOfTurns = numberOfTurns;
}
public abstract void DoEffect(Character char);
public void NextTurn()
{
numberOfTurns -= 1;
}
public bool IsDone()
{
return numberOfTurns <= 0;
}
}
Or you can use Enum for state