So uh, I’m trying to create basic ‘Attack’ and ‘Skill’ buttons. It’s just going to reduce target health and wait for a little until the next round.
the code in action:
private void Attack(Animator anim, UnitManager.BattlerStat targetStat, UnitManager.BattlerStat attackerStat)
{
anim.Play("Unit_Attack");
targetStat.CurrentHealth -= attackerStat.Attack;
UnitManager.OnValueChange.Invoke();
StartCoroutine(WaitBeforeProceedTurn());
}
public void AttackTheEnemy()
{
Attack(playerAnim, UnitManager.EnemyBattler, UnitManager.PlayerBattler);
}
public void AttackThePlayer()
{
Attack(enemyAnim, UnitManager.PlayerBattler, UnitManager.EnemyBattler);
}
public void SkillThatDamagePlayer()
{
Attack();
}
public void SkillThatDamageEnemy()
{
Attack();
}
I try to ‘encapsulate’ the Attack method so it can be invoked from UnityEvent.
But it’s starting to get out of control if I add even little things from here (heal, etc).
Any tips to handle this kind of approach?
Thanks!