Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create the server
- using (var game = new ExampleGame(new ServerNetworkManager()))
- {
- game.Run();
- }
- // Create the client
- using (var game = new ExampleGame(new ClientNetworkManager()))
- {
- game.Run();
- }
- // Network Manager type injected as appropriate.
- using (XNAGame game = new XNAGame(new ClientNetworkManager()))
- {
- game.Run();
- }
- // Constructor accepts the "injected" type as below.
- public XnaGame(INetworkManager networkManager)
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- this.networkManager = networkManager;
- }
- // RTTI / Polymorphism. Determine if this instance is a Server or a Client.
- public bool IsServer()
- {
- return this.networkManager is ServerNetworkManager ? true : false;
- }
- // The Windows form within this project can then be run as follows.
- protected override void Initialize()
- {
- // TODO: Add your initialization logic here
- // If this is the server, we need to create and show the management form.
- if (this.IsServer() == true)
- {
- Form = new MainServerForm();
- Form.Show();
- }
- base.Initialize();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement