I am trying to create a system that casts magic abilities for my combat system. In a nutshell I want my main combat script to be able to call a MagicStart(); function that will be applied to one of a few different magic ability scripts. To make the combat script call the function from the different script, I need to declare the variable at the beginning which is then assigned to corresponding component. The issue is that when I declare the variable I need to put the specific name of the component after it, so say I have three different scripts I want to be able to call from the combat script, I can only call one of them. Is there a way to make it so that the function I call from the combat script can be assigned a different component?
for example :
var magicCast : not sure what would go here
I have tried using SendMessage to accomplish this, but I have issues with the preciseness that it executes the Start functions. I have also tried to make a class EventListener with a boolean, attach it to the main combat script and all the scripts I want to have for magic cast scripts and make the combat script Listener equal to the magic class Listener variable that I want to use and make the Listener bool true on both scripts, then the magic cast script has:
EventListener = false;
If that makes any sense. I feel like this sloppy and am hoping there is a better more simple way to do it. Basically I want to have a x number of magic spell components that have very different code for their functionality and yield timers that use multiple different particle systems, but can all be called from the same function in my combat script. Is this possible? Is there a better way to it that my roughshod EventListener method? Thanks for taking the time to read this.