public override void Update(GameTime gameTime) { float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; #region cutsceneForEndLevel if (iAmInACutscene) { if (Vector2.Distance(teleportDistance, endPosition) < Vector2.Distance(sPosition, endPosition)) { if (!teleporting) { currentDirection = myDirection.none; playAnimation("ninjutsu", false); //currentDirection = myDirection.down; stage1 = true; teleporting = true; framesperSecond = 2; } } else if (!teleporting) { walking = true; } if (stage1) { if (currentAnimation == "ninjutsu") { if (frameIndex == 3) { playAnimation("smoke", false); framesperSecond = 5; } else { // timer.startTimer(10); // timer.update(gameTime); // if(timer.checkTimer) // frameIndex++; } } if (currentAnimation == "smoke") { if (frameIndex == 3) { playAnimation("smoke2", false); stage1 = false; stage2 = true; } else { } } } else if (stage2) { if (currentAnimation == "smoke2") { if (frameIndex == 0) { sPosition = teleportDistance; } if (frameIndex == 3) { stage2 = false; stage3 = true; } else { timer.startTimer(5); timer.update(gameTime); if (timer.checkTimer) { frameIndex++; } } } } else if (stage3) { framesperSecond = 20; playAnimation("idleDown", true); if (currentAnimation == "idleDown") { timer.startTimer(2); timer.update(gameTime); if (timer.checkTimer) { playAnimation("Up", true); currentDirection = myDirection.up; } } if (currentAnimation == "Up") { sDirection = Vector2.Zero; sDirection = endPosition - sPosition; sDirection.Normalize(); sDirection *= mySpeed; position += (direction * deltaTime); if (reachedEndPoint) { currentDirection = myDirection.none; playAnimation("idleDown", false); } } } if (walking) { playAnimation("Up", true); currentDirection = myDirection.up; sDirection = Vector2.Zero; sDirection = endPosition - sPosition; sDirection.Normalize(); sDirection *= mySpeed; position += (direction * deltaTime); } } #endregion if (hasFallen) { playAnimation("death", true); if (myCurrentAnimation.Contains("death")) { framesperSecond = 2; if (frameIndex == 5) { frameIndex = 5; looper++; } if (looper == 5) { active = false; gameIsOver = true; looper = 0; } } else { playAnimation("death", false); } } #region lvl3Cutscene if (bossCutscene1) { inLevelThreeCutscene = true; if (Vector2.Distance(sPosition, ayoubPos) > 200) { sPosition += new Vector2(0, -2); playAnimation("Up", true); } else { playAnimation("idleUp", true); } } if (currentAnimation == "idleUp" && !bossCutscene1) { inLevelThreeCutscene = false; } if (chaseAyoub) { playAnimation("Up", true); currentDirection = myDirection.up; sDirection = Vector2.Zero; sDirection = ayoubPos - sPosition; sDirection.Normalize(); sDirection *= 300; position += (direction * deltaTime); } if (endGameScene) { inLevelThreeCutscene = true; if (Vector2.Distance(sPosition, ayoubPos) > 200) { playAnimation("Up", true); currentDirection = myDirection.up; sDirection = Vector2.Zero; sDirection = ayoubPos - sPosition; sDirection.Normalize(); sDirection *= mySpeed; position += (direction * deltaTime); } else { currentDirection = myDirection.none; playAnimation("idleUp", true); } } #endregion if (!iAmInACutscene && !inLevelThreeCutscene) { sDirection = Vector2.Zero; } if (!hasFallen && !iAmInACutscene && !inLevelThreeCutscene) { handleInput(Keyboard.GetState(), GamePad.GetState(PlayerIndex.One)); } abilityHandler(gameTime); // float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; if (!iAmInACutscene) { sDirection += sDirection * mySpeed; } Rectangle heroRectangle = new Rectangle((int)sPosition.X + 20, (int)sPosition.Y + 12, 22, 53); if (levelManager.levelIndicator == levelManager.levels.levelOne) { map.checkCollision(heroRectangle); maptile.checkCollision(heroRectangle); if (!iAmInACutscene) { sPosition += (sDirection * deltaTime); sPosition.X = MathHelper.Clamp(sPosition.X, 0, 2349); sPosition.Y = MathHelper.Clamp(sPosition.Y, 80, 1650); } } else if (levelManager.levelIndicator == levelManager.levels.levelTwo) { mountainMap.checkCollision(heroRectangle); sPosition += (sDirection * deltaTime); sPosition.X = MathHelper.Clamp(sPosition.X, 80, 2500); sPosition.Y = MathHelper.Clamp(sPosition.Y, 0, 1490); } else if (levelManager.levelIndicator == levelManager.levels.levelThree || levelManager.levelIndicator == levelManager.levels.trainLevel) { if (!inLevelThreeCutscene) { castleMap.checkCollision(heroRectangle); sPosition += (sDirection * deltaTime); } } base.Update(gameTime); }