Exemplo n.º 1
0
        /// <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
        }
Exemplo n.º 2
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     //TestHarness.WorldBuilder.test();
     using (Engine game = new Engine())
     {
         game.Run();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="engine">The engine using the controller.</param>
 public PCControllerInput(Engine engine)
 {
     engine_ = engine;
     inputs_ = InputSet.getInstance();
 }
Exemplo n.º 4
0
 public UpdateThread(Engine engine, EngineStateInterface engineState)
 {
     currentEngineState_ = engineState;
     engine_ = engine;
     drawBuffer_ = DrawBuffer.getInstance();
 }
Exemplo n.º 5
0
 /// <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);
 }
Exemplo n.º 6
0
 /// <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();
 }
Exemplo n.º 7
0
 public static void initialize(Engine engine)
 {
     engine_ = engine;
     StateStack = new Stack<EngineStateInterface>();
 }
Exemplo n.º 8
0
 public EngineStateSplash(Engine engine)
 {
     engine_ = engine;
     //splash_ = new GameTexture(@"Sprites\splash", engine.spriteBatch_, engine.GraphicsDevice, engine_.Content);
     splash_ = new GameTexture(@"Sprites\splash");
 }
Exemplo n.º 9
0
 public ManagedXml(Engine engine)
     : base()
 {
     content_ = new ContentManager(engine.Services);
     content_.RootDirectory = "Content";
 }
Exemplo n.º 10
0
 /// <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);
 }
Exemplo n.º 11
0
        /// <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();
        }
Exemplo n.º 12
0
 public EngineStateGameplay(Engine engine)
     : base(engine)
 {
     // Init logic here
     GameplayManager.initialize(this);
 }
Exemplo n.º 13
0
 public UpdateThread(Engine engine)
 {
     engine_ = engine;
     drawBuffer_ = DrawBuffer.getInstance();
 }