Esempio n. 1
0
        public override void Draw(GameTime gameTime)
        {
            int width  = Game.GraphicsDevice.PresentationParameters.BackBufferWidth;
            int height = Game.GraphicsDevice.PresentationParameters.BackBufferHeight;

            GraphicsDevice.Clear(Color.Black);
            scenery.Draw(gameTime);
            player.Draw(gameTime);
            castleHandler.Draw(gameTime);
            spellHandler.Draw(gameTime);
            enemyHandler.Draw(gameTime);

            spriteBatch.Begin();


            slowEnemyParticles.Draw(gameTime);
            poisonEnemyParticles.Draw(gameTime);
            fireBallParticles.Draw(gameTime);
            magicMissilePartilces.Draw(gameTime);
            dirtPartilces.Draw(gameTime);


            spriteBatch.Draw(userInterfaceBack, new Rectangle(0, 0, width, height), Color.White);
            // Draw healthbar
            float healthLeft = ((float)player.Health / (float)player.MaxHealth) * ((float)width * 0.16f);

            spriteBatch.Draw(blankTexture, new Rectangle(Convert.ToInt32(width * 0.047f), Convert.ToInt32(height * 0.07f), (int)healthLeft, Convert.ToInt32(height * 0.0222f)), Color.Red);

            float manaLeft = ((float)player.Mana / (float)player.MaxMana) * ((float)width * 0.16f);

            spriteBatch.Draw(blankTexture, new Rectangle(Convert.ToInt32(width * 0.050f), Convert.ToInt32(height * 0.11f), (int)manaLeft, Convert.ToInt32(height * 0.0222f)), Color.Blue);

            float castleHealth = ((1.0f - ((float)player.Xp / (float)player.XpToNextLevel))) * ((float)height * 0.06f);

            spriteBatch.Draw(blankTexture, new Rectangle(Convert.ToInt32(width * 0.232f), Convert.ToInt32(height * 0.07f), Convert.ToInt32(height * 0.02f), (int)castleHealth), new Color(95, 68, 40, 255));

            spriteBatch.Draw(userInterface, new Rectangle(0, 0, width, height), Color.White);

            spriteBatch.DrawString(m_fontLarge, "" + (castleHandler.Castle.Upgrade) + "/6", new Vector2(Convert.ToInt32(width * 0.142f), Convert.ToInt32(height * 0.185)), Color.Black);
            spriteBatch.DrawString(m_fontLarge, "" + (castleHandler.Castle.Upgrade) + "/6", new Vector2(Convert.ToInt32(width * 0.14f), Convert.ToInt32(height * 0.18)), Color.White);

            spriteBatch.DrawString(m_fontLarge, "" + (player.Level), new Vector2(Convert.ToInt32(width * 0.245f), Convert.ToInt32(height * 0.07)), Color.Black);
            spriteBatch.DrawString(m_fontLarge, "" + (player.Level), new Vector2(Convert.ToInt32(width * 0.247f), Convert.ToInt32(height * 0.065)), Color.White);

            spriteBatch.DrawString(m_font, "" + (castleHandler.Castle.Level), new Vector2(Convert.ToInt32(width * 0.835f), Convert.ToInt32(height * 0.06)), Color.Black);
            spriteBatch.DrawString(m_font, "" + (castleHandler.Castle.Level), new Vector2(Convert.ToInt32(width * 0.837f), Convert.ToInt32(height * 0.055)), Color.White);

            //spriteBatch.DrawString(m_font, "" + (m_Castle.TheCastle.Wave), new Vector2(Convert.ToInt32(width * 0.835f), Convert.ToInt32(height * 0.1)), Color.Black);
            //spriteBatch.DrawString(m_font, "" + (m_Castle.TheCastle.Wave), new Vector2(Convert.ToInt32(width * 0.837f), Convert.ToInt32(height * 0.095)), Color.White);

            spriteBatch.DrawString(m_fontLarge, "" + (castleHandler.Castle.EnemiesInCurrentWave + enemyHandler.EnemiesList.Count), new Vector2(Convert.ToInt32(width * 0.855f), Convert.ToInt32(height * 0.195)), Color.Black);
            spriteBatch.DrawString(m_fontLarge, "" + (castleHandler.Castle.EnemiesInCurrentWave + enemyHandler.EnemiesList.Count), new Vector2(Convert.ToInt32(width * 0.857f), Convert.ToInt32(height * 0.190)), Color.White);

            spriteBatch.DrawString(m_fontLarge, "" + (player.ManaPotions), new Vector2(Convert.ToInt32(width * 0.875f), Convert.ToInt32(height * 0.86)), Color.Black);
            spriteBatch.DrawString(m_fontLarge, "" + (player.ManaPotions), new Vector2(Convert.ToInt32(width * 0.877f), Convert.ToInt32(height * 0.855)), Color.White);

            spriteBatch.DrawString(m_fontLarge, "" + (player.HealthPotions), new Vector2(Convert.ToInt32(width * 0.095f), Convert.ToInt32(height * 0.86)), Color.Black);
            spriteBatch.DrawString(m_fontLarge, "" + (player.HealthPotions), new Vector2(Convert.ToInt32(width * 0.097f), Convert.ToInt32(height * 0.855)), Color.White);


            switch (spellHandler.SelectedSpell)
            {
            case SpellHandler.Spells.Fireball:
            {
                spriteBatch.Draw(spellIcons[0], new Rectangle(Convert.ToInt32(width * 0.050f), Convert.ToInt32(height * 0.18f), Convert.ToInt32(width * 0.025f * 1.5f), Convert.ToInt32(height * 0.0444f * 1.5f)), Color.White);
                break;
            }

            case SpellHandler.Spells.Slowball:
            {
                spriteBatch.Draw(spellIcons[1], new Rectangle(Convert.ToInt32(width * 0.050f), Convert.ToInt32(height * 0.18f), Convert.ToInt32(width * 0.025f * 1.5f), Convert.ToInt32(height * 0.0444f * 1.5f)), Color.White);
                break;
            }

            case SpellHandler.Spells.PoisonBall:
            {
                spriteBatch.Draw(spellIcons[2], new Rectangle(Convert.ToInt32(width * 0.050f), Convert.ToInt32(height * 0.18f), Convert.ToInt32(width * 0.025f * 1.5f), Convert.ToInt32(height * 0.0444f * 1.5f)), Color.White);
                break;
            }

            case SpellHandler.Spells.MagicMissile:
            {
                spriteBatch.Draw(spellIcons[3], new Rectangle(Convert.ToInt32(width * 0.050f), Convert.ToInt32(height * 0.18f), Convert.ToInt32(width * 0.025f * 1.5f), Convert.ToInt32(height * 0.0444f * 1.5f)), Color.White);
                break;
            }

            case SpellHandler.Spells.EnergyBall:
            {
                spriteBatch.Draw(spellIcons[4], new Rectangle(Convert.ToInt32(width * 0.050f), Convert.ToInt32(height * 0.18f), Convert.ToInt32(width * 0.025f * 1.5f), Convert.ToInt32(height * 0.0444f * 1.5f)), Color.White);
                break;
            }

            case SpellHandler.Spells.MagicMissileX2:
            {
                spriteBatch.Draw(spellIcons[5], new Rectangle(Convert.ToInt32(width * 0.050f), Convert.ToInt32(height * 0.18f), Convert.ToInt32(width * 0.025f * 1.5f), Convert.ToInt32(height * 0.0444f * 1.5f)), Color.White);
                break;
            }

            case SpellHandler.Spells.MagicMissileX4:
            {
                spriteBatch.Draw(spellIcons[6], new Rectangle(Convert.ToInt32(width * 0.050f), Convert.ToInt32(height * 0.18f), Convert.ToInt32(width * 0.025f * 1.5f), Convert.ToInt32(height * 0.0444f * 1.5f)), Color.White);
                break;
            }
            }


            if (castleHandler.Castle.EnemiesInCurrentWave <= 0)
            {
                if (enemyHandler.AllEnemiesDead && enemyHandler.WaveFinishedTimer > 0)
                {
                    spriteBatch.Draw(waveCompleted, new Rectangle(0, 0, width, height), new Color(1.0f, 1.0f, 1.0f, 1.0f));
                }
            }

            if (castleHandler.Castle.Level <= 0)
            {
                //spriteBatch.Draw(tutorial, new Rectangle(0, 0, width, height), new Color(1.0f, 1.0f, 1.0f, 0.2f));
            }

            if (player.DisplayLevelUpTimer > 0)
            {
                spriteBatch.Draw(levelUpNotifier, new Rectangle(0, 0, width, height), new Color(1.0f, 1.0f, 1.0f, (player.DisplayLevelUpTimer / 3000.0f)));
            }


            if (isCurrentLevelABoss)
            {
                if (enemyHandler.SpawnEnemyTypes.Count >= 1)
                {
                    if (enemyHandler.EnemiesList.Count >= 1)
                    {
                        spriteBatch.Draw(bossInfo, new Rectangle(0, 0, width, height), new Color(new Vector4(1, 1, 1, 1)));
                        //spriteBatch.DrawString(m_font, "Boss HP " + m_EnemyHandler.EnemiesList[0].Health, new Vector2(900, 80), Color.Black);
                        float bossHealth = ((float)enemyHandler.EnemiesList[0].Health / (float)enemyHandler.EnemiesList[0].MaxHealth) * ((float)width * 0.435f);
                        spriteBatch.Draw(blankTexture, new Rectangle(Convert.ToInt32(width * 0.267f), Convert.ToInt32(height * 0.1055f), (int)bossHealth, Convert.ToInt32(height * 0.0222f)), Color.Green);
                        spriteBatch.DrawString(m_font, "Boss: " + enemyHandler.EnemiesList[0].Name, new Vector2(Convert.ToInt32(width * 0.267f), Convert.ToInt32(height * 0.13f)), Color.Gold);
                    }
                }
            }

            spriteBatch.End();

            GraphicsDevice.BlendState        = BlendState.Opaque;
            GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            GraphicsDevice.RasterizerState   = RasterizerState.CullCounterClockwise;
            GraphicsDevice.SamplerStates[0]  = SamplerState.LinearWrap;

            base.Draw(gameTime);
        }