######EDIT######
So yesterday i got my system working. At least a prototype for it. Here is a picture what i can do with it in the inspector:
Cool thing about it is, that i can make Components like "DoDamage" or "ApplyPoison". Then chain them and compose my custom abilitys. One ability can have more effects. Like a chain of effects. Damage one Enemy > heal one ally > buff all other allys
Its not optimal. I really would like to have something like this with scriptabla objects, but i was not able to pull it off. Is this system okay how i did it?
My game is turn based. The game is based around the combat and around a lot of characters. thats why i want an easy ability composer.
I have 3 codes:
- AbilityController
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AbilityController : MonoBehaviour
{
public string abilityName;
public AbilityTargetMode[] targetModes;
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
for(int i = 0; i < targetModes.Length; i++)
{
targetModes[i].Execute();
}
}
}
}
- AbilityTargetMode
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum TargetMode { EnemySingle, EnemyAll, EnemyRandom, AllySingle, AllySingleOther, AllyAll, AllyAllOther, AllyRandom, AllyRandomOther, AllySelf}
[System.Serializable]
public class AbilityTargetMode
{
public TargetMode targetMode;
public AbilityComponent[] abilityComponents;
private Character[] targets;
public void Execute()
{
CastAbilityComponentsOnTarget();
}
private void CastAbilityComponentsOnTarget()
{
for (int i = 0; i < abilityComponents.Length; i++)
{
abilityComponents[i].CastAbilityComponent(targets);
}
}
private void SelectTargets()
{
switch (targetMode)
{
case TargetMode.EnemySingle:
break;
case TargetMode.EnemyAll:
break;
case TargetMode.EnemyRandom:
break;
case TargetMode.AllySingle:
break;
case TargetMode.AllySingleOther:
break;
case TargetMode.AllyAll:
break;
case TargetMode.AllyAllOther:
break;
case TargetMode.AllyRandom:
break;
case TargetMode.AllyRandomOther:
break;
case TargetMode.AllySelf:
break;
}
}
}
- AbilityComponent
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class AbilityComponent : MonoBehaviour
{
public virtual void CastAbilityComponent(Character[] _targets)
{
//do stuff
}
}
