public void SetVelocity(GameWindow gameWindow, Platforms platforms, ref int shift, GameTime gameTime) { velocity.X = baseVelocity; velocity.Y = baseVelocity + 5; Platform platform = platforms.CurrentPlatform(this, gameWindow, shift); if (platform != null) { currentPlatform = platform; platform.MoveUnit(this, gameWindow, platforms, shift); changeShift(ref shift, gameWindow); } currentPlatform.ChangeVelocity(ref velocity); if (IncreaseVelocityBonusChecker == true) { velocity.X += bonusVelocityAcceleration; velocityBonusChecker += gameTime.ElapsedGameTime; if (velocityBonusChecker >= velocityBonusTotalTime) { IncreaseVelocityBonusChecker = false; } } }
public void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, ref int shift, PlayerBullets playerBullets, ContentManager content, Enemies enemies, Bullets bullets) { playerAnimation.Update(gameTime); GetHurt(enemies, bullets); KeyboardState newState = Keyboard.GetState(); SetPlayerDirection(oldState, newState); PlayerJump(oldState, newState, gameWindow, platforms, shift); SetVelocity(gameWindow, platforms, ref shift, gameTime); Shoot(oldState, newState, playerBullets, content); if (canMoveRight(gameWindow, platforms, shift) && newState.IsKeyDown(Keys.Right)) { position.X += velocity.X; changeShift(ref shift, gameWindow); } if (canMoveLeft(gameWindow, platforms, shift) && newState.IsKeyDown(Keys.Left)) { position.X -= velocity.X; changeShift(ref shift, gameWindow); } oldState = newState; EndGame(); }
public override void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, ref int shift, Player Player, ContentManager Content) { this.UpdateTime(gameTime); Rectangle EnemyPlusHisRange = new Rectangle((int)(this.position.X) - Range, (int)(this.position.Y), (int)(this.size.X) + 2 * (int)(Range), (int)(this.size.Y)); if (!(Math.Abs(Player.position.X - this.position.X) < Range) && Where == WhereIGo.movingLeft) { if (!(Math.Abs(position.X - Player.position.X) < Epson)) { if (this.canMoveLeft(gameWindow, platforms, shift)) { position.X -= velocity.X; } if (position.X < Player.position.X) { Where = WhereIGo.movingRight; } } } else if (!(Math.Abs(Player.position.X - this.position.X) < Range) && Where == WhereIGo.movingRight) { if (!(Math.Abs(position.X - Player.position.X) < Epson)) { if (this.canMoveRight(gameWindow, platforms, shift)) { position.X += velocity.X; } if (position.X > Player.position.X) { Where = WhereIGo.movingLeft; } } } if ((Math.Abs(Player.position.Y - this.position.Y) < Range)) { return; } else if (WhereVertical == WhereIGo.movingDown) { if (Math.Abs(position.Y - Player.position.Y) < Epson) { return; } if (this.canMoveDown(gameWindow, platforms, shift)) { position.Y += velocity.Y; } if (position.Y > Player.position.Y) { WhereVertical = WhereIGo.movingUp; } return; } else if (WhereVertical == WhereIGo.movingUp) { if (Math.Abs(position.Y - Player.position.Y) < Epson) { return; } if (this.canMoveUp(gameWindow, platforms, shift)) { position.Y -= velocity.Y; } if (position.Y < Player.position.Y) { WhereVertical = WhereIGo.movingDown; } return; } }
public virtual void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, ref int shift, Player Player) { }
public virtual void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, ref int shift, Player Player, ContentManager content) { }
private void PlayerJump(KeyboardState oldstate, KeyboardState newState, GameWindow gameWindow, Platforms platforms, int shift) { if (!Jumper.Jump(gameWindow, platforms, shift, jumpHeight) && newState.IsKeyDown(Keys.Space) && !oldstate.IsKeyDown(Keys.Space)) { jumpHeight = 0; Jumper.jumpState = JumpManager.JumpState.rising; } if (newState.IsKeyDown(Keys.Space) && jumpHeight < maxJumpHeight) { jumpHeight += 20; } }
public virtual void MoveUnit(Unit unit, GameWindow gameWindow, Platforms platforms, int shift) { }
public virtual bool ShouldBeRemoved(Platforms platforms, Unit Unit, GameWindow gameWindow, GameTime gameTime, int shift) { return(false); }
public void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, int shift) { position.X += Velocity.X; position.Y += Velocity.Y; }
public override void Update(GameTime gameTime, GameWindow gameWindow, Platforms platforms, ref int shift, Player Player, ContentManager Content) { this.UpdateTime(gameTime); animation.Update(gameTime); return; }