public override void Update(GameTime gameTime) { _previousScroll = _currentScroll; _currentScroll = GameMouse.ScrollWheelValue; var speed = 0.15f; if (_previousScroll < _currentScroll) { _scale *= 1f + speed; } else if (_previousScroll > _currentScroll) { _scale *= 1f - speed; } if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up)) { _scale *= 1.05f; } else if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down)) { _scale *= 0.95f; } _scale = MathHelper.Clamp(_scale, 1f, 10f); _transform = Matrix.CreateTranslation(0, 0, 0) * //new Vector3((_gameModel.ScreenWidth / 2), (_gameModel.ScreenHeight / 2), 0)) * Matrix.CreateScale(_scale); }
public override void Update(GameTime gameTime) { if (GetInformation != null) { Information = GetInformation(); } if (GetRectangle != null) { Rectangle = GetRectangle(); } if (GameMouse.Intersects(Rectangle)) { OnHover?.Invoke(); IsHover = true; if (GameMouse.IsLeftClicked) { OnSelected?.Invoke(); IsSelected = true; } } else { OffHover.Invoke(); IsHover = false; if (GameMouse.IsLeftClicked && !GameKeyboard.IsKeyDown(Keys.LeftShift)) { OffSelected?.Invoke(); IsSelected = false; } } }
public void Follow(Vector2 followPosition) { var newPosition = followPosition; //newPosition.X = CheckNSet(newPosition.X, MinX); //newPosition.Y = CheckNSet(newPosition.Y, MinY); //newPosition.X = CheckNSet(newPosition.X, MaxX); //newPosition.Y = CheckNSet(newPosition.Y, MaxY); if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right)) { Scale += 0.01f; } else if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left)) { Scale -= 0.01f; } //Scale = 1.57f;// Math.Clamp(Scale, 0.5f, 2.0f); Position = newPosition;// Vector2.Lerp(Position, newPosition, 0.05f); //Transform = Matrix.CreateTranslation(Position.X, Position.Y, 0);v var x = -Position.X + (ZonerGame.ScreenWidth / 2); var y = -Position.Y + (ZonerGame.ScreenHeight / 2); if (MaxX.HasValue && x > MaxX.Value) { x = MaxX.Value; } if (MinX.HasValue && x < MinX.Value) { x = MinX.Value; } if (StaticX.HasValue) { x = StaticX.Value; } if (MaxY.HasValue && y > MaxY.Value) { y = MaxY.Value; } if (MinY.HasValue && y < MinY.Value) { y = MinY.Value; } if (StaticY.HasValue) { y = StaticY.Value; } Transform = Matrix.CreateTranslation(x, y, 0) * Matrix.CreateScale(Scale, Scale, 1); }
/// <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) { GameMouse.Update(); GameKeyboard.Update(); _state.Update(gameTime); base.Update(gameTime); }
/// <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) { GameMouse.Update(gameTime); GameKeyboard.Update(gameTime); _homeStateGUI.Update(gameTime); base.Update(gameTime); }
/// <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) { GameMouse.Update(); GameKeyboard.Update(); _battleGUI.Update(gameTime, new System.Collections.Generic.List <Lib.Models.UnitModel>()); 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() { Content.RootDirectory = "GameJamTestContent"; MediaPlayer.Volume = 0.5f; //MediaPlayer.Volume = 0; base.Initialize(); GameServices.AddService <GraphicsDevice>(GraphicsDevice); GameServices.AddService <ContentManager>(Content); keyboard = new GameKeyboard(); }
/// <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) { base.Update(gameTime); GameKeyboard.Update(gameTime); GameMouse.Update(gameTime); if (GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.G)) { Settings.ShowCollidingBoxes = !Settings.ShowCollidingBoxes; } }
/// <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() { IsMouseVisible = true; Random = new Random(); GameMouse = new GameMouse(); GameKeyboard = new GameKeyboard(); ScreenWidth = _graphics.PreferredBackBufferWidth; ScreenHeight = _graphics.PreferredBackBufferHeight; base.Initialize(); }
/// <summary> /// What happens when wandering around the area /// </summary> /// <param name="gameTime"></param> private void PlayerStateUpdate(GameTime gameTime) { if (GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.G)) { _showGrid = !_showGrid; } _player.Update(gameTime); _currentArea.Update(gameTime); switch (_player.CollisionResult) { case Map.CollisionResults.OffRight: LoadArea(_currentArea.RightArea); _player.X = -_player.CurrentRectangle.Width; break; case Map.CollisionResults.OffLeft: LoadArea(_currentArea.LeftArea); _player.X = _gameModel.ScreenWidth; break; case Map.CollisionResults.OffTop: LoadArea(_currentArea.TopArea); _player.Y = -_player.CurrentRectangle.Height; break; case Map.CollisionResults.OffBottom: LoadArea(_currentArea.BottomArea); _player.Y = _gameModel.ScreenHeight; break; case Map.CollisionResults.Battle: _nextState = States.Battle; _battleState = new BattleState(_gameModel, _players); _battleState.LoadContent(); break; default: break; } }
public void Update() { if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right)) { Position.X--; } else if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left)) { Position.X++; } if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up)) { Position.Y++; } else if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down)) { Position.Y--; } }
private void SetMovementEvent(GameTime gameTime) { if (GameKeyboard.IsKeyPressed(Keys.D)) { Direction = Directions.Right; } else if (GameKeyboard.IsKeyPressed(Keys.A)) { Direction = Directions.Left; } else if (GameKeyboard.IsKeyPressed(Keys.W)) { Direction = Directions.Up; } else if (GameKeyboard.IsKeyPressed(Keys.S)) { Direction = Directions.Down; } else if (GameKeyboard.IsKeyDown(Keys.D)) { _moveComponent.Velocity = new Vector2(_moveComponent.Speed, 0); Direction = Directions.Right; } else if (GameKeyboard.IsKeyDown(Keys.A)) { _moveComponent.Velocity = new Vector2(-_moveComponent.Speed, 0); Direction = Directions.Left; } else if (GameKeyboard.IsKeyDown(Keys.W)) { _moveComponent.Velocity = new Vector2(0, -_moveComponent.Speed); Direction = Directions.Up; } else if (GameKeyboard.IsKeyDown(Keys.S)) { _moveComponent.Velocity = new Vector2(0, _moveComponent.Speed); Direction = Directions.Down; } }
public void Update(GameTime gameTime) { _timer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (_currentText == _fullText) { if (GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Space)) { IsFinished = true; } } else { if (_timer >= 0.05f) { _timer = 0; var character = _fullText[_currentText.Length]; do { _currentText += character; if (_currentText.Length < _fullText.Length) { character = _fullText[_currentText.Length]; } } while (character == ' '); } if (GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Space)) { _currentText = _fullText; } } }
/// <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) { GameMouse.Update(gameTime); GameKeyboard.Update(gameTime); switch (_currentState) { case RoamingState roamingState: //if (roamingState.EnterBattle) //{ // roamingState.EnterBattle = false; // _transition.Start(); //} //if (_transition.State == Transition.States.Middle) //{ // _currentState = new BattleState(_gameModel, _players); // _currentState.LoadContent(); //} break; //case BattleState battleState: // if (battleState.BattleFinished) // { // if (!(_transition is FourCornersTransition)) // _transition = new FourCornersTransition(_gameModel); // _transition.Start(); // } // if (_transition.State == Transition.States.Middle) // { // _currentState = new AfterBattleState(_gameModel, _players); // _currentState.LoadContent(); // } // break; //case AfterBattleState afterBattleState: // if (afterBattleState.Continue) // { // _transition.Start(); // } // if (_transition.State == Transition.States.Middle) // { // _currentState = new RoamingState(_gameModel, _players); // _currentState.LoadContent(); // } // break; case OpeningState openingState: if (openingState.State == OpeningState.States.Fade) { _transition.Start(); } if (_transition.State == Transition.States.Middle) { _currentState = new BattleState(_gameModel, _players, new List <string>() { "Glenda: Any reason why you're completely nude, and surrounded by vampire snakes?", "Nude man: A really fun night I guess..?", "Glenda: Uugh. Just kill them!", }); _currentState.LoadContent(); } break; default: //throw new Exception("Unexpected state: " + _currentState.ToString()); break; } _transition.Update(gameTime); _currentState.Update(gameTime); base.Update(gameTime); }
public override void Update(GameTime gameTime) { if (GameKeyboard.GetKeyUpTrigger(Keys.Escape)) { OpenBackMenu(); } if (start.Visible) { start.Text = (((GameStage)stages["Stage01"]).StartTime / 60).ToString(); start.Location = ((size - start.Size) / 2).ToPoint(); if (((GameStage)stages["Stage01"]).StartTime == 0) { start.Visible = false; } } if ((runStage.MouseWin || runStage.CatWin) && !gameOver.Visible) { Dictionary <string, string> result = new Dictionary <string, string>(); if (runStage.MouseWin && runStage.CatWin) { result["winer"] = "引き分け"; } else if (runStage.MouseWin) { sounds["viruswin"].Play(); result["winer"] = "個人情報大量漏出"; } else if (runStage.CatWin) { sounds["antiviruswin"].Play(); result["winer"] = "ウィルス全滅"; } result["thedatafind"] = string.Format($"取り戻せた情報量:{runStage.AntivirusPoint}"); result["thedatalost"] = string.Format($"盗まれた情報量:{runStage.MousePoint}"); gameOver.ShowResult(result); } if (!backMenu.Visible && !gameOver.Visible) { base.Update(gameTime); } else { if (backMenu.Visible) { backMenu.Update(gameTime); } if (gameOver.Visible) { gameOver.Update(gameTime); } } if (IGGamePad.GetKeyTrigger(PlayerIndex.One, Buttons.Start) && gameOver.Visible) { Initialize(); } else if (IGGamePad.GetKeyTrigger(PlayerIndex.One, Buttons.Back)) { if (gameOver.Visible) { IsRun = false; GameRun.scenes["title"].IsRun = true; Initialize(); } else if (!backMenu.Visible) { OpenBackMenu(); } } }
private void keyboardEvent(GameKeyboard.KeyboardEvent kbEvent, string valueOne) { switch (kbEvent) { case GameKeyboard.KeyboardEvent.KE_WORDUPDATE: m_wordText.text = valueOne; break; } }
private void UpdateWakeUpText(GameTime gameTime) { _timer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (_currentText == _texts.First()) { if (GameKeyboard.IsKeyPressed(Keys.Space)) { _textOpacity = 0; } if (_timer > 1f) { _textOpacity -= 0.01f; if (_textOpacity <= 0) { if (_texts.Count > 1) { _textOpacity = 1f; _texts.RemoveAt(0); _textIndex = 0; _currentText = ""; } } } if (_textOpacity <= -1) { _timer = 0; State = States.Flash; } return; } if (GameKeyboard.IsKeyPressed(Keys.Space)) { var text = _texts.First(); _currentText = text; _textIndex = text.Length; } if (_timer >= 0.3) { _timer = 0.0f; var text = _texts.First(); if (_textIndex < text.Length) { var value = text[_textIndex]; _currentText += value; while (value == ' ') { _textIndex++; value = text[_textIndex]; _currentText += value; } } _textIndex++; } }
public override void Update(GameTime gameTime) { _transition.Update(gameTime); if (_nextState != _currentState) { if (_transition.State == Transition.States.Waiting) { _transition.Start(); } if (_transition.State == Transition.States.FirstHalf) { return; } // Change the state at the half-way point so it can't be seen if (_transition.State == Transition.States.Middle) { _currentState = _nextState; } } switch (_currentState) { case States.Playing: if (GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Escape)) { _nextState = States.Paused; return; } if (GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.M)) { _nextState = States.Map; _mapState.UpdateMap(_currentArea, _player); return; } if (GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.E)) { foreach (var entity in _currentArea.Interactables) { if (_player.CanInteract(entity)) { var interactedComponent = entity.Components.GetComponent <InteractComponent>(); interactedComponent.OnInteract(); } } } PlayerStateUpdate(gameTime); break; case States.Battle: _battleState.Update(gameTime); if (_battleState.BattleFinished) { _nextState = States.AfterBattle; } break; case States.AfterBattle: _afterBattleState.Update(gameTime); if (_afterBattleState.Continue) { _nextState = States.Playing; } break; case States.Paused: if (GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Escape)) { _nextState = States.Playing; return; } _pauseState.Update(gameTime); break; case States.Map: if (GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Escape) || GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.M)) { _nextState = States.Playing; return; } _mapState.Update(gameTime); break; default: throw new Exception("Unknown state: " + this._currentState.ToString()); } }
void Start() { m_target = GameObject.Find("EnemyTarget").GetComponent<EnemyTarget>(); m_enemyMan = GameObject.Find("EnemyManager").GetComponent<EnemyManager>(); m_gameKB = GameObject.Find("GameKeyboard").GetComponent<GameKeyboard>(); m_gameKB.lockKeyboard(false); }