Ejemplo n.º 1
0
Archivo: Game.cs Proyecto: melburn/GLhf
        protected override void Update(GameTime a_gameTime)
        {
            if (!IsActive)
            {
                return;
            }
            KeyboardHandler.setCurrentKeyboard(Keyboard.GetState());
            MouseHandler.setCurrentMouse(Mouse.GetState());
            m_currentGameTime = a_gameTime;
            if (m_nextProgress != null)
            {
                m_progress = m_nextProgress;
                m_nextProgress = null;
            }
            if (m_nextState != null)
            {
                m_currentState = m_nextState;
                AssetFactory.updateState(m_currentState);
                if (!m_currentState.isLoaded())
                {
                    #if DEBUG
                    m_currentState.load();
                    #else
                    try
                    {
                        m_currentState.load();
                    }
                    catch (Exception e)
                    {
                        ErrorLogger.getInstance().writeString("While loading " + m_currentState + " got exception: " + e);
                    }
                    #endif
                }
                m_nextState = null;
            }

            #if DEBUG
            if (m_currentState != null)
            {
                m_currentState.update(a_gameTime);
            }
            #else
            if (m_currentState != null)
            {
                try
                {
                    m_currentState.update(a_gameTime);
                }
                catch (Exception e)
                {
                    //ErrorLogger.getInstance().writeString("While updating " + m_currentState + " got exception: " + e);
                }
            }
            #endif

            if (KeyboardHandler.keyClicked(Keys.F7)) //TODO Alfa/Beta-grej
            {
                m_nextState = new MainMenu();
            }

            MouseHandler.setPreviousMouse();
            KeyboardHandler.setPreviousKeyboard();
            base.Update(a_gameTime);
        }
Ejemplo n.º 2
0
        protected override void Update(GameTime a_gameTime)
        {
            if (!IsActive)
                return;
            m_currentKeyInput = Keyboard.GetState();
            m_currentMouse = Mouse.GetState();
            m_currentGameTime = a_gameTime;

            if (m_nextState != null)
            {
                m_currentState = m_nextState;
                if (!m_currentState.isLoaded())
                {
                    try
                    {
                        m_currentState.load();
                    }
                    catch (Exception e)
                    {
                        ErrorLogger.getInstance().writeString("While loading " + m_currentState + " got exception: " + e);
                    }
                }
                m_nextState = null;
            }

            if (m_currentState != null)
            {
                try
                {
                    m_currentState.update(a_gameTime);
                }
                catch (Exception e)
                {
                    ErrorLogger.getInstance().writeString("While updating " + m_currentState + " got exception: " + e);
                }
            }

            if (keyClicked(Keys.F7)) //Asså det här är ju inte ok
            {
                m_nextState = new MainMenu();
            }

            m_previousMouse = m_currentMouse;
            m_previousKeyInput = m_currentKeyInput;
            base.Update(a_gameTime);
        }
Ejemplo n.º 3
0
Archivo: Game.cs Proyecto: melburn/GLhf
 protected override void Initialize()
 {
     ErrorLogger.getInstance().clearFile();
     ErrorLogger.getInstance().writeString("GrandLarceny initiated at "+System.DateTime.Now);
     #if DEBUG
     m_camera = new Camera();
     Loader.getInstance().loadGraphicSettings("Content//wtf//settings.ini");
     Loader.getInstance().loadSoundSettings("Content//wtf//settings.ini");
     m_camera.load();
     m_currentState = new MainMenu();
     m_currentState.load();
     base.Initialize();
     #else
     try
     {
         m_camera = new Camera();
         m_currentState = new MainMenu();
         m_currentState.load();
         base.Initialize();
     }
     catch (Exception e)
     {
         ErrorLogger.getInstance().writeString("While instantiating: " + e);
         ErrorLogger.getInstance().writeString("Terminating");
         Exit();
     }
     #endif
 }
Ejemplo n.º 4
0
 protected override void Initialize()
 {
     ErrorLogger.getInstance().writeString("GrandLarceny initiated at "+System.DateTime.Now);
     try
     {
         m_camera = new Camera();
         m_currentState = new MainMenu();
         m_currentState.load();
         base.Initialize();
     }
     catch (Exception e)
     {
         ErrorLogger.getInstance().writeString("While instantiating: " + e);
         ErrorLogger.getInstance().writeString("Terminating");
         Exit();
     }
 }