Solved it myself
Storing delegates or function calls in a array
I've been struggling to figure out the best way to approach this problem. I'm making a turn based game. Every turn the player chooses several actions, so does each enemy in play. These actions should all be stored in an array, shuffled and then executed one at a time during and TurnPlay sequence.
so a action function look this
public void FirePrim(source,weapon,target){
dmg = HitCalc(weapon,target);
Instantiate(projectile);
projectile.GetComponent().dmg = dmg;
}
What I'd like to do is have the function call and parameters wrapped up in one varible that can be added to the actionArray. I'm thinking that delegates may be the way to go, but my knowledge of how they work is limited. I figure I could make a delegate that contains all parameter information and extra instructions if necessary like so
pubic void delegate myDelegate; void firePrimPckg(){ FirePrim(GameObject Player, GameObject Beam, GameObject targetEnemy); }
myDelegate = firePrimPckg;
and this point I'd like to store myDelegate into an array for later use, but from what I can tell a delegate doesn't have a type so I can't store it in a regular array. Should I use an ArrayList? I've been advised against it in the past due to performance issues, Is it possible to store these delegates as strings and then use the Invoke method? Or perhaps there is a better strategy for accomplishing this that I have overlooked. Any help at all would be greatly appreciated :)
Follow this Question
Related Questions
How do you access the Scripts, Functions, and Bools within an array of GameObjects? 0 Answers
Array index out of range error with onClick.AddListener(delegate) 1 Answer
Storing a Gameobject from array into a Gameobject variable giving NullReferenceException 3 Answers
Fields not populated during OnValidate on Editor startup 2 Answers
Cannot convert UnityEngine.GameObject to UnityEngine.GameObject 1 Answer