using System; namespace Icarus.Logic.GameEngine { /// /// I am a singleton which can be used to retrieve Game Engine settings. /// Members are straightforward to access. /// public class GameSettings { #region Instance Variables /// /// Defines the game difficulty, changes the AI, and is used by Game Calculations. /// private int iDifficulty; /// /// The timescale is used to define the number of times per /// second that the GameEngine executes to update the world. /// private float iTimeScale; /// /// Defines whether cheats are on or off. /// private bool bCheatsEnabled; /// /// Defines how many particles are pre-allocated when a level loads. /// private uint uiMaxParticles; /// /// Defines the number of particles to dynamically load at a time /// when the max number of particles is infinite. /// private uint uiParticleLoadRate; /// /// Defines how many items are pre-allocated when a level loads. /// private uint uiMaxItems; /// /// Defines the number of items to dynamically load at a time /// when the max number of items is infinite. /// private uint uiItemLoadRate; /// /// Defines how many actors are pre-allocated when a level loads. /// private uint uiMaxActors; /// /// Defines the number of actors to dynamically load at a time /// when the max number of actors is infinite. /// private uint uiActorLoadRate; /// /// Defines how many terrain world objects are pre-allocated when a level loads. /// private uint uiMaxTerrainObjects; /// /// Defines the number of terrain ojects to dynamically load at a time /// when the max number of terrain objects is infinite. /// private uint uiTerrainObjectLoadRate; /// /// Defines how detailed the Physics calculations are. /// private int iPhysicsDetail; /// /// Defines the maximum number of collision boxes in a level /// private uint uiMaxCollisionBoxes; /// /// The maximum internal collision rectangles a collision box can hold /// private uint uiMaxInternalRects; /// /// The maximum internal collision triangles a collision box can hold /// private uint uiMaxInternalTris; /// /// This defines the time between updates in milliseconds, default is 22 (45fps) /// private uint uiUpdateRate; /// /// The maximum number of stages per level /// private uint uiMaxStages; #endregion #region Singleton Stuff private static GameSettings instance = new GameSettings(); /// /// Returns the instance of the GameSettings object /// public static GameSettings Instance { get { return instance; } } #endregion #region Accessors/Modifiers /* ------------------- */ /* Accessors/Modifiers */ /* ------------------- */ /// /// Defines the maximum number of collision boxes in a level /// public uint sv_maxCollisionBoxes { get { return this.uiMaxCollisionBoxes; } set { this.uiMaxCollisionBoxes = value; } } /// /// Defines the maximum number of internal collision rectangles /// a collision box can hold /// public uint sv_maxInternalRects { get { return this.uiMaxInternalRects; } set { this.uiMaxInternalRects = value; } } /// /// Defines the maximum number of internal collision triangles /// a collision box can hold /// public uint sv_maxInternalTris { get { return this.uiMaxInternalTris; } set { this.uiMaxInternalTris = value; } } /// /// A Negative difficulty should cause all enemies to freeze in place /// (allowing debugging to take place). /// A Positive difficulty becomes more difficult with increasing values. /// Lowest difficulty is 0. /// public int sv_difficulty { get { return this.iDifficulty; } set { this.iDifficulty = value;} } /// /// This sets the game's TimeScale. /// The timescale values can range from FLOAT_MIN to FLOAT_MAX. /// Whether the full range is supported, doesn't matter. /// Negatives don't matter, only the magnitude is used. /// A higher number than 1.0f will result in more updates occuring per second. /// Numbers between 0 and 1.0, exclusive, result in fewer /// updates and, thus, the game moves "slower". /// public float sv_timescale { get { return this.iTimeScale; } set { this.iTimeScale = value;} } /// /// Activating cheats can turn on things like God Mode, which negate damage /// effects to the player, as well as various other nifty debugging tools. /// public bool sv_cheats { get { return this.bCheatsEnabled; } set { this.bCheatsEnabled = value;} } /// /// A value of 0 means that infinite particles are allowed. /// In the case of infinite particles, particles will be loaded dynamically /// sv_particleLoadRate at a time. /// Dynamic loading is much slower, but requires much less memory. /// public uint sv_maxParticles { get { return this.uiMaxParticles; } set { this.uiMaxParticles = value;} } /// /// This defines the number of particles to dynamically load at a time /// when the max number of particles is infinite. /// public uint sv_particleLoadRate { get { return this.uiParticleLoadRate; } set { this.uiParticleLoadRate = value;} } /// /// A value of 0 means that infinite items are allowed. /// In the case of infinite items, items will be loaded dynamically /// sv_itemLoadRate at a time. /// Dynamic loading is much slower, but requires much less memory. /// public uint sv_maxItems { get { return this.uiMaxItems; } set { this.uiMaxItems = value;} } /// /// This defines the number of items to dynamically load at a time /// when the max number of items is infinite. /// public uint sv_itemLoadRate { get { return this.uiItemLoadRate; } set { this.uiItemLoadRate = value;} } /// /// A value of 0 means that infinite actors are allowed. /// In the case of infinite actors, actors will be loaded dynamically /// sv_actorLoadRate at a time. /// Dynamic loading is much slower, but requires much less memory. /// public uint sv_maxActors { get { return this.uiMaxActors; } set { this.uiMaxActors = value;} } /// /// This defines the number of actors to dynamically load at a time /// when the max number of actors is infinite. /// public uint sv_actorLoadRate { get { return this.uiActorLoadRate; } set { this.uiActorLoadRate = value;} } /// /// A value of 0 means that infinite terrain objects are allowed. /// In the case of infinite terrain objects, terrain objects will be /// loaded dynamically sv_terrainObjectLoadRate at a time. /// Dynamic loading is much slower, but requires much less memory. /// public uint sv_maxTerrainObjects { get { return this.uiMaxTerrainObjects; } set { this.uiMaxTerrainObjects = value;} } /// /// This defines the number of terrain objects to dynamically load at a time /// when the max number of terrain objects is infinite. /// public uint sv_TerrainObjectLoadRate { get { return this.uiTerrainObjectLoadRate; } set { this.uiTerrainObjectLoadRate = value;} } /// /// This may cause faster algorithms to be used in place of slower, /// more precise algorithms. /// This varies on Physics Engine implementation/mode. /// Default value is 0 (Full Detail), negative values lower /// detail and positive values (may) increase detail. /// public int sv_physicsDetail { get { return this.iPhysicsDetail; } set { this.iPhysicsDetail = value;} } /// /// This stores the time between updates in milliseconds. /// /// Note that the variable sv_timescale speeds up or slows down the /// game itself, this variable will affect the magnitude of vectors in /// the Physics Engine and alter the Physics themselves /// public uint sv_updateRate { get { return this.uiUpdateRate; } set { this.uiUpdateRate = value;} } /// /// The maximum number of stages per level /// public uint sv_maxStages { get { return this.uiMaxStages; } set { this.uiMaxStages = value; } } #endregion #region Initialization /* -------------- */ /* Initialization */ /* -------------- */ /// /// Uses Icarus preset Game settings as defined in the variable comments. /// private GameSettings() { this.iDifficulty = 3; this.iPhysicsDetail = 0; this.iTimeScale = 1.0f; this.bCheatsEnabled = false; this.uiParticleLoadRate = 25; this.uiMaxParticles = 1000; this.uiItemLoadRate = 25; this.uiMaxItems = 100; this.uiActorLoadRate = 25; this.uiMaxActors = 100; this.uiTerrainObjectLoadRate = 25; this.uiMaxTerrainObjects = 1000; this.uiMaxCollisionBoxes = 100; this.sv_maxInternalRects = 15; this.sv_maxInternalTris = 15; this.uiUpdateRate = 22; //45fps this.uiMaxStages = 10; } /// /// Load GameSettings from a File. /// Sets the settings to the Icarus Defaults then loads the settings from /// fileName and replaces the settings specified. /// /// The fileName of settings to replace defaults. private GameSettings(string fileName) : this() { // TODO: Implement me } #endregion } }