Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            mouse   = Mouse.GetState();
            elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            inputHelper.Update(elapsed);

            if ((inputHelper.IsNewButtonPress(Buttons.Back) || inputHelper.IsNewKeyPress(Keys.Escape)) && !gameover)
            {
                menu.loadClicked   = false;
                menu.counterOption = 0;
                menu.counterSave   = 0;
                menu.showing       = !menu.showing;
            }

            if (menu.Update(elapsed))
            {
                if (reload)
                {
                    LoadContent();
                    reload = false;
                }

                return;
            }

            if (nbEnemy == 0)
            {
                Bloodbender.ptr.gameover             = true;
                Bloodbender.ptr.menu.showing         = true;
                Bloodbender.ptr.menu.bigMessage      = "YOU WIN";
                Bloodbender.ptr.menu.bigMessageColor = Microsoft.Xna.Framework.Color.Green;
            }

            world.Step(1f / 30f);

            camera.Update(elapsed);

            //totemscene.Update(elapsed);

            for (int i = 0; i < listGraphicObj.Count; ++i)
            {
                listGraphicObj[i].Update(elapsed);
            }

            for (int i = 0; i < listGraphicObj.Count; ++i)
            {
                if (listGraphicObj[i].shouldDie == true)
                {
                    if (listGraphicObj[i] is Enemy)
                    {
                        nbEnemy--;
                    }
                    listGraphicObj[i].Dispose();
                    listGraphicObj.RemoveAt(i);
                    --i;
                }
            }

            particuleSystem.Update(elapsed);
            snowMarkSpawner.Update(elapsed);

            pFinder.Update(elapsed);
            shadowsRendering.Update(elapsed);

            if (inputHelper.IsNewKeyPress(Keys.F1))
            {
                debugView.EnableOrDisableFlag(DebugViewFlags.Shape);
            }
            if (inputHelper.IsNewKeyPress(Keys.F2))
            {
                debugView.EnableOrDisableFlag(DebugViewFlags.DebugPanel);
                debugView.EnableOrDisableFlag(DebugViewFlags.PerformanceGraph);
            }
            if (inputHelper.IsNewKeyPress(Keys.F3))
            {
                debugView.EnableOrDisableFlag(DebugViewFlags.Joint);
            }
            if (inputHelper.IsNewKeyPress(Keys.F4))
            {
                debugView.EnableOrDisableFlag(DebugViewFlags.ContactPoints);
                debugView.EnableOrDisableFlag(DebugViewFlags.ContactNormals);
            }
            if (inputHelper.IsNewKeyPress(Keys.F5))
            {
                debugView.EnableOrDisableFlag(DebugViewFlags.PolygonPoints);
            }
            if (inputHelper.IsNewKeyPress(Keys.F6))
            {
                debugView.EnableOrDisableFlag(DebugViewFlags.Controllers);
            }
            if (inputHelper.IsNewKeyPress(Keys.F7))
            {
                debugView.EnableOrDisableFlag(DebugViewFlags.CenterOfMass);
            }
            if (inputHelper.IsNewKeyPress(Keys.F8))
            {
                debugView.EnableOrDisableFlag(DebugViewFlags.AABB);
            }
            if (inputHelper.IsNewKeyPress(Keys.F9))
            {
                debugView.EnableOrDisableFlag(DebugViewFlags.PathFinding);
            }


            if (inputHelper.IsNewKeyPress(Keys.F12))
            {
                this.Window.ClientSizeChanged -= eventResize;

                if (!graphics.IsFullScreen)
                {
                    savedWidth  = graphics.PreferredBackBufferWidth;
                    savedHeight = graphics.PreferredBackBufferHeight;

                    graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                    graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                }
                else
                {
                    graphics.PreferredBackBufferWidth  = savedWidth;
                    graphics.PreferredBackBufferHeight = savedHeight;
                }

                graphics.ToggleFullScreen();

                setAllOnResize();

                this.Window.ClientSizeChanged += eventResize;
            }

            frameRateCounter.Update(elapsed);

            debugView.Update(elapsed);

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        public void Update(float elapsed)
        {
            paths = Bloodbender.ptr.pFinder.GetCurrentPaths();

            ps.Update(elapsed);
        }