public void Combo(GameTime gameTime, List<Enemy>enemies, Collision collision) { if (nextAttack >= (lastAttack + TimeSpan.FromSeconds(1))) { comboCounter = 0; foreach (Enemy enemy in enemies) { if (collision.checkIfPlayerHitEnemy(enemy, this)) { enemy.Hit(20, true); } } lastAttack = gameTime.TotalGameTime; comboCounter = 1; } else { if (comboCounter == 0) { nextAttack = gameTime.TotalGameTime; } else { if (nextAttack >= (lastAttack + TimeSpan.FromSeconds(0.5))) { foreach (Enemy enemy in enemies) { if (collision.checkIfPlayerHitEnemy(enemy, this)) { if (comboCounter == 1) { enemy.Hit(20, true); } if (comboCounter == 2) { enemy.Hit(20, true); } if (comboCounter == 3) { enemy.Hit(20, true); } } } if (comboCounter <= 3) { comboCounter++; } else { comboCounter = 0; } lastAttack = gameTime.TotalGameTime; } else { nextAttack = gameTime.TotalGameTime; } } } }
public void Attack(GameTime gameTime, Player player, Collision collision) { animateAttack(gameTime); if (nextAttack >= (lastAttack + TimeSpan.FromSeconds(1.08))) { if (collision.checkIfEnemyHitPlayer(this, player)) { player.Hit(damage); } lastAttack = gameTime.TotalGameTime; } else { nextAttack = gameTime.TotalGameTime; } }
public void updateHeight(Collision collision, Level level) { if (!collision.checkEnemyLevelCollision(this, level).Contains("Bottom")) { if (airVelocity <= 15) { airVelocity += 0.5f; } location = new Vector2(location.X, location.Y + airVelocity); } }
public bool Move(Player player, Collision collision, Level level, GameTime gameTime, PlayerAnimations playerAnimations) { if (!Recoil(player)) { if (location.X + enemyTex[currentFrame].Width < player.location.X) { if (!collision.checkEnemyLevelCollision(this, level).Contains("Right")) { direction = 1; location.X += 5; animateMove(gameTime); lastAttack = gameTime.TotalGameTime - TimeSpan.FromSeconds(0.5); return false; } } if (location.X > player.location.X + playerAnimations.playerTex[playerAnimations.currentframe].Width) { if (!collision.checkEnemyLevelCollision(this, level).Contains("Left")) { direction = 0; location.X -= 5; animateMove(gameTime); lastAttack = gameTime.TotalGameTime -TimeSpan.FromSeconds(0.5); return false; } } return true; } return false; }
public void UpdateHeight(PlayerAnimations animation, Level level, Collision collision) { if (jumping && allowJump) { if (grounded) { velocity = 15f; } grounded = false; location = new Vector2(location.X, location.Y - velocity); velocity -= 0.5f; if (velocity <= 0) { jumping = false; allowJump = false; } } else { if (grounded) { velocity = 1f; } if (!collision.checkPlayerLevelCollision(animation, this, level).Contains("Bottom")) { if (velocity <= 15) { velocity += 0.5f; } location = new Vector2(location.X, location.Y + velocity); allowJump = false; grounded = false; } else { grounded = true; allowJump = true; } } }
public void MoveRight(PlayerAnimations animation, Level level, GameTime gameTime, Collision collision) { if (!collision.checkPlayerLevelCollision(animation, this, level).Contains("Right")) { animation.BotState = PlayerAnimations.BottomAnimationState.Walking; if (!screenLocked) { level.MoveLevel(1); } else { if (location.X < GlobalVars.resolutionWidth - animation.playerTex[animation.currentframe].Width) { location += new Vector2(GlobalVars.playerSpeed, 0); } } } }
public void MoveLeft(PlayerAnimations animation, Level level, GameTime gameTime, Collision collision) { if (level.location > 0) { if (!collision.checkPlayerLevelCollision(animation, this, level).Contains("Left")) { animation.Moving(gameTime); if (!screenLocked) { level.MoveLevel(-1); } else { if (location.X > 0) { location -= new Vector2(GlobalVars.playerSpeed, 0); } } } } }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load<SpriteFont>(@"Arial"); playerAnimations = new PlayerAnimations(Content); playerInterface = new Interface(Content); player = new Player(playerAnimations); keyboardInput = new KeyboardInput(); database = new DatabaseClass(); collision = new Collision(); enemies = new List<Enemy>(); level = new Level(Content); menu = new Menu(Content); text = new Text(); GlobalVars.currentState = GlobalVars.gameState.mainMenu; }