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(); }
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(); }
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(); }
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(); }
public void RocketCommanderGame_Keyboard_Test() { var game = new TestGame(); game.Updated += (o, e) => { if (game.Keyboard.IsKeyDown(Key.Escape)) game.Exit(); }; game.Run(); }
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(); }
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(); }
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(); }
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(); }
public void Mission_Construct_Test() { foreach (string levelFile in new string[] { @"RocketCommander/Levels/EasyFlight.level", @"RocketCommander/Levels/LostCivilization.level", @"RocketCommander/Levels/TheRevenge.level", @"RocketCommander/Levels/ValleyofDeath.level"}) { var game = new TestGame(); var level = new Level(game.Framework.AssetManager.GetFullPath(levelFile)); Assert.AreEqual(Path.GetFileNameWithoutExtension(levelFile), level.Name); Assert.IsTrue(level.Width > 0); Assert.IsTrue(level.Length > 0); Assert.IsTrue(level.Items.Count > 0); Assert.AreEqual(level.Length, level.SunColors.Length); } }
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(); }