public void NewGame() { loadAndSave.LoadGameObjectsNewGame(ref allGameObjectList, ref wormPlayer); allGameObjectList.Add(shopKeeper); levelManager.sortGameObjects(); FillLists(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load <SpriteFont>("Fonts/LuckiestGuy"); LoadAndSave loading = new LoadAndSave(allGameObjectList, texturesDictionary); //MUSIC audioManager.LoadSongsAndSound(this.Content); loading.loadEverything(this.Content, ref playerSpriteSheets, ref texturesDictionary, ref enemySpriteSheets); levelEditor.loadTextures(Content, ref texturesDictionary, graphics.GraphicsDevice); animManager = new AnimationManager(playerSpriteSheets); wormPlayer = new Player(playerSpriteSheets["playerMoveSpriteSheet"], new Vector2(SpriteSheetSizes.spritesSizes["Reggie_Move_X"] / 5, SpriteSheetSizes.spritesSizes["Reggie_Move_Y"] / 5), new Vector2(13444, 1500), (int)Enums.ObjectsID.PLAYER); //SHOP shopKeeper = new ShopKeeper(texturesDictionary["cornnency"], new Vector2(334, 407), new Vector2(2600, 4225), (int)Enums.ObjectsID.SHOPKEEPER, texturesDictionary); //13494 enemySpawnList = new List <Platform>(); allGameObjectList = new List <GameObject>(); interactiveObject = new List <GameObject>(); cornnencyList = new List <GameObject>(); levelObjectList = new List <GameObject>(); loadAndSave.LoadGameObjects(ref allGameObjectList, ref wormPlayer); //allGameObjectList.Add(shopKeeper); levelManager = new Levels(ref wormPlayer.gameObjectPosition, ref levelObjectList, ref allGameObjectList); levelManager.sortGameObjects(); loadAndSave = new LoadAndSave(allGameObjectList, texturesDictionary); ingameMenus = new IngameMenus(spriteBatch, texturesDictionary, playerSpriteSheets); FillLists(); // MONO: use this.Content to load your game content here hakume = new Boss(null, new Vector2(400, 422), new Vector2(-4750, -11450), (int)Enums.ObjectsID.BOSS, enemySpriteSheets); hakume.SetPlayer(wormPlayer); }
/// <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); }