2 using System.Collections.Generic;
4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Audio;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.GamerServices;
8 using Microsoft.Xna.Framework.Graphics;
9 using Microsoft.Xna.Framework.Input;
10 using Microsoft.Xna.Framework.Media;
11 using Microsoft.Xna.Framework.Net;
12 using Microsoft.Xna.Framework.Storage;
13 using CS_3505_Project_06.CS_3505;
15 namespace CS_3505_Project_06
18 /// A game outline for testing network communications
20 public class Game06 : Microsoft.Xna.Framework.Game
22 GraphicsDeviceManager graphics;
23 SpriteBatch spriteBatch;
25 NetworkGame networkGame;
28 IDeterministicGame deterministicGame;
35 graphics = new GraphicsDeviceManager(this);
36 Content.RootDirectory = "Content";
38 // Make the game object. The game is currently called 'testHarness'.
40 lobby = new lobbyGUI();
41 deterministicGame = new TestHarness();
42 networkGame = new NetworkGame(lobby, deterministicGame);
43 Components.Add(new GamerServicesComponent(this));
47 /// Allows the game to perform any initialization it needs to before starting to run.
48 /// This is where it can query for any required services and load any non-graphic
49 /// related content. Calling base.Initialize will enumerate through any components
50 /// and initialize them as well.
52 protected override void Initialize()
54 // Set a fixed time span of 1/60th of a second.
56 IsFixedTimeStep = true;
57 TargetElapsedTime = networkGame.TargetTimeSpan;
59 // For debugging - reset the mouse position to the center of the window.
61 Mouse.SetPosition(400, 300);
63 // Allow the base class to initialize.
69 /// LoadContent will be called once per game and is the place to load
70 /// all of your content.
72 protected override void LoadContent()
74 // Create a new SpriteBatch, which can be used to draw textures.
76 spriteBatch = new SpriteBatch(GraphicsDevice);
78 networkGame.font = Content.Load<SpriteFont>("InstructionFont");
80 lobby.LoadContent(Content, graphics);
81 deterministicGame.LoadContent(Content);
85 /// UnloadContent will be called once per game and is the place to unload
88 protected override void UnloadContent()
90 lobby.UnloadContent();
91 deterministicGame.UnloadContent();
95 /// Allows the game to run logic such as updating the world,
96 /// checking for collisions, gathering input, and playing audio.
98 /// <param name="gameTime">Provides a snapshot of timing values.</param>
99 protected override void Update(GameTime gameTime)
101 networkGame.Update(gameTime);
103 // Allow the superclass to do any needed updates (unknown purpose).
104 base.Update(gameTime);
108 /// This is called when the game should draw itself.
110 /// <param name="gameTime">Provides a snapshot of timing values.</param>
111 protected override void Draw(GameTime gameTime)
113 GraphicsDevice.Clear(new Color(16, 16, 16, 255)); // Needed by the test harness, should be removed for the real game.
117 // Let the game draw itself.
118 networkGame.Draw(gameTime, spriteBatch);