/// <summary> /// Constructor determines whether PC or Xbox 360 and initializes /// variables accordingly. /// /// For PC, this means creating the controller and trying to get a /// storage device. /// /// For the Xbox 360, we don't need to do much as we rely on update() /// logic to determine active controller and storage device. /// </summary> /// <param name="engine"></param> public EngineStateStart(Engine engine) { engine_ = engine; //logo_ = TextureMap.fetchTexture(@"Sprites\TitleScreen"); //logo_ = new GameTexture(@"Sprites\TitleScreen", engine.spriteBatch_, engine.GraphicsDevice, engine.Content); logo_ = new GameTexture(@"Sprites\TitleScreen"); #if !XBOX { Settings settings = Settings.getInstance(); if (Settings.getInstance().IsUsingMouse_) { engine_.Controls_ = new PCControllerInput(engine_); settings.CurrentPlayer_ = PlayerIndex.One; TEXT_MESSAGE = "Press " + engine_.Controls_.getControlName(InputsEnum.CONFIRM_BUTTON).ToUpper() + " to Continue"; } else { engine_.Controls_ = new X360ControllerInput(engine_, PlayerIndex.One); settings.CurrentPlayer_ = PlayerIndex.One; TEXT_MESSAGE = "Press " + engine_.Controls_.getControlName(InputsEnum.CONFIRM_BUTTON).ToUpper() + " to Continue"; } prepareStorageDevice(); returnFlag_ = true; } #else { engine_.Controls_ = null; // reset controls if they are coming back to this returnFlag_ = false; } #endif }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { //TestHarness.WorldBuilder.test(); using (Engine game = new Engine()) { game.Run(); } }
/// <summary> /// Default constructor. /// </summary> /// <param name="engine">The engine using the controller.</param> public PCControllerInput(Engine engine) { engine_ = engine; inputs_ = InputSet.getInstance(); }
public UpdateThread(Engine engine, EngineStateInterface engineState) { currentEngineState_ = engineState; engine_ = engine; drawBuffer_ = DrawBuffer.getInstance(); }
/// <summary> /// Constructor which allows specification of a player. /// </summary> /// <param name="engine">The engine using the controller.</param> /// <param name="player">The player whose input should be read.</param> public X360ControllerInput(Engine engine, PlayerIndex player) { engine_ = engine; player_ = player; inputs_ = InputSet.getInstance(player); }
/// <summary> /// Default constructor; assigns itself to Player One's input device. /// </summary> /// <param name="engine">The engine using the controller.</param> public X360ControllerInput(Engine engine) { engine_ = engine; player_ = PlayerIndex.One; inputs_ = InputSet.getInstance(); }
public static void initialize(Engine engine) { engine_ = engine; StateStack = new Stack<EngineStateInterface>(); }
public EngineStateSplash(Engine engine) { engine_ = engine; //splash_ = new GameTexture(@"Sprites\splash", engine.spriteBatch_, engine.GraphicsDevice, engine_.Content); splash_ = new GameTexture(@"Sprites\splash"); }
public ManagedXml(Engine engine) : base() { content_ = new ContentManager(engine.Services); content_.RootDirectory = "Content"; }
/// <summary> /// This is the constructor that should almost always be used /// </summary> /// <param name="filepath">The path to the .spritefont file, without .spritefont at the end</param> /// <param name="spriteBatch">The spriteBatch to be used when drawing text</param> /// <param name="engine">The main Engine class</param> public GameFont(string filename, SpriteBatch spriteBatch, Engine engine) { spriteBatch_ = spriteBatch; font_ = engine.Content.Load<SpriteFont>(filename); }
/// <summary> /// Load all the textures for the game. /// </summary> /// <param name="filepath">Filename of the texture document</param> /// <param name="spriteBatch">SpriteBatch for the game</param> /// <param name="graphics">GraphicsDevice for the game</param> public void loadTextures(string filename, Engine engine) { SpriteBatch spriteBatch = engine.spriteBatch_; GraphicsDevice graphics = engine.GraphicsDevice; using (ManagedXml manager = new ManagedXml(engine)) { try { XmlDocument document = manager.loadFromFile(filename); XmlNodeList textureXMLs = document.GetElementsByTagName("texture"); foreach (XmlNode node in textureXMLs) { KeyValuePair<string, GameTexture> tempPair = GameTexture.loadTextureFromFile(node.InnerText, spriteBatch, graphics); textures_.Add(tempPair.Key, tempPair.Value); } XmlNodeList images = document.GetElementsByTagName("image"); foreach (XmlNode node in images) { string key = "", image = ""; XmlNodeList children = node.ChildNodes; foreach (XmlNode child in children) { if (child.LocalName == "key") { key = child.InnerText; } else if (child.LocalName == "handle") { image = child.InnerText; } } textures_.Add(key, new GameTexture(image)); } } catch (Exception e) { Console.Out.WriteLine("FATAL ERROR: Texture Map failed to load!"); throw e; } } // Don't collect here, because we will be reading in a lot of these XML docs //GC.Collect(); //GC.WaitForPendingFinalizers(); }
public EngineStateGameplay(Engine engine) : base(engine) { // Init logic here GameplayManager.initialize(this); }
public UpdateThread(Engine engine) { engine_ = engine; drawBuffer_ = DrawBuffer.getInstance(); }