1

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.

gnat
20.5k29 gold badges117 silver badges308 bronze badges
asked Apr 6, 2015 at 11:16

1 Answer 1

4

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.