Esempio n. 1
0
        }         // Start(renderCode)

        #endregion

        #region Unit Testing
#if DEBUG
        #region TestEmptyGame
        /// <summary>
        /// Test empty game
        /// </summary>
        public static void TestEmptyGame()
        {
            TestGame.Start(null);
        }         // TestEmptyGame()
Esempio n. 2
0
            }             // SetupScene(sceneNumber)

            #endregion

            #region Test asteroid manager physics. Press 1-7 to start physics scenes.
            /// <summary>
            /// Test asteroid manager physics. Press 1-7 to start physics scenes.
            /// </summary>
            public void TestAsteroidPhysicsSmallScene()
            {
                TestGame.Start("TestAsteroidPhysicsSmallScene",
                               delegate
                {
                    asteroidManager = new GameAsteroidManager(
                        Level.LoadAllLevels()[0]);
                    asteroidModel = asteroidManager.asteroidModels[0];
                    //new Model("Asteroid1.X");

                    SetupScene(0);
                },
                               delegate
                {
                    BaseGame.GlowShader.Start();

                    // Render sky cube map as our background.
                    BaseGame.skyCube.RenderSky(1.0f, BaseGame.SkyBackgroundColor);

                    BaseGame.camera.FreeCamera = true;
                    BaseGame.EnableAlphaBlending();

                    // Press 1-7 to start physics scenes.
                    if (Input.KeyboardKeyJustPressed(Keys.D1))
                    {
                        SetupScene(0);
                    }
                    if (Input.KeyboardKeyJustPressed(Keys.D2))
                    {
                        SetupScene(1);
                    }
                    if (Input.KeyboardKeyJustPressed(Keys.D3))
                    {
                        SetupScene(2);
                    }
                    if (Input.KeyboardKeyJustPressed(Keys.D4))
                    {
                        SetupScene(3);
                    }
                    if (Input.KeyboardKeyJustPressed(Keys.D5))
                    {
                        SetupScene(4);
                    }
                    if (Input.KeyboardKeyJustPressed(Keys.D6))
                    {
                        SetupScene(5);
                    }
                    if (Input.KeyboardKeyJustPressed(Keys.D7))
                    {
                        SetupScene(6);
                    }

                    for (int z = 0; z < NumberOfSectors; z++)
                    {
                        //for (int y = 0; y < NumberOfSectors; y++)
                        for (int x = 0; x < NumberOfSectors; x++)
                        {
                            // Update all positions for this sector
                            foreach (Asteroid asteroid in
                                     asteroidManager.sectorAsteroids[z, x])
                            {
                                asteroid.UpdateMovement(BaseGame.MoveFactorPerSecond);
                            }

                            // Handle physics (only calculate 50% per frame)
                            //always: if ((z + x) % 2 == BaseGame.TotalFrames % 2)
                            asteroidManager.HandleSectorPhysics(x, z,
                                                                0, 0);
                        }                                         // asteroidModel
                    }
                    // Make sure we start the mesh render manager for this frame.
                    // It will copy all models from last frame over to this frame.
                    //obs, handled in render now! BaseGame.MeshRenderManager.Init();

                    // Render physics asteroids ourselfs
                    for (int z = 0; z < NumberOfSectors; z++)
                    {
                        //for (int y = 0; y < NumberOfSectors; y++)
                        for (int x = 0; x < NumberOfSectors; x++)
                        {
                            //if (x <= 1 && y <= 1 && z <= 1)
                            if (asteroidManager.sectorIsVisible[z, x])
                            {
                                foreach (Asteroid asteroid in
                                         asteroidManager.sectorAsteroids[z, x])
                                {
                                    asteroidModel.Render(asteroid.RenderMatrix);
                                }                                                 // asteroidModel
                            }
                        }
                    }
                });
            }             // TestAsteroidPhysicsSmallScene()