/// <summary> /// Draws the Level Editor UI and finds out if element was clicked /// </summary> /// <param name="texturesDictionary"></param> /// <param name="spriteBatch"></param> /// <param name="transformationMatrix"></param> /// <param name="gameObjectList"></param> /// <param name="graphics"></param> public void DrawLvlEditorUI(Dictionary <string, Texture2D> texturesDictionary, SpriteBatch spriteBatch, Matrix transformationMatrix, ref List <GameObject> gameObjectList, ref List <GameObject> levelGameObjects, GraphicsDevice graphics, ref LoadAndSave loadAndSave, ref Levels levelManager) { int j = 0; MouseState mouseState = Mouse.GetState(); Vector2 firstPosition = new Vector2(1750, 200); Vector2 transformedPos_firstPosition = Vector2.Transform(firstPosition, Matrix.Invert(transformationMatrix)); spriteBatch.Draw(texturesDictionary["Transparent_500x50"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Transparent_1000x50"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Climbingplant_38x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Transparent_64x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; for (int i = 0; i < PlatformsDic.Count(); i++) { spriteBatch.Draw(Platform_TileSheet, transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), PlatformsDic.ElementAt(i).Value, Color.White, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 0); j++; } spriteBatch.Draw(texturesDictionary["SnailShell"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Armor_64x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Shovel_64x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Scissors_64x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["HealthItem"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["PowerPotion"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["JumpPotion"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["GoldenUmbrella"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Spiderweb_64x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["VineDoor"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Apple"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; j++; spriteBatch.Draw(texturesDictionary["EnemySpawnPoint"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["cornnency"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; if (ButtonState.Pressed == mouseState.LeftButton && !button1Pushed) { Vector2 transformedPos = Vector2.Transform(new Vector2(1000, 200), Matrix.Invert(transformationMatrix)); Rectangle checkRectangle; button1Pushed = true; for (int i = 4; i < PlatformsDic.Count() + 4; i++) { checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + i * 100 - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { createNewPlatform(ref gameObjectList, PlatformsDic.ElementAt(i - 4).Key, transformationMatrix, graphics, texturesDictionary); } } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + 0 * 100 - yoffset, 500, 50); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["Transparent_500x50"], new Vector2(512, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.INVISIBLE_WALL_500x50, false)); gameObjectList.Last().DontDrawThisObject(); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + 1 * 100 - yoffset, 1000, 50); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["Transparent_1000x50"], new Vector2(1024, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.INVSIBLE_WALL_1000x50, false)); gameObjectList.Last().DontDrawThisObject(); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + 2 * 100 - yoffset, 38, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["Climbingplant_38x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.VINE, (int)Enums.ObjectsID.VINE, false)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + 3 * 100 - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["Transparent_64x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.INVISIBLE_WALL_64x64, false)); gameObjectList.Last().DontDrawThisObject(); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 4) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["SnailShell"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.SNAILSHELL)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 5) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["Armor_64x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.ARMOR)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 6) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["Shovel_64x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.SHOVEL)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 7) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["Scissors_64x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.SCISSORS)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 8) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["HealthItem"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.HEALTHPOTION)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 9) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["PowerPotion"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.POWERPOTION)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 10) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["JumpPotion"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.JUMPPOTION)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 11) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["GoldenUmbrella"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.GOLDENUMBRELLA)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 12) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["Spiderweb_64x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.SPIDERWEB, false)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 13) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["VineDoor"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.VINEDOOR, false)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 14) * 100) - yoffset, 128, 128); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["Apple"], new Vector2(128, 128), transformedPos, (int)Enums.ObjectsID.APPLE)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 16) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["EnemySpawnPoint"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.ENEMYSPAWNPOINT, true)); gameObjectList.Last().DontDrawThisObject(); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 17) * 100) - yoffset, 128, 128); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["cornnency"], new Vector2(128, 128), transformedPos, (int)Enums.ObjectsID.CORNNENCY)); } } if (ButtonState.Released == mouseState.LeftButton) { button1Pushed = false; } Color color = new Color(); Vector2 positionBackButton = new Vector2(1550, 900); Vector2 transformedBackButton = Vector2.Transform(positionBackButton, Matrix.Invert(transformationMatrix)); Rectangle rectangleBackButton = new Rectangle((int)positionBackButton.X, (int)positionBackButton.Y, 200, 50); if (rectangleBackButton.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { if (ButtonState.Pressed == mouseState.LeftButton && !button2Pushed) { button2Pushed = true; color = Color.LightGray; foreach (GameObject gameObject in gameObjectList) { levelGameObjects.Add(gameObject); } levelManager.sortGameObjects(); loadAndSave.Save(); } else { color = Color.White; } } else { button2Pushed = false; color = Color.White; } spriteBatch.Draw(texturesDictionary["LevelEditorUIBackButton"], transformedBackButton, color); }
//Contains Player Movement in all 4 directions and the attack private void PlayerControls(GameTime gameTime, List <Enemy> enemyList, List <GameObject> interactiveObject, ref List <GameObject> GameObjectsList, LoadAndSave loadAndSave, IngameMenus ingameMenus, List <GameObject> levelGameObjects, ShopKeeper shopKeeper, ItemUIManager itemUIManager, Boss hakume) { //using item: if ((Keyboard.GetState().IsKeyDown(Keys.F) || GamePad.GetState(0).IsButtonUp(Buttons.B)) && !previousState.IsKeyDown(Keys.B) && previousGamepadState.IsButtonDown(Buttons.B)) { int temp = itemUIManager.RemoveObject(); if (temp == (int)Enums.ObjectsID.HEALTHPOTION) { playerHP += 0.1f; if (playerHP >= 1f) { playerHP = 1f; } } if (temp == (int)Enums.ObjectsID.POWERPOTION) { playerDamage *= 2; } if (temp == (int)Enums.ObjectsID.JUMPPOTION) { defaultJumpValue = -22f; } } mouseState = Mouse.GetState(); if (!firstJump && !secondJump) { if (AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Left || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Hat_Left || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Armor_Left || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Armor_Hat_Left) { if (ItemUIManager.snailShellPickedUp && ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Hat_Left; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Hat_Left; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Left; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Left; } } if (AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Right || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Hat_Right || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Armor_Right || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Armor_Hat_Right) { if (ItemUIManager.snailShellPickedUp && ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Hat_Right; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Hat_Right; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Right; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Right; } } } if (!playerGameElementInteraction) { //if (Keyboard.GetState().IsKeyDown(Keys.P)) // ReducePlayerHP(); if (Keyboard.GetState().IsKeyDown(Keys.A) || GamePad.GetState(0).ThumbSticks.Left.X < -0.5f || GamePad.GetState(0).IsButtonDown(Buttons.DPadLeft)) { //Camera won't move after simple turning camera.IncreaseLeftCounter(); camera.ResetRightCounter(); //Camera moves to a direction so that you see better what is coming to you camera.cameraOffset(gameTime, false, true); if (firstJump == true || secondJump == true) { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Hat_Left; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Hat_Left; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Left; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Left; } } else { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Hat_Left; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Hat_Left; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Left; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Left; } } if (!playerGameElementInteraction) { velocity.X = -movementSpeed; } pressedLeftKey = true; facingDirectionRight = false; pressedRightKey = false; } else if (Keyboard.GetState().IsKeyDown(Keys.D) || GamePad.GetState(0).ThumbSticks.Left.X > 0.5f || GamePad.GetState(0).IsButtonDown(Buttons.DPadRight)) { //Camera won't move after simple turning camera.IncreaseRightCounter(); camera.ResetLeftCounter(); //Camera moves to a direction so that you see better what is coming to you camera.cameraOffset(gameTime, true, true); if (firstJump || secondJump) { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Hat_Right; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Right; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Hat_Right; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Right; } } else { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Hat_Right; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Right; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Hat_Right; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Right; } } if (!playerGameElementInteraction) { velocity.X = movementSpeed; } facingDirectionRight = true; pressedLeftKey = false; pressedRightKey = true; } else if (Keyboard.GetState().IsKeyDown(Keys.S) /*|| GamePad.GetState(0).IsButtonDown()*/) { velocity.Y = movementSpeed; } } //Player Jump Input if ((Keyboard.GetState().IsKeyDown(Keys.Space) && !previousState.IsKeyDown(Keys.Space) && !jumpButtonPressed) || (GamePad.GetState(0).IsButtonDown(Buttons.A) && !previousGamepadState.IsButtonDown(Buttons.A) && !jumpButtonPressed)) { if (facingDirectionRight) { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Hat_Right; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Right; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Hat_Right; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Right; } } else { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Hat_Left; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Left; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Hat_Left; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Left; } } jumpButtonPressed = true; playerGameElementInteraction = false; climbAllowed = false; isStanding = false; gravityActive = true; if (firstJump == false || secondJump == false) { jumpSpeed = defaultJumpValue; } PlayerJump(); //MUSIC if (secondJump != true) { audioManager.Play("ReggieJump"); } } //Player Attack Input if ((ButtonState.Pressed == mouseState.LeftButton && cooldown == 0 && !playerGameElementInteraction) || GamePad.GetState(0).IsButtonDown(Buttons.X) && cooldown == 0 && !playerGameElementInteraction) { audioManager.Play("ReggieAttack"); audioManager.Play("ReggieGroaning"); if (facingDirectionRight) { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Armor_Hat_Right; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Armor_Right; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Hat_Right; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Right; } } else { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Armor_Hat_Left; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Armor_Left; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Hat_Left; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Left; } } // TODO: Step1 activate enemyknockback at the specific currentframe, Step2 depending on the size of an enemy (how tall) //foreach (var enemy in enemyList) //{ // if (PlayerAttackCollision(enemy) && enemy.EnemyAliveState() == true && !enemy.invincibilityFrames) // { // enemy.invincibilityFrames = true; // //worm.KnockBackPosition(facingDirectionRight, 35); // enemy.KnockBackPosition(facingDirectionRight); // } //} if (ItemUIManager.currentItemEquipped.objectID == (int)Enums.ObjectsID.SCISSORS) { //Platform temp = null; playerDamage = 3; foreach (Platform platform in levelGameObjects.Cast <GameObject>().OfType <Platform>().ToList()) { if (DetectCollision(platform) && platform.PlatformType == (int)Enums.ObjectsID.SPIDERWEB) { //temp = platform; levelGameObjects.Remove(platform); break; } } //GameObjectsList.Remove(temp); } if (ItemUIManager.currentItemEquipped.objectID == (int)Enums.ObjectsID.SHOVEL) { movementSpeed = 20f; defaultJumpValue = 20f; } //TODO:Destroyable? temp // Platform temp = null; foreach (Platform platform in levelGameObjects.Cast <GameObject>().OfType <Platform>().ToList()) { if (DetectCollision(platform) && platform.PlatformType == (int)Enums.ObjectsID.VINEDOOR) { levelGameObjects.Remove(platform); break; } } //GameObjectsList.Remove(temp); foreach (Item item in levelGameObjects.Cast <GameObject>().OfType <Item>().ToList()) { if (item.objectID == (int)Enums.ObjectsID.APPLE) { if (item.gameObjectRectangle.Contains(this.gameObjectPosition)) { ingameMenus.saveAnimStart(); loadAndSave.Save(); Console.WriteLine("Game Saved"); break; } } } foreach (ShopKeeper shopkeeper in levelGameObjects.Cast <GameObject>().OfType <ShopKeeper>().ToList()) { if (shopkeeper.objectID == (int)Enums.ObjectsID.SHOPKEEPER) { if (shopkeeper.gameObjectRectangle.Contains(this.gameObjectPosition)) { shopKeeper.shopOpen = true; } else { shopKeeper.shopOpen = false; } } } playerAttackPressed = true; } if (playerAttackPressed) { attackTimer += (float)gameTime.ElapsedGameTime.Milliseconds / 100; if (attackTimer != 0 && attackTimer <= 0.5f) { foreach (var enemy in enemyList) { if (PlayerAttackCollision(enemy) && enemy.EnemyAliveState() == true && !enemy.invincibilityFrames) { enemy.invincibilityFrames = true; enemy.KnockBackPosition(facingDirectionRight, playerDamage); //enemy.KnockBackPosition(facingDirectionRight); } } if (PlayerAttackCollision(hakume)) { hakume.ReduceEnemyHP(playerDamage); } } else { attackTimer = 0; } cooldown += (float)gameTime.ElapsedGameTime.TotalSeconds * 2; } if (cooldown >= .75) { cooldown = 0; playerAttackPressed = false; } //Player Gameelement Interactive Input if ((ButtonState.Pressed == mouseState.RightButton || Keyboard.GetState().IsKeyDown(Keys.W) || GamePad.GetState(0).IsButtonDown(Buttons.DPadUp) && !playerGameElementInteraction && !previousState.IsKeyDown(Keys.W) && !previousGamepadState.IsButtonDown(Buttons.DPadUp))) { foreach (var vine in interactiveObject) { if (DetectCollision(vine)) { jumpSpeed = 0; gravityActive = false; isStanding = true; firstJump = false; secondJump = false; jumpButtonPressed = false; playerGameElementInteraction = true; pressedLeftKey = false; pressedRightKey = false; velocity.X = 0; collisionBoxPosition.X = vine.gameObjectRectangle.X; if (gameObjectPosition != collisionBoxPosition - changeCollisionBox) { gameObjectPosition = collisionBoxPosition - changeCollisionBox; } } } } if ((Keyboard.GetState().IsKeyDown(Keys.W) || GamePad.GetState(0).IsButtonDown(Buttons.DPadUp)) && playerGameElementInteraction) { climbAllowed = false; velocity.X = 0; velocity.Y = -movementSpeed - 2; foreach (var vine in interactiveObject) { if (Math.Abs(collisionBoxPosition.X - vine.gameObjectRectangle.X) <= 5) { collisionBoxPosition.X = vine.gameObjectRectangle.X; if (collisionRectangle.Bottom + velocity.Y >= vine.gameObjectRectangle.Top + 30) { climbAllowed = true; } } } if (gameObjectPosition != collisionBoxPosition - changeCollisionBox) { gameObjectPosition = collisionBoxPosition - changeCollisionBox; } if (climbAllowed) { velocity.Y = -movementSpeed - 2; } else { velocity.Y = 0; } } else if ((Keyboard.GetState().IsKeyDown(Keys.S) || GamePad.GetState(0).IsButtonDown(Buttons.DPadDown)) && playerGameElementInteraction) { climbAllowed = false; velocity.X = 0; velocity.Y = movementSpeed + 2; foreach (var vine in interactiveObject) { if (Math.Abs(collisionBoxPosition.X - vine.gameObjectRectangle.X) <= 5) { collisionBoxPosition.X = vine.gameObjectRectangle.X; if (collisionRectangle.Top + velocity.Y <= vine.gameObjectRectangle.Bottom - 80) { climbAllowed = true; } } } if (gameObjectPosition != collisionBoxPosition - changeCollisionBox) { gameObjectPosition = collisionBoxPosition - changeCollisionBox; } if (climbAllowed) { velocity.Y = movementSpeed + 2; } else { velocity.Y = 0; } } if (Keyboard.GetState().IsKeyUp(Keys.D) && Keyboard.GetState().IsKeyUp(Keys.A) && !firstJump && !secondJump && !playerGameElementInteraction) { if (facingDirectionRight) { camera.cameraOffset(gameTime, false, false); } if (!facingDirectionRight) { camera.cameraOffset(gameTime, true, false); } } previousState = Keyboard.GetState(); previousGamepadState = GamePad.GetState(0); }