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