Esempio n. 1
0
        public void RocketCommanderGame_Mouse_Test()
        {
            var game = new TestGame();

            Layout layout = null;
            game.Initialized += (o, e) =>
                {
                    layout = new Layout("MouseState", game.Framework.AssetManager)
                    {
                        DestRect = new Rectangle(0.0f, 0.1f, 1.0f, 1.0f)
                    };

                    var mouseBlock = new TextBlock(layout, game.Framework.AssetManager)
                    {
                        Font = game.Framework.AssetManager.DefaultFont,
                        Foreground = Color.Red,
                        Name = "MouseBlock"
                    };

                    game.AddLayout(layout);
                };
            game.Mouse.MouseMove += (o, e) =>
                {
                    var mouseBlock = layout.GetElement("MouseBlock") as TextBlock;
                    mouseBlock.Text = game.Mouse.Position.ToString();
                };

            game.Run();
        }
Esempio n. 2
0
        public void Asteroid_Render_Test()
        {
            var game = new TestGame();
            Asteroid asteroid = null;
            game.Updated += (o, e) =>
            {
                game.DebugText += "\n\nPress key 1~5 to watch each asteroid";

                Key[] keys = new Key[] { Key.D1, Key.D2, Key.D3, Key.D4, Key.D5 };
                foreach (Key key in keys)
                {
                    if (game.Keyboard.IsKeyDown(key) == false)
                        continue;

                    if (asteroid != null)
                        game.SceneManager.RemoveRenderable(asteroid.MeshNode);

                    int type = key - keys[0];
                    asteroid = new Asteroid(game.Framework, game.SceneManager, type);

                    game.SceneManager.Camera.LookMeshNode(asteroid.MeshNode);
                    game.SceneManager.Light.Position = new Vector3(0.0f, 0.0f, asteroid.MeshNode.BoundingRadius * -5.0f);
                }
            };
            game.Run();
        }
Esempio n. 3
0
        public void Item_Render_Test()
        {
            var game = new TestGame();
            Item item = null;
            game.Updated += (o, e) =>
            {
                game.DebugText += "\n\nPress key 1~5 to watch each item";

                Key[] keys = new Key[] { Key.D1, Key.D2, Key.D3, Key.D4, Key.D5 };
                foreach (Key key in keys)
                {
                    if (game.Keyboard.IsKeyDown(key) == false)
                        continue;

                    if (item != null)
                        game.SceneManager.RemoveRenderable(item.MeshNode);

                    Item.Type type = (Item.Type)(key - keys[0]);
                    item = new Item(game.Framework, game.SceneManager, type);

                    game.SceneManager.Camera.LookMeshNode(item.MeshNode);
                    game.SceneManager.Light.Position = new Vector3(0.0f, 0.0f, item.MeshNode.BoundingRadius * -5.0f);
                }
            };
            game.Run();
        }
Esempio n. 4
0
        public void Layout_Test()
        {
            var game = new TestGame();
            Layout layout = null;
            game.Updated += (o, e) =>
                {
                    game.DebugText += "\n\nPress key 1~ to watch each layout";

                    string[] layoutNames =
                    {
                        @"RocketCommander\GUI\MainMenu.layout",
                        @"RocketCommander\GUI\Help.layout",
                        @"RocketCommander\GUI\MissionSelection.layout"
                    };
                    for (int i = 0; i < layoutNames.Length; ++i)
                    {
                        if (game.Keyboard.IsKeyDown(Key.D1 + i) == false)
                            continue;

                        if (layout != null)
                            game.RemoveLayout(layout);

                        layout = game.Framework.AssetManager.Load(layoutNames[i]) as Layout;
                        game.AddLayout(layout);
                    }
                };
            game.Run();
        }
Esempio n. 5
0
        public void RocketCommanderGame_Keyboard_Test()
        {
            var game = new TestGame();
            game.Updated += (o, e) =>
                {
                    if (game.Keyboard.IsKeyDown(Key.Escape))
                        game.Exit();
                };

            game.Run();
        }
Esempio n. 6
0
 public void RocketCommanderGame_RoamingRocketScene_Test()
 {
     var game = new TestGame();
     game.Updated += (o, e) =>
         {
             if (game.Keyboard.IsKeyDown(Key.D1))
                 game.EnableRoamingRocketScene();
             else if (game.Keyboard.IsKeyDown(Key.D2))
                 game.DisableRoamingRocketScene();
         };
     game.Run();
 }
Esempio n. 7
0
        public void GameCamera_VariousCameras_Test()
        {
            var game = new TestGame();
            game.Updated += (o, e) =>
                {
                    if (game.Keyboard.IsKeyDown(Key.D1))
                        game.Camera = new FreeCamera(game.Mouse, game.Keyboard);
                    else if (game.Keyboard.IsKeyDown(Key.D2))
                        game.Camera = new RoamingCamera(game.Mouse, game.Keyboard, game);
                };

            game.Run();
        }
Esempio n. 8
0
        public void Rocket_Render_Test()
        {
            var game = new TestGame();
            game.Initialized += (o, e) =>
                {
                    var rocket = new Rocket(game.Framework);
                    rocket.MeshNode.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, new Radian(MathUtils.PI * -0.5f));
                    game.SceneManager.AddRenderable(rocket.MeshNode);

                    game.SceneManager.Camera.LookMeshNode(rocket.MeshNode);
                    game.SceneManager.Light.Position = new Vector3(0.0f, 0.0f, rocket.MeshNode.BoundingRadius * -5.0f);
                };

            game.Run();
        }
Esempio n. 9
0
 public void AsteroidManager_Render_Test()
 {
     var game = new TestGame();
     AsteroidManager asteroidManager = null;
     game.Initialized += (o, e) =>
     {
         var level = new Level(game.Framework.AssetManager.GetFullPath(@"RocketCommander/Levels/EasyFlight.level"));
         asteroidManager = new AsteroidManager(level, game);
     };
     game.Updated += (o, e) =>
     {
         asteroidManager.Update();
         game.DebugText += "\n\n" + asteroidManager.GetVisibilityText();
     };
     game.Run();
 }
Esempio n. 10
0
        public void Rocket_InFrontOfCamera_Test()
        {
            var game = new TestGame();

            Rocket rocket = null;
            game.Initialized += (o, e) =>
                {
                    rocket = new Rocket(game.Framework);
                    game.SceneManager.AddRenderable(rocket.MeshNode);

                    game.Camera = new RoamingCamera(game.Mouse, game.Keyboard, game);
                    game.Camera.FovY = new Radian(MathUtils.PI / 1.8f);
                };
            game.Updated += (o, e) =>
                {
                    var inFrontOfCameraPos = new Vector3(0, -1.33f, 2.5f);
                    rocket.MeshNode.Position = inFrontOfCameraPos * game.Camera.ViewMatrix.Invert();

                    rocket.MeshNode.Orientation = game.Camera.Orientation *
                        Quaternion.CreateFromAxisAngle(Vector3.UnitZ, new Radian(game.TotalGameTime / 8500.0f));
                };
            game.Run();
        }