]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/IDeterministicGame.cs
Implemented the base architecture we are bound to because of how the network code...
[chaz/carfire] / CarFire / CarFire / CarFire / IDeterministicGame.cs
diff --git a/CarFire/CarFire/CarFire/IDeterministicGame.cs b/CarFire/CarFire/CarFire/IDeterministicGame.cs
new file mode 100644 (file)
index 0000000..857f57a
--- /dev/null
@@ -0,0 +1,157 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using Microsoft.Xna.Framework;\r
+using Microsoft.Xna.Framework.Graphics;\r
+using Microsoft.Xna.Framework.Input;\r
+using Microsoft.Xna.Framework.Content;\r
+\r
+namespace CarFire\r
+{\r
+    /// <summary>\r
+    /// A DeterministicGame object is a full XNA game, except that it does not\r
+    /// extend the Microsoft.Xna.Framework.Game class.  It supports content loading\r
+    /// and unloading, as well as modified Update and Draw functionality.\r
+    /// \r
+    /// DeterministicGame objects are intented to be incorporated inside of an \r
+    /// existing game.  By simply calling update and draw at the appropriate times,\r
+    /// and by supplying user inputs, the game will play just like any other game.\r
+    /// \r
+    /// It is intended that a DeterministicGame be a multiplayer game, and support for\r
+    /// this is listed in the interface below.  Each player is identified by a unique object\r
+    /// reference (of the caller's choice, not a struct).  The game supports the notion of a\r
+    /// current 'frame', or state.  The enclosing code supplies the user inputs for the\r
+    /// next frame by calling methods.  The enclosing code then should call the update\r
+    /// method to advance the game to the next frame.  Finally, the enclosing code\r
+    /// calls the draw method to render the game state.  Note that the game state can\r
+    /// be drawn multiple times without updating the game, thus allowing the game\r
+    /// to be paused or stalled.\r
+    /// </summary>\r
+    public interface IDeterministicGame\r
+    {\r
+        /// <summary>\r
+        /// Call this method to give the game a chance to load its content.\r
+        /// </summary>\r
+        /// <param name="contentManager">A valid content manager pointing to the root of the content tree</param>\r
+        void LoadContent (ContentManager contentManager);\r
+\r
+        /// <summary>\r
+        /// Call this method to give the game a chance to unload its content.\r
+        /// </summary>\r
+        void UnloadContent();\r
+\r
+        /// <summary>\r
+        /// Returns the preferred screen size for this game.\r
+        /// </summary>\r
+        /// <returns></returns>\r
+        Vector2 PreferredScreenSize { get; }\r
+\r
+        /// <summary>\r
+        /// Returns the minimum number of players this game can support.\r
+        /// </summary>\r
+        /// <returns>the minimum player count</returns>\r
+        int MinimumSupportedPlayers { get; }\r
+\r
+        /// <summary>\r
+        /// Returns the maximum number of players this game can support.\r
+        /// </summary>\r
+        /// <returns>the maximum player count</returns>\r
+        int MaximumSupportedPlayers { get; }\r
+\r
+        /// <summary>\r
+        /// Call this method to reset the game state, to set the current frame at 0, and\r
+        /// to supply identifiers for each player in the game.  Player identifiers should\r
+        /// be unique object references (not structs) that the caller will use later\r
+        /// to identify each player.  (It is important that these not be 'boxed' object\r
+        /// references or the reference will not be preserved.)\r
+        /// \r
+        /// Since, in theory, there will be four copies of the game running, a second\r
+        /// parameter identifies the player that is running this copy of the game.\r
+        /// </summary>\r
+        /// <param name="playerIdentifiers">An array of objects (references) that will identify each player</param>\r
+        /// <param name="playerIdentifiers">An object identifier for the player whose machine is displaying this game</param>\r
+        void ResetGame(Object[] playerIdentifiers, Object thisPlayer);\r
+\r
+        /// <summary>\r
+        /// Returns the current frame number.  This corresponds to the current state\r
+        /// of the game world.\r
+        /// </summary>\r
+        /// <returns>the current frame number</returns>\r
+        long CurrentFrameNumber { get; }\r
+\r
+        /// <summary>\r
+        /// Returns a checksum of all of the game world state.  This checksum can be used\r
+        /// to ensure that multiple players at some frame all share the same state.  It is\r
+        /// guaranteed that identical states will produce identical checksums.\r
+        /// </summary>\r
+        /// <returns>the current game state checksum</returns>\r
+        long CurrentChecksum { get; }\r
+\r
+        /// <summary>\r
+        /// Call this method to report changes in keypresses to the game.  You should call this method\r
+        /// to report any changes in keyboard state for a player.  The keyboard state will be\r
+        /// applied to the next game state (not the current state).\r
+        /// </summary>\r
+        /// <param name="playerIdentifier">An object (reference) that was registered for a player in the game</param>\r
+        /// <param name="key">A key identifier</param>\r
+        /// <param name="isKeyPressed">The key state - true means pressed, false means released</param>\r
+        void ApplyKeyInput (Object playerIdentifier, Keys key, bool isKeyPressed);\r
+\r
+        /// <summary>\r
+        /// Call this method to report changes in mouse locations to the game.  You should call this method\r
+        /// any time the mouse coordinates for a player changes.  The mouse information will\r
+        /// be applied to the next game state (not the current state).\r
+        /// </summary>\r
+        /// <param name="playerIdentifier">an object (reference) that was registered for a player in the game</param>\r
+        /// <param name="x">the mouse x location</param>\r
+        /// <param name="y">the mouse y location</param>\r
+        void ApplyMouseLocationInput (Object playerIdentifier, int x, int y);\r
+\r
+        /// <summary>\r
+        /// Call this method to report changes in mouse button state to the game.  Note that only one\r
+        /// mouse button is supported in game.  You should call this method to report any\r
+        /// changes in mouse button state for a player.  The mouse button state will be\r
+        /// applied to the next game state (not the current state).\r
+        /// </summary>\r
+        /// <param name="playerIdentifier">an object (reference) that was registered for a player in the game</param>\r
+        /// <param name="isButtonPressed">the mouse button state</param>\r
+        void ApplyMouseButtonInput (Object playerIdentifier, bool isButtonPressed);\r
+\r
+        /// <summary>\r
+        /// Returns true if the specified player's game is over.  They can be safely disconnected from the game\r
+        /// when this flag is true, their inputs do not affect game state.  (You can continue to report inputs,\r
+        /// to allow the player to view a game over screen, but no game state action is taken.)\r
+        /// </summary>\r
+        /// <param name="playerIdentifier">an object (reference) that was registered for a player in the game</param>\r
+        /// <returns>true if the game is over</returns>\r
+        bool IsGameOver(Object playerIdentifier);\r
+\r
+        /// <summary>\r
+        /// Returns true if the specified player's game is over, and the player has clicked on something indicating\r
+        /// they wish to leave the game over screen.  (This only becomes true if inputs are reported\r
+        /// even after the game is over.)\r
+        /// </summary>\r
+        /// <param name="playerIdentifier">an object (reference) that was registered for a player in the game</param>\r
+        /// <returns>true if the player has terminated the game</returns>\r
+        bool IsTerminated(Object playerIdentifier);\r
+\r
+        /// <summary>\r
+        /// Call this method to advance the game state.  Previously sent inputs are applied\r
+        /// to the game state and the frame number is advanced and returned.  Caution should be used when\r
+        /// supplying the seconds parameter - it can affect game state.  All players in a game\r
+        /// should advance their game time by the same amount.\r
+        /// </summary>\r
+        /// <param name="timespan">The elapsed game time</param>\r
+        /// <returns>the frame number of the new game state (now the current state)</returns>\r
+        long Update(TimeSpan timespan);\r
+\r
+        /// <summary>\r
+        /// Draws the current game state.  This does not affect the game state - it may be called\r
+        /// repeatedly to redraw the current game state if needed.\r
+        /// </summary>\r
+        /// <param name="spriteBatch">a SpriteBatch object that has begun a batch</param>\r
+        /// <returns>the current game state frame number</returns>\r
+        long Draw(SpriteBatch spriteBatch);\r
+    }\r
+}\r
This page took 0.022739 seconds and 4 git commands to generate.