static void Main(string[] args) { //TestGame.Main(); var game = new TestGame(79, 24); game.GameLoop(); }
public void ProcessInput(TestGame testGameInstance, GameTime gameTime) { _testGameInstance = testGameInstance; ProcessInputForGame(); _oldMouseState = Mouse.GetState(); }
public void ProcessInput(TestGame testGameInstance, GameTime gameTime) { _testGameInstance = testGameInstance; ProcessInputForMenu(); _oldKeyboardState = Keyboard.GetState(); }
public TransparencyTest(IKernel kernel, TestGame game, ContentManager content, GraphicsDevice device) : base("Transparency", kernel) { _kernel = kernel; _content = content; _device = device; _game = game; _batch = new SpriteBatch(device); }
public void TestFixtureSetup() { this.game = new TestGame(); this.gameThread = new Thread(new ThreadStart(game.Run)); this.gameThread.Start(); // I need to give the game enough time to initialise before letting the tests continue System.Threading.Thread.Sleep(200); }
public void Constructor_GivenNullRules_ThrowsException() { // arrange TestGame game; // act:ish Action action = () => game = new TestGame(null); // assert AssertExtension.Throws<ArgumentNullException>(action); }
public Demo( IKernel kernel, TestGame game, ContentManager content, GraphicsDevice device) : base("Demo", kernel) { _kernel = kernel; _content = content; _game = game; }
public void RunThrough_GivenInteger_StepsForwardInTime() { // arrange var game = new TestGame(new StandardRules()); // act game.RunThrough(10); // assert Assert.AreEqual( expected: 10, actual: game.Generation, message: "Game did not step forward correctly."); }
public void Rules_WhenAccessed_ReturnsObjectPassedToConstructor() { // arrange var rules = new StandardRules(); var game = new TestGame(rules); // act var property = game.Rules; // assert Assert.AreSame( expected: rules, actual: property, message: "Wrong rules reference returned by property."); }
public void Game_Run_Test() { var game = new TestGame(); bool initializedFired = false, updateFired = false, drawFired = false, exitingFired = false; game.Initialized += ((o, e) => initializedFired = true); game.Updated += ((o, e) => updateFired = true); game.Exiting += ((o, e) => exitingFired = true); game.Drew += ((o, e) => drawFired = true); game.Run(); Assert.IsTrue(initializedFired); Assert.IsTrue(updateFired); Assert.IsTrue(exitingFired); Assert.IsTrue(drawFired); }
public Demo( IKernel kernel, TestGame game, ContentManager content, GraphicsDevice device) : base("Demo", kernel) { this.kernel = kernel; this.content = content; this.device = device; this.game = game; //aviManager = new AviManager(@"demo.avi", false); //timeline = new DefaultTimeline(framesPerSecond); //timeline.AddAudioGroup("main"); //videoGroup = timeline.AddVideoGroup("main", framesPerSecond, 32, width, height); //videoTrack = videoGroup.AddTrack(); }
private void InitializeGame() { try { _context.Entry(game).State = EntityState.Detached; } catch (Exception) { // TODO: nothing... } game = new TestGame() { GameId = 200, GameStatusCode = "A", GameCategoryId = 1, GamePlatformId = 1, GameName = "Testing Game", GameDescription = "Testing description for Testing Game", GamePrice = 9.99m, GameQty = 100, GameDigitalPath = @"\download\200" }; }
private void runGameWithLogic(Action <Game> logic, Func <Game, bool> exitCondition = null) { Storage storage = null; try { using (var host = new HeadlessGameHost($"{GetType().Name}-{Guid.NewGuid()}", realtime: false)) { storage = host.Storage; using (var game = new TestGame()) { game.Schedule(() => logic(game)); host.UpdateThread.Scheduler.AddDelayed(() => { if (exitCondition?.Invoke(game) == true) { host.Exit(); } }, 0, true); host.Run(game); } } } finally { try { storage?.DeleteDirectory(string.Empty); } catch { // May fail due to the file handles still being open on Windows, but this isn't a big problem for us } } }
public void UpdateLoopCatchupForFixedTimeStepGameWhereStepRateExceedsMAX_ELAPSEDTest() { const int LOOP_COUNT = 5; const int STEP_RATE = 1000; // milliseconds per step const int TARGET_UPDATE_RATE = 100; // update called every 100 ms Assert.Greater((double)STEP_RATE, (double)TestClock.MAX_ELAPSED, "STEP_RATE should be greater than TestClock.MAX_ELAPSED for this test"); DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e) { int i = LOOP_COUNT; while (i-- > 0) { TestClock.Instance.Step(STEP_RATE); e.Game.Tick(); } }); TestGame gd = new TestGame(evt, true); gd.TargetElapsedTime = TimeSpan.FromMilliseconds(TARGET_UPDATE_RATE); gd.Run(); Assert.AreEqual(1 + LOOP_COUNT * TestClock.MAX_ELAPSED / TARGET_UPDATE_RATE, gd.CountUpdate); }
public void DrawCalledWhenIDrawableGameComponentIsVisibleTest() { DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e) { DrawableGameComponentTestBase u = (DrawableGameComponentTestBase)e.Game.Components[0]; for (int i = 1; i < 6; i++) { TestClock.Instance.Step(100); e.Game.Tick(); u.Visible = i % 2 == 0; } }); TestGame game = new TestGame(evt); ((TestGameWindow)game.Window).RaiseVisibleChanged(true); DrawableGameComponentTestBase gc = new DrawableGameComponentTestBase(game); game.Components.Add(gc); game.Run(); Assert.AreEqual(3, gc.CountDraw, "Unexpected draw count"); Assert.AreEqual(6, gc.CountUpdate, "Unexpected update count"); }
public void UpdateLoopForVariableTimeStepGameTest() { const int LOOP_COUNT = 5; const int STEP_RATE = 50; // milliseconds per step const int TARGET_UPDATE_RATE = 100; // update called every 100 ms DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e) { int i = LOOP_COUNT; while (i-- > 0) { TestClock.Instance.Step(STEP_RATE); e.Game.Tick(); } }); TestGame gd = new TestGame(evt, true); gd.TargetElapsedTime = TimeSpan.FromMilliseconds(TARGET_UPDATE_RATE); gd.IsFixedTimeStep = false; ((TestGameWindow)gd.Window).RaiseVisibleChanged(true); gd.Run(); Assert.AreEqual(gd.CountUpdate, gd.CountDraw + 1); }
public void DrawNotCalledOnNonVisibleIDrawableGameComponent() { DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e) { e.Game.Tick(); }); TestGame game = new TestGame(evt); ((TestGameWindow)game.Window).RaiseVisibleChanged(true); DrawableGameComponentTestBase gc = new DrawableGameComponentTestBase(game); game.Components.Add(gc); gc.Visible = false; game.Run(); Assert.AreEqual(0, gc.CountDraw); }
private void load(TestGame game) { blockingClose = game.BlockExit.GetBoundCopy(); }
public LightingTest(TestGame game, int width, int height) : base(game, width, height) { }
public void InitializeGraphicsTest() { Game = new TestGame(); }
public Pad(TestGame game) : base(game) { }
public Player(TestGame game) : base(game) { }
public Goat(TestGame game, int width, int height) : base(game, width, height) { }
public void IsFixedTimeStepDefaultTrueTest() { TestGame game = new TestGame(); Assert.IsTrue(game.IsFixedTimeStep, "IsFixedTimeStep should be true"); }
public void IsActiveDefaultTrueTest() { TestGame game = new TestGame(); Assert.IsTrue(game.IsActive, "IsActive should be true"); }
public void Constructors() { TestGame game = new TestGame(); Assert.IsNotNull(game, "Failed to create TestGame"); }
public TestWindow() { Game = new TestGame(); InitializeComponent(); }
public void UpdateCalledOnceForIUpdatableGameComponent() { DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e) { GameComponentTestBase u = (GameComponentTestBase)e.Game.Components[0]; u.Enabled = false; for (int i = 0; i < 5; i++) { TestClock.Instance.Step(100); e.Game.Tick(); } }); TestGame game = new TestGame(evt); GameComponentTestBase gc = new GameComponentTestBase(game); game.Components.Add(gc); game.Run(); Assert.AreEqual(1, gc.CountUpdate); }
public void Init() { game = new TestGame(true); components = game.Components; }
public ParticleLight (TestGame game, int width, int height) : base(game, width, height) { }
private void Awake() { Ins = this; m_update = gameObject.GetComponent <UpdateResFromServer>(); m_update.Init(); }
private static void DeviceFound(object sender, DeviceEventArgs args) { INatDevice device = args.Device; IGamePortMapping gamePortMapping; switch (Mode) { case Mode.ADD: case Mode.REMOVE: if (GameName == "TestGame") { //Tweak pour load l'assembly gamePortMapping = new TestGame(); } else { gamePortMapping = (IGamePortMapping)AssemblyLoader.GetInstanceOfGameMapping(GameName); } if (gamePortMapping == null) { Console.WriteLine("Le jeu " + GameName + " n'a pas été trouvé, veuillez réessayer."); System.Environment.Exit(1); } Console.WriteLine(gamePortMapping.Description()); if (Mode == Mode.REMOVE) { Console.WriteLine("Le système va tenter de supprimer ces ports de la table NAT"); } else { Console.WriteLine("Le système va tenter d'ajouter ces ports de la table NAT"); } Console.WriteLine("Appliquer ? [O]/N"); String res = Console.ReadLine(); if (res.ToLower().Equals("n")) { System.Environment.Exit(0); } GamePortMappingApplier applier = new GamePortMappingApplier(gamePortMapping); if (Mode == Mode.ADD) { applier.AddRules(device); Console.WriteLine("Les ports sont bien ajoutés, le système reste ouvert et va se relancer toutes les 500 secondes"); Console.WriteLine("CTRL+C pour quitter"); } else { applier.RemoveRules(device); Environment.Exit(0); } break; case Mode.LISTPORT: var routerTable = device.GetAllMappings(); foreach (Mapping m in routerTable) { Console.WriteLine(m.ToString()); } Environment.Exit(0); break; default: break; } }
//Initializes variables void Awake() { game = FindObjectOfType <TestGame>().GetComponent <TestGame>(); }
internal TestGame Create(TestGame newGame) { _repo.Create(newGame); return(newGame); }
public ResultGameState(TestGame game) { this.game = game; }
public void GameWindowSetTest() { TestGame game = new TestGame(); Assert.IsNotNull(game.Window, "Window is not set"); Assert.IsInstanceOfType(typeof (TestGameWindow), game.Window); }
static void Main(string[] args) { var fieldGenerator = new PreciseFieldGenerator(new PreciseFieldGeneratorParams(-690520614, 20)); int width = 10, height = 10; var game = new TestGame(fieldGenerator, width, height); markX = 0; markY = 0; PrintField(width, height, game.Field); while (true) { var key = System.Console.ReadKey(); switch (key.Key) { case ConsoleKey.UpArrow: { if (markX == 0) { break; } markX--; Reprint(width, height, game.Field); break; } case ConsoleKey.DownArrow: { if (markX >= width - 1) { break; } markX++; Reprint(width, height, game.Field); break; } case ConsoleKey.LeftArrow: { if (markY == 0) { break; } markY--; Reprint(width, height, game.Field); break; } case ConsoleKey.RightArrow: { if (markY >= height - 1) { break; } markY++; Reprint(width, height, game.Field); break; } case ConsoleKey.F: { game.MakeMove(new Move(markX, markY, Data.MoveType.Flag)); Reprint(width, height, game.Field); break; } case ConsoleKey.Enter: { var result = game.MakeMove(new Move(markX, markY, Data.MoveType.Click)); Reprint(width, height, game.Field); switch (result.ResultType) { case Enums.MoveResultType.GameOver: System.Console.WriteLine("Game over."); break; case Enums.MoveResultType.Victory: System.Console.WriteLine("Victory"); break; case Enums.MoveResultType.Opened: System.Console.WriteLine(string.Join(", ", result.OpenedCells.Select(x => $"{x.X}: {x.Y}"))); break; } break; } default: return; } } }
public void DrawCalledWhenIDrawableGameComponentIsVisibleTest() { DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e) { DrawableGameComponentTestBase u = (DrawableGameComponentTestBase)e.Game.Components[0]; for (int i = 1; i < 6; i++) { TestClock.Instance.Step(100); e.Game.Tick(); u.Visible = i%2 == 0; } }); TestGame game = new TestGame(evt); ((TestGameWindow)game.Window).RaiseVisibleChanged(true); DrawableGameComponentTestBase gc = new DrawableGameComponentTestBase(game); game.Components.Add(gc); game.Run(); Assert.AreEqual(3, gc.CountDraw, "Unexpected draw count"); Assert.AreEqual(6, gc.CountUpdate, "Unexpected update count"); }
public RampTest(TestGame game, int width, int height) : base(game, width, height) { }
public void TestComponents() { var testGame = new TestGame(); testGame.OnInitialized += game => { var sw = new Stopwatch(); sw.Start(); var manager = game.GameObjectManager; // Expect there to be 0 game objects. Assert.AreEqual(0, manager.GameObjects.Count, "Expected 0 root objects."); var go = game.AddGameObject(); var child = go.AddObject(); // Expect there to be 1 root game object and 1 child in go. Assert.AreEqual(1, manager.GameObjects.Count, "Expected 1 root object."); Assert.AreEqual(1, go.Children.Count, "Expected 1 child object."); // Expect go's name to be the name of the class. Assert.AreEqual(typeof(GameObject).Name, go.Name, "Expected root object's name to be 'GameObject'."); Assert.AreEqual(typeof(GameObject).Name, child.Name, "Expected child's name to be 'GameObject'."); // Expect object's sibling count to be 1. Assert.AreEqual(1, go.Siblings.Count, "Expected root object's siblings count to be 1."); Assert.AreEqual(1, child.Siblings.Count, "Expected child object's siblings count to be 1."); var child2 = go.AddObject(); // Expect root object's sibling count to be 2. Assert.AreEqual(1, go.Siblings.Count, "Expected root object's siblings count to be 1."); Assert.AreEqual(2, child.Siblings.Count, "Expected child object's siblings count to be 2."); Assert.AreEqual(2, go.Children.Count, "Expected root object's children count to be 2."); // Expect object component count to be 1 and for it to have a Transform component. Assert.AreEqual(1, go.Components.Count, "Expected object's Component count to be 1."); Assert.AreEqual(typeof(Transform), go.GetComponent<Transform>()?.GetType(), "Expected object to have a Transform component."); // Expect object to be enabled and visible. Assert.AreEqual(true, go.Enabled, "Expected object to be Enabled."); Assert.AreEqual(true, go.Visible, "Expected object to be visible."); // Expect every component to be enabled. Assert.IsTrue(go.Components.All(comp => comp.Value.Enabled), "Expected all components to be enabled."); go.Enabled = false; // Expect every component to be disabled. Assert.IsTrue(go.Components.All(comp => !comp.Value.Enabled), "Expected all components to be disabled."); go.Enabled = true; // Expect every component to be enabled. Assert.IsTrue(go.Components.All(comp => comp.Value.Enabled), "Expected all components to be enabled."); child.Destroy(); // Expect there to be 1 child object and for child to be destroyed. Assert.AreEqual(1, go.Children.Count, "Expected 1 child object."); Assert.AreEqual(true, child.Destroyed, "Expected child to be destroyed."); Assert.AreEqual(0, child.Components.Count, "Expected destroyed object to have 0 components."); go.Destroy(); // Expect there to be 0 objects and for Object to be destroyed. Assert.AreEqual(0, manager.GameObjects.Count, "Expected 0 root objects."); Assert.AreEqual(true, go.Destroyed, "Expected object to be destroyed."); // Test cloning go = game.AddGameObject(); var clone = go.Clone(); // Expect clone name to be 'GameObject (Clone)' Assert.AreEqual(go.Name + " (Clone)", clone.Name, "Expected clone's name to be original name plus ' (Clone)'."); // Test setting properties var component = go.AddComponent<TestComponent>(); Assert.AreEqual("default", component.TestString, "Expected default TestString value to equal 'default'."); go.RemoveComponent<TestComponent>(); component = go.AddComponent<TestComponent>(new { TestString = "custom" }); Assert.AreEqual("custom", component.TestString, "Expected custom TestString value to equal 'custom'."); // Expect clones to not equal the original object. Assert.AreNotEqual(go, clone, "Expected clone to be separate instance"); Assert.IsTrue(go.Components.Values.All(comp => !clone.Components.ContainsValue(comp)), "Expected cloned components to be separate instances from original components."); Assert.IsTrue(go.Children.All(_child => !clone.Children.Contains(_child)), "Expected cloned children to be separate instances from original children."); Console.WriteLine(game.ToHierarchyString()); game.GameObjectManager.Destroy(); // Expect there to be 0 objects. Assert.AreEqual(0, game.GameObjectManager.GameObjects.Count, "Expected total root objects count to be 0."); sw.Stop(); Console.WriteLine("TestComponents took " + sw.Elapsed.TotalMilliseconds + " ms."); }; testGame.RunOneFrame(); }
} // ResetRenderTarget(fullResetToBackBuffer) #endregion #region Unit Testing #if DEBUG /// <summary> /// Test create render to texture /// </summary> static public void TestCreateRenderToTexture() { Model testModel = null; RenderToTexture renderToTexture = null; TestGame.Start( "TestCreateRenderToTexture", delegate { testModel = new Model("asteroid1"); renderToTexture = new RenderToTexture( //SizeType.QuarterScreen); SizeType.HalfScreen); //SizeType.HalfScreenWithZBuffer); //SizeType.FullScreen); //SizeType.ShadowMap); }, delegate { bool renderToTextureWay = Input.Keyboard.IsKeyUp(Keys.Space) && Input.GamePadAPressed == false; BaseGame.Device.RenderState.DepthBufferEnable = true; if (renderToTextureWay) { // Set render target to our texture renderToTexture.SetRenderTarget(); // Clear background renderToTexture.Clear(Color.Blue); // Draw background lines //Line.DrawGrid(); //Ui.LineManager.RenderAll3DLines(); // And draw object testModel.Render(Matrix.CreateScale(7.5f)); //BaseGame.RenderManager.RenderAllMeshes(); // Do we need to resolve? renderToTexture.Resolve(true); //BaseGame.Device.ResolveRenderTarget(0); // Reset background buffer //not longer required, done in Resolve now: //RenderToTexture.ResetRenderTarget(true); } // if (renderToTextureWay) else { // Copy backbuffer way, render stuff normally first // Clear background BaseGame.Device.Clear(Color.Blue); // Draw background lines //Line.DrawGrid(); //Ui.LineManager.RenderAll3DLines(); // And draw object testModel.Render(Matrix.CreateScale(7.5f)); //BaseGame.RenderManager.RenderAllMeshes(); } // else // Show render target in a rectangle on our screen renderToTexture.RenderOnScreen( //tst: new Rectangle(100, 100, 256, 256)); //BaseGame.ScreenRectangle); //no need: BaseGame.UI.FlushUI(); TextureFont.WriteText(2, 0, " Press Space to toogle full screen rendering"); TextureFont.WriteText(2, 30, "renderToTexture.Width=" + renderToTexture.Width); TextureFont.WriteText(2, 60, "renderToTexture.Height=" + renderToTexture.Height); TextureFont.WriteText(2, 90, "renderToTexture.Valid=" + renderToTexture.IsValid); TextureFont.WriteText(2, 120, "renderToTexture.XnaTexture=" + renderToTexture.XnaTexture); TextureFont.WriteText(2, 150, "renderToTexture.ZBufferSurface=" + renderToTexture.ZBufferSurface); TextureFont.WriteText(2, 180, "renderToTexture.Filename=" + renderToTexture.Filename); }); } // TestCreateRenderToTexture()
public QuestionGameState(TestGame game) { this.game = game; }
public static void Main() { { var test = new TestController(); test.TestExitLoop(); test.TestPlayState(); test.TestStop(); test.TestPause(); test.TestDefaultValues(); test.TestVolume(); test.TestIsLooped(); test.TestPlay(); } { var test = new TestAudioSystem(); test.TestDopplerCoherency(); test.TestAttenuationCoherency(); test.TestLocalizationCoherency(); test.TestSeveralControllers(); test.TestEffectsAndMusic(); test.TestAddRemoveEmitter(); test.TestRemoveListener(); test.TestAddListener(); test.TestAudioEngine(); test.TestAddRemoveListener(); } { var test = new TestAudioEmitterProcessor(); test.TestEmitterUpdateValues(); test.TestAddRemoveListeners(); test.TestAddRemoveEntityWithEmitter(); test.TestAddRemoveSoundEffect(); } { var test = new TestAudioEmitterComponent(); test.TestInitialization(); test.TestAttachDetachSounds(); test.TestGetController(); } { var test = new TestAudioListenerProcessor(); test.TestAddAudioSysThenEntitySys(); test.TestAddEntitySysThenAudioSys(); test.TestRemoveListenerFromAudioSystem(); test.TestRemoveListenerFromEntitySystem(); } { var test = new TestGame(); test.TestAccessToAudio(); test.TestCreationDestructionOfTheGame(); } { var test = new TestScriptContext(); test.TestScriptCreationDestruction(); test.TestScriptAudioAccess(); } { var test = new TestAssetLoading(); test.TestSoundEffectLoading(); test.TestSoundMusicLoading(); } }
public void ProcessInput(TestGame testGameInstance, GameTime gameTime) { GetCurrentInputController().ProcessInput(testGameInstance, gameTime); }
public void UpdateNotCalledOnDisabledIUpdatableGameComponent() { TestGame game = new TestGame(new NullEventSource()); GameComponentTestBase gc = new GameComponentTestBase(game); game.Components.Add(gc); gc.Enabled = false; game.Run(); Assert.AreEqual(0, gc.CountUpdate); }
public float[][] brainOutput; // !! Or if this should live inside the miniGameInstance public TestGameManager(TestTrainer testTrainer) { testTrainerRef = testTrainer; testGameInstance = new TestGame(); SetInputOutputArrays(); }
static void Main() { using (var game = new TestGame()) game.Run(); }
public ParticleLight(TestGame game, int width, int height) : base(game, width, height) { }
public void InitializeCalledOnIGameComponentTest() { TestGame game = new TestGame(new NullEventSource()); GameComponentTestBase gc = new GameComponentTestBase(game); game.Components.Add(gc); game.Run(); Assert.AreEqual(1, gc.CountInitialize); }
public void GameSleepsWhenDeactivatedTest() { DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e) { ((TestGameWindow)e.Game.Window).RaiseDeactivating(); Assert.IsFalse(e.Game.IsActive, "Game should be inactive."); e.Game.Tick(); }); TestGame gd = new TestGame(evt, true); gd.InactiveSleepTime = TimeSpan.FromMilliseconds(500); Stopwatch sw = Stopwatch.StartNew(); gd.Run(); sw.Stop(); Assert.IsTrue(sw.ElapsedMilliseconds >= 500, "Time elapsed should be at least 500ms"); }
protected Entity(TestGame game) : base(game) { }
protected override Game CreateGame() => game = new TestGame();
internal void Update(TestGame update) { string sql = @"UPDATE testgame SET playerName = @PlayerName, profileImg = @ProfileImg, playerEnergy = @PlayerEnergy, playerTool = @PlayerTool, playerMoney = @PlayerMoney, resource1 = @Resource1, resource2 = @Resource2, resource3 = @Resource3, resource4 = @Resource4, planetId = @PlanetId WHERE id = @Id;"; _db.Execute(sql, update); }