I'm writing a little game using C# MonoGame and I have idea of scripting enemies in external script files (not necessarily in C#, maybe in lua?).
So for example I have class Enemy in C#. And I want to load external C# class from file, and the class will inherit from Enemy base class and I will use it as enemy.
Maybe it sound dumb, "why don't I just add .cs files to my project with that class and compile it into one executable?" I don't know, just want to know if it is possible and how to do it.
PS: If it helps I'm using Visual Studio Community 2013.
1 Answer 1
There are two straightforward ways to accomplish this. The simplest is to move your common code to a library then make your enemy a library that your game loads. Your enemies can be Dlls.
If you want to distribute source, and compile enemies at run time, see https://stackoverflow.com/questions/826398/is-it-possible-to-dynamically-compile-and-execute-c-sharp-code-fragments