public void TestGetImageType() { GameState state = new GameState(); GameModel m = new GameModel(state); string ImageFile="pawnblack"; string GetImage = m.GetFigureImage(1, 3).ToLower(); Assert.AreEqual(GetImage, ImageFile); }
public void OnWin() { _gameState = Common.GameState.Gameover; gun.BlockGun(); uiManager.DisplayWin(); AudioManager.Instance.PlaySound(AudioManager.Instance.win); }
public void OnStartGame() { _gameState = Common.GameState.Playing; gun.LoadDoneBullets(ballManager.GenerateBallAsBullet(), ballManager.GenerateBallAsBullet()); gun.UnBlockGun(); ballManager.InitBalls(GetLevelProfile()); AudioManager.Instance.PlaySound(AudioManager.Instance.click); }
public void OnGameover() { // Debug.Log("Gameover"); _gameState = Common.GameState.Gameover; gun.BlockGun(); uiManager.DisplayGameOver(); AudioManager.Instance.PlaySound(AudioManager.Instance.gameover); AudioManager.Instance.PlayThemeMenu(); }
public GameModel(GameState gamestate) { this.gameState = gamestate; this.cells = Parse(gameState.GameStateNotation); this.CurrentMoves = new List<CoordinateXY>(); if(gameState.Moves.Count() % 2 == 0) { this.CurrentPlayerWhite = false; } else { this.CurrentPlayerWhite = true; } CssClass(); }
public void OnWin() { Debug.Log("on win event"); _gameState = Common.GameState.Gameover; pusher.OnPause(); gun.BlockGun(); uiManager.DisplayWin(); AudioManager.Instance.PlaySound(AudioManager.Instance.win); ProgressSceneLoader.instance.LoadScene(nameSceneAfterGame); }
public void GameUpdate() { GameMove move = new GameMove() { MoveNotation = "a2 a4" }; // Arrange GamesController controller = new GamesController(repository); // Act GameState updatedGame = controller.Get(gameId); List<GameMove> moves = new List<GameMove>(updatedGame.Moves); moves.Add(move); updatedGame.Moves = moves; controller.Put(updatedGame); updatedGame = controller.Get(gameId); // Assert GameState game = new GameState(); game.RegisterMove(move); Assert.AreEqual(game.GameStateNotation, updatedGame.GameStateNotation); }
public DataService.RepositoryResult<GameState> StartGame(Guid gameRequest, Guid whiteGamer, Guid blackGamer) { GameState game = new GameState() { GameId = gameRequest, BlackGamer = blackGamer, WhiteGamer = whiteGamer }; games.Add(gameRequest, game); return new RepositoryResult<GameState>() { Value = game, IsSuccessStatusCode = true }; }
private void PlayGame(object sender, EventArgs args) { // reset variables level = -1; gameClock.TimeLeft = 20; score = 100; nextLvl(); currentState = GameState.Play; }
void nextLvl() { // clear out the blocks foreach (Block cube in cubes) { cube.Parent = null; } cubes.Clear(); // get rid of cannon balls /* foreach (Cannonball ball in cannonballs) { ball.Parent = null; } cannonballs.Clear();*/ level++; score += gameClock.TimeLeft * 10; gameClock.TimeLeft = 20; switch (level) { case 0 : makeBuilding(); break; case 1: makeGlassBuilding(); break; case 2: makeBigBuilding(); break; case 3: currentState = GameState.End; break; default: break; } }
private void InfoMenu(object sender, EventArgs args) { currentState = GameState.Info; }
private void GameOver(object sender, EventArgs args) { currentState = GameState.End; }
/// <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) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); // TODO: Add your update logic here states[currentState].Update(gameTime); states[currentState].Update(gameTime, Matrix.Identity); #region Sound listeners and emitters listener.Position = cameras[curCamera].Position; listener.Up = cameras[curCamera].Up; listener.Forward = cameras[curCamera].Forward; clickEmitter.Position = cameras[curCamera].Position; //Sound business clickEmitter.Up = cameras[curCamera].Up; clickEmitter.Forward = cameras[curCamera].Forward; cannonEmitter.Position = cameras[2].Position; //Sound business cannonEmitter.Up = cameras[2].Up; cannonEmitter.Forward = cameras[2].Forward; #endregion // to go directly to game state if (InputManager.IsKeyReleased(Keys.D1)) { currentState = GameState.Menu; } if (InputManager.IsKeyReleased(Keys.D2)) { currentState = GameState.Play; } if (InputManager.IsKeyReleased(Keys.D3)) { currentState = GameState.Pause; } if (InputManager.IsKeyReleased(Keys.D4)) { currentState = GameState.End; } // M to Mute if (InputManager.IsKeyReleased(Keys.M)) { mute = !mute; if (mute) { player.Stop(); } else { player.PlayLooping(); } } // P to Pause if (currentState.Equals(GameState.Play) || currentState.Equals(GameState.Pause)) { if (InputManager.IsKeyReleased(Keys.P)) { if (currentState.Equals(GameState.Play)) { currentState = GameState.Pause; } else { currentState = GameState.Play; } } } // Tab to switch cameras if (InputManager.IsKeyPressed(Keys.Tab) && currentState.Equals(GameState.Play)) { if (++curCamera > 2) { curCamera = 0; } } if (currentState.Equals(GameState.Play)) { #region First Person Camera Stuff float elapsedTime = (float)(gameTime.ElapsedGameTime.TotalSeconds); if (InputManager.IsKeyDown(Keys.Up) || InputManager.IsKeyDown(Keys.W)) { if (cameraAngle < MathHelper.PiOver2) // Vertical { cameraAngle += elapsedTime * 2f; cameras[2].RotatePitch = elapsedTime * 2f; } } if (InputManager.IsKeyDown(Keys.Down) || InputManager.IsKeyDown(Keys.S)) { if (cameraAngle > 0.0f) // Horizontal { cameraAngle -= elapsedTime * 2f; cameras[2].RotatePitch = -elapsedTime * 2f; } } if (InputManager.IsKeyDown(Keys.Left) || InputManager.IsKeyDown(Keys.A)) { cameras[2].RotateY = elapsedTime * 2f; } if (InputManager.IsKeyDown(Keys.Right) || InputManager.IsKeyDown(Keys.D)) { cameras[2].RotateY = -elapsedTime * 2f; } #endregion if (InputManager.IsKeyReleased(Keys.Space) && score <= 0) { currentState = GameState.End; // game over } if (cubes.Count <= 0) { foreach (Cannonball ball in cannonballs) { ball.Parent = null; } cannonballs.Clear(); } // used a reverse for loop so the game doesn't crash when the cannonball explodes (ironic) for (int i = cannonballs.Count - 1; i > -1; i--) { Cannonball b = cannonballs[i]; b.Update(gameTime); // used another reverse for loop so the game doesn't crash when the block breaks (double irony) for (int j = cubes.Count - 1; j > -1; j--) { Block c = cubes[j]; if (c.DidCollide(b)) { // SFX: play collision sound based on block type (glass, wood, stone) c.CurrentState = Block.State.Moved; if (c.BlockType != Block.Type.Glass) { b.Explode(); } breakEmitter.Position = c.Position; breakEmitter.Up = c.Up; breakEmitter.Forward = c.Forward; } } } } InputManager.Update(gameTime); base.Update(gameTime); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // set up scene states states = new Dictionary<GameState, Transform>(); states[GameState.Menu] = new Transform(); states[GameState.Info] = new Transform(); states[GameState.Play] = new Transform(); states[GameState.Pause] = new Transform(); states[GameState.End] = new Transform(); currentState = GameState.Menu; InputManager.Initialize(); base.Initialize(); }
/// <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) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); imageAngle += MathHelper.Pi * gameTime.ElapsedGameTime.Milliseconds / 500f; // Increment the angle scaleAngle += MathHelper.Pi * gameTime.ElapsedGameTime.Milliseconds / 500f; // Increment the scale // TODO: Add your update logic here mercury.Update(gameTime); KeyboardState keyboardState = Keyboard.GetState(); if (keyboardState.IsKeyDown(Keys.Escape)) this.Exit(); if (keyboardState.IsKeyDown(Keys.W)) torus.Position += 0.01f * Vector3.UnitZ; if (keyboardState.IsKeyDown(Keys.S)) torus.Position -= 0.01f * Vector3.UnitZ; if (keyboardState.IsKeyDown(Keys.A)) torus.Position -= 0.01f * Vector3.UnitX; if (keyboardState.IsKeyDown(Keys.D)) torus.Position += 0.01f * Vector3.UnitX; if (keyboardState.IsKeyDown(Keys.Up)) camera.RotateX = 0.01f; if (keyboardState.IsKeyDown(Keys.Down)) camera.RotateX = -0.01f; if (keyboardState.IsKeyDown(Keys.Left)) torus.RotateY = -0.01f; if (keyboardState.IsKeyDown(Keys.Right)) torus.RotateY = 0.01f; if (keyboardState.IsKeyDown(Keys.Add)) camera.FieldOfView -= 0.01f; if (keyboardState.IsKeyDown(Keys.Subtract)) camera.FieldOfView += 0.01f; if (keyboardState.IsKeyDown(Keys.P) && prevKeyboardState.IsKeyUp(Keys.P)) gameState = GameState.Pause; if (keyboardState.IsKeyDown(Keys.T) && prevKeyboardState.IsKeyUp(Keys.T)) gameState = GameState.Start; if (keyboardState.IsKeyDown(Keys.I) && prevKeyboardState.IsKeyUp(Keys.I)) gameState = GameState.Play; prevKeyboardState = keyboardState; elements[gameState].Update(gameTime); base.Update(gameTime); }
private void StartNewGame(object sender, EventArgs args) { gameState = GameState.Play; }
private void ToMenu(object sender, EventArgs args) { currentState = GameState.Menu; }
public GameFiguresList(GameState gameState) { figures = new List<Figure>(); this.gameState = gameState; }
public Guid StartGame(GameState newGame) { games.Add(newGame.GameId, new GameFiguresList(newGame)); return newGame.GameId; }