12
\$\begingroup\$

I'm currently making a PC game in XNA. It's actually a collection of mini-games (there's 3 mini-games at the moment) however I plan to make and add more, in downloadable 'packs'.

My question is, what's the best way to achieve this?

Currently my thoughts are:

  • Create a 'game' interface
  • Build games to this interface but create them as .dlls
  • Have the main .exe file scan a directory and load in the .dlls at runtime.

I've not messed around with the idea much, but I know there are applications at-least that use this plug-in approach (Notepad++ seems to), but I'm not sure of any games that do (although I'm sure they must exist). However it seems that this is a problem that has been solved previously, so I'm wondering if there's any form of established best-practice.

\$\endgroup\$
5
\$\begingroup\$

On windows, you can you can just open an assembly (dll) and import types and execute methods. See the Assembly Class documentation.

On the Xbox 360 you do not have access to System.Reflection. Here you should rely on the XBLA store API. I'm not sure how much of this functionality is available to XBLIG applications.

\$\endgroup\$
2
  • \$\begingroup\$ Yeah, I know I can just load the .dlls (since it's a PC game) however I'm wondering if this is the best way of doing it, or if this is going against some established best practice \$\endgroup\$ – Andrew Thorpe Oct 29 '10 at 15:26
  • \$\begingroup\$ +1 This is the standard way of loading plugins. Look up plugin architecture; FYI, this is a very good solution. \$\endgroup\$ – ashes999 May 24 '12 at 3:00
1
\$\begingroup\$

Since you're building a game for Windows, you can access the full framework as @Ranieri stated. Your architecture sounds solid; however, you might want to check into MEF, the Managed Extensibility Framework. It might make that workflow you outline more streamlined. I haven't used it myself, but I've read good things about it.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.