Hello!
I am desperatly looking for help! I’m working on RTS game and I want to make an list/array of functions, which the unit would go through in the order and execute the functions one by one. I’ve been googling and trying to figure this out for almost week now.
Currently I have this:
var unitQueue : List.<Function> = new List.<Function>();
public function Move(location) {
//Move to location
}
and I’m trying to add this function in array with:
unitQueue.Add(Move(location));
This returns me an error:
BCE0017: The best overload for the method 'System.Collections.Generic.List.<Function>.Add(Function)' is not compatible with the argument list '(void)'.
Any ideas, fixes?
Have a look at [the MSDN documentation for Function][1]. Incidentally, I prefer a wrapper class and delegates to hold "command" arguments. Gives you more room for expansion: public class GameCommand { // names, ids, flags, types can go here // along with a delegate or battery of delegates // and helper methods } [1]: https://msdn.microsoft.com/en-us/library/bb982519.aspx
– AlwaysSunny