public static bool HasCollisionWithObject(Player player, int targetPositionX, int targetPositionY, Map map, Vector2 mapPosition)
        {
            Rectangle playerRect = new Rectangle(targetPositionX, targetPositionY, player.Image.Width,
                player.Image.Height);

            foreach(var mapElement in map.MapElements)
            {
                var mapElementRect = new Rectangle(mapElement.TopLeftX + (int) mapPosition.X,
                                                   mapElement.TopLeftY + (int) mapPosition.Y,
                                                   mapElement.Image.Width,
                                                   mapElement.Image.Height);

                if (playerRect.Intersects(mapElementRect))
                {
                    return true;
                }
            }

            foreach (var mapCreature in map.MapCreatures)
            {
                var mapCreatureRect = new Rectangle(mapCreature.TopLeftX + (int)mapPosition.X,
                                                   mapCreature.TopLeftY + (int)mapPosition.Y,
                                                   mapCreature.Image.Width,
                                                   mapCreature.Image.Height);

                if (playerRect.Intersects(mapCreatureRect))
                {
                    return true;
                }
            }

            return false;
        }
        public static void DrawPlayer(Player player,SpriteBatch spriteBatch, ContentManager content)
        {
            spriteBatch.Draw(player.Image, new Vector2(player.TopLeftX, player.TopLeftY)); // draw player

            StatBar.DrawEnergyBar(player, 10, spriteBatch, content, Vector2.Zero);
            StatBar.DrawFocusBar(player, 13, spriteBatch, content, Vector2.Zero);
            StatBar.DrawExperienceBar(player, 16, spriteBatch, content, Vector2.Zero);
        }
        public static double GetDistanceBetweenObjects(Player player, Creature creature, Vector2 mapPosition)
        {
            Vector2 playerPoint = GetCenterOfRectangle(player);
            Vector2 creaturePoint = GetCenterOfRectangle(creature);

            double a = (double)((creaturePoint.X + mapPosition.X/2) - playerPoint.X);
            double b = (double)((creaturePoint.Y + mapPosition.Y/2) - playerPoint.Y);

            return Math.Sqrt(a * a + b * b);
        }
        public static void DrawExperienceBar(Player player, int barOffSet, SpriteBatch spriteBatch, ContentManager content, Vector2 mapPosition)
        {
            spriteBatch.Draw(content.Load<Texture2D>("GUI/statbar"), new Vector2(player.TopLeftX + mapPosition.X, player.TopLeftY - barOffSet + mapPosition.Y));

            double percentageFull = ((double)player.Experience / player.LevelUpExperience) * FullBarWidth;

            for (int i = 0; i < percentageFull; i++)
            {
                spriteBatch.Draw(content.Load<Texture2D>("GUI/experience-filler"),
                    new Vector2((player.TopLeftX + 1 + i) + mapPosition.X,
                                (player.TopLeftY - (barOffSet - 1)) + mapPosition.Y));
            }
        }
        public static Creature GetClosestCreature(Map map, Player player, Vector2 mapPostion)
        {
            double closestCreatureDistance = Double.MaxValue;
            Creature closestCreature = null;

            foreach (var mapCreature in map.MapCreatures)
            {
                double currentDistance = GetDistanceBetweenObjects(player, mapCreature,mapPostion);
                if (currentDistance < closestCreatureDistance)
                {
                    closestCreature = mapCreature;
                    closestCreatureDistance = currentDistance;
                }
            }

            return closestCreature;
        }
        public static bool HasCollisionWithEnemy(Player player, Map map, Vector2 mapPosition, out int hashcodeOfCollidedEnemy)
        {
            Rectangle playerRect = new Rectangle(player.TopLeftX, player.TopLeftY, player.Image.Width, player.Image.Height);

            foreach (var creature in map.MapCreatures)
            {
                bool intersects =
                    playerRect.Intersects(new Rectangle(creature.TopLeftX + (int)mapPosition.X, creature.TopLeftY + (int)mapPosition.Y, creature.Image.Width,
                        creature.Image.Height));
                if (intersects)
                {
                    hashcodeOfCollidedEnemy = creature.GetHashCode();
                    return true;
                }
            }

            hashcodeOfCollidedEnemy = 0;
            return false;
        }
        public static bool HasCollisionWithItem(Player player, Map map, Vector2 mapPosition, out int hashcodeOfCollidedItem)
        {
            Rectangle playerRect = new Rectangle(player.TopLeftX, player.TopLeftY, player.Image.Width, player.Image.Height);

            foreach (var mapItem in map.MapItems)
            {
                var mapItemRect = new Rectangle(mapItem.TopLeftX + (int) mapPosition.X,
                                                mapItem.TopLeftY + (int) mapPosition.Y,
                                                mapItem.Image.Width,
                                                mapItem.Image.Height);

                if (playerRect.Intersects(mapItemRect))
                {
                    hashcodeOfCollidedItem = mapItem.GetHashCode();
                    return true;
                }
            }

            hashcodeOfCollidedItem = 0;
            return false;
        }
        protected override void LoadContent()
        {
            this.spriteBatch = new SpriteBatch(GraphicsDevice);

            this.playButton = new Button("play", Content.Load<Texture2D>("GUI/MainMenuTextures/play"), 700, 50);
            this.howToPlayButton = new Button("howToPlay", Content.Load<Texture2D>("GUI/MainMenuTextures/howToPlay"), 700, 200);
            this.aboutButton = new Button("about", Content.Load<Texture2D>("GUI/MainMenuTextures/about"), 700, 350);
            this.quitButton = new Button("quit", Content.Load<Texture2D>("GUI/MainMenuTextures/quit"), 700, 500);

            this.playButton.Click += OnClick;
            this.howToPlayButton.Click += OnClick;
            this.aboutButton.Click += OnClick;
            this.quitButton.Click += OnClick;

            this.mainMenu.Buttons.Add(playButton);
            this.mainMenu.Buttons.Add(howToPlayButton);
            this.mainMenu.Buttons.Add(aboutButton);
            this.mainMenu.Buttons.Add(quitButton);

            this.map.SetMapBackground(Content.Load<Texture2D>("MapElementsTextures/map"));
            MapFactory.LoadMapObjectsFromTextFile(map, MainClass.MapCoordinates, this.Content);

            this.mapPosition = new Vector2(0, 0);

            this.player = new NormalStudent();
        }
        public static void DrawInventory(Player player, SpriteBatch spriteBatch, ContentManager content)
        {
            SpriteFont inventoryNumberFont = content.Load<SpriteFont>("Fonts/InventoryNumberOfItems");

            Texture2D beer = content.Load<Texture2D>("GUI/Inventory/block-beer");
            Texture2D noBeer = content.Load<Texture2D>("GUI/Inventory/block-nobeer");
            Vector2 beerPosition = new Vector2(400, 650);
            int numberOfBeers = player.Inventory.Count(item => item is Beer);

            Texture2D redbull = content.Load<Texture2D>("GUI/Inventory/block-redbull");
            Texture2D noRedbull = content.Load<Texture2D>("GUI/Inventory/block-noredbull");
            Vector2 redbullPosition = new Vector2(450, 650);
            int numberOfRedbulls = player.Inventory.Count(item => item is RedBull);

            Texture2D ram = content.Load<Texture2D>("GUI/Inventory/block-ram");
            Texture2D noRam = content.Load<Texture2D>("GUI/Inventory/block-noram");
            Vector2 ramPosition = new Vector2(500, 650);

            Texture2D hdd = content.Load<Texture2D>("GUI/Inventory/block-hdd");
            Texture2D noHdd = content.Load<Texture2D>("GUI/Inventory/block-nohdd");
            Vector2 hddPosition = new Vector2(550, 650);

            Texture2D cpu = content.Load<Texture2D>("GUI/Inventory/block-cpu");
            Texture2D noCpu = content.Load<Texture2D>("GUI/Inventory/block-nocpu");
            Vector2 cpuPosition = new Vector2(600, 650);

            Texture2D book = content.Load<Texture2D>("GUI/Inventory/block-book");
            Texture2D noBook = content.Load<Texture2D>("GUI/Inventory/block-nobook");
            Vector2 bookPosition = new Vector2(700, 650);

            Texture2D resharper = content.Load<Texture2D>("GUI/Inventory/block-resharper");
            Texture2D noResharper = content.Load<Texture2D>("GUI/Inventory/block-noresharper");
            Vector2 resharperPosition = new Vector2(750, 650);

            if (player.Inventory.Any(x => x is Beer))
            {
                spriteBatch.Draw(beer, beerPosition);
                spriteBatch.DrawString(inventoryNumberFont, numberOfBeers.ToString(), new Vector2(beerPosition.X + 36, beerPosition.Y + 4), Color.WhiteSmoke);
            }
            else
            {
                spriteBatch.Draw(noBeer, beerPosition);
            }

            if (player.Inventory.Any(x => x is RedBull))
            {
                spriteBatch.Draw(redbull, redbullPosition);
                spriteBatch.DrawString(inventoryNumberFont, numberOfRedbulls.ToString(), new Vector2(redbullPosition.X + 36, redbullPosition.Y + 4), Color.WhiteSmoke);
            }
            else
            {
                spriteBatch.Draw(noRedbull, redbullPosition);
            }

            if (player.Inventory.Any(x => x is MemoryUpgrade))
            {
                spriteBatch.Draw(ram, ramPosition);
            }
            else
            {
                spriteBatch.Draw(noRam, ramPosition);
            }

            if (player.Inventory.Any(x => x is DiskUpgrade))
            {
                spriteBatch.Draw(hdd, hddPosition);
            }
            else
            {
                spriteBatch.Draw(noHdd, hddPosition);
            }

            if (player.Inventory.Any(x => x is ProcessorUpgrade))
            {
                spriteBatch.Draw(cpu, cpuPosition);
            }
            else
            {
                spriteBatch.Draw(noCpu, cpuPosition);
            }

            if (player.Inventory.Any(x => x is NakovBook))
            {
                spriteBatch.Draw(book, bookPosition);
            }
            else
            {
                spriteBatch.Draw(noBook, bookPosition);
            }

            if (player.Inventory.Any(x => x is Resharper))
            {
                spriteBatch.Draw(resharper, resharperPosition);
            }
            else
            {
                spriteBatch.Draw(noResharper, resharperPosition);
            }
        }
        public static void DrawPlayerLevel(Player player, SpriteBatch spriteBatch, ContentManager content)
        {
            Texture2D level = level = content.Load<Texture2D>("GUI/LevelsBlocks/1");

            switch (player.CurrentLevel)
            {
                case 2: level = content.Load<Texture2D>("GUI/LevelsBlocks/2");
                    break;
                case 3: level = content.Load<Texture2D>("GUI/LevelsBlocks/3");
                    break;
                case 4: level = content.Load<Texture2D>("GUI/LevelsBlocks/4");
                    break;
                case 5: level = content.Load<Texture2D>("GUI/LevelsBlocks/5");
                    break;
                case 6: level = content.Load<Texture2D>("GUI/LevelsBlocks/6");
                    break;
                case 7: level = content.Load<Texture2D>("GUI/LevelsBlocks/7");
                    break;
                case 8: level = content.Load<Texture2D>("GUI/LevelsBlocks/8");
                    break;
                case 9: level = content.Load<Texture2D>("GUI/LevelsBlocks/9");
                    break;
                case 10: level = content.Load<Texture2D>("GUI/LevelsBlocks/10");
                    break;
            }
            spriteBatch.Draw(level, new Vector2(650, 650));
        }