예제 #1
0
        public void Draw(SpriteBatch batch)
        {
            batch.GraphicsDevice.SetRenderTarget(renderTarget);

            batch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.GetTransform());

            background.Draw(batch, camera);

            batch.End();


            batch.GraphicsDevice.SetRenderTarget(null);

            batch.Begin(SpriteSortMode.Deferred, null, null, null, null, effect, null);

            batch.Draw(renderTarget, Vector2.Zero, Color.White);

            batch.End();

            batch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.GetTransform());
            map.Draw(batch);
            BulletsEverywhere.Draw(batch);
            enemyHandler.Draw(batch);
            character.Draw(batch);
            batch.End();
        }
예제 #2
0
 public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
 {
     foreach (var tile in _tiles)
     {
         tile.Draw(deltaTime, graphics, spriteBatch);
     }
     _enemyHandler.Draw(deltaTime, graphics, spriteBatch);
 }
예제 #3
0
파일: Game.cs 프로젝트: robodylan/LD-29
        public void Draw()
        {
            Vector2 old = new Vector2();

            for (int i = 0; i <= 360; i += 12)
            {
                Vector2 r = RayCast(50, i * 0.0174532925f + rota);
                if (old.X == 0 && old.Y == 0)
                {
                    old = r;
                    continue;
                }
                raycpoint.Position = to2f(r);
                Vector2f off = new Vector2f(32, 0);
                line[0].Position = new Vector2f(character.Body.Position.X * 128 * Global.Scale, (character.Body.Position.Y) * 128 * Global.Scale) + Global.Offset - off;
                line[1].Position = Offset(to2f(r)) - off;
                line[0].Color    = new Color(0, 0, 200);
                line[1].Color    = new Color(0, 0, 0);
                post.Draw(line, PrimitiveType.Lines);
                line[0].Color    = Color.White;
                line[1].Color    = Color.White;
                line[2].Color    = Color.Black;
                line[2].Position = Offset(to2f(old)) - off;
                glowMap.Draw(line, PrimitiveType.Triangles);
                old = r;
            }

            testlevel.Draw(post);

            if (grappled)
            {
                line[0].Position = new Vector2f(character.Body.Position.X * 128 * Global.Scale, (character.Body.Position.Y) * 128 * Global.Scale) + Global.Offset - new Vector2f(32, 0);
                line[1].Position = Offset(to2f(grapBody.Position)) - new Vector2f(32, 0);
                line[0].Color    = new Color(255, 255, 255);
                line[1].Color    = new Color(100, 100, 100);
                post.Draw(line, PrimitiveType.Lines);
            }

            enemies.Draw(post);

            //Main Character;
            Char.Position = new Vector2f(Player.CameraX + window.Size.X / 2 - 64, Player.CameraY + window.Size.Y / 2 - 32);
            post.Draw(Char);
            bullets.Draw(post);
            glowDisplay.Texture = glowMap.Texture;
            glowMap2.Draw(glowDisplay, blurShaderHorizontal);
            glowDisplay.Texture = glowMap2.Texture;
            glowMap.Draw(glowDisplay, blurShaderVertical);
            glowDisplay.Texture = glowMap.Texture;
            finalShader.Shader.SetParameter("glow", glowDisplay.Texture);
            finalShader.Shader.SetParameter("texture", post.Texture);
            window.Draw(glowDisplay, finalShader);
            //Upadate Time
            T                 = new Text("Time Left: 0", defaultFont, 50);
            T.Color           = new Color(255, 255, 255);
            T.Position        = new Vector2f(10, 200);
            TimeLeft         -= 10;
            T.DisplayedString = "Time Left: " + (TimeLeft / 100).ToString();
            //Update Score
            S                 = new Text("Score: 0", defaultFont, 50);
            S.Color           = new Color(255, 255, 255);
            S.Position        = new Vector2f(10, 100);
            Score             = Global.Coins + Global.Rubies;
            S.DisplayedString = "Score: " + Score.ToString();
            //
            //Draw To GUI
            window.Draw(T);
            window.Draw(S);
        }
예제 #4
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);
        }