Esempio n. 1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            if (generatedPercent < 100)
            {
                spriteBatch.Begin();
                for (int x = 0; x < 4; x++)
                {
                    for (int y = 0; y < 3; y++)
                    {
                        spriteBatch.Draw(texTitleBG, -titleScrollPos + (new Vector2(x * texTitleBG.Width, y * texTitleBG.Height)), null, Color.White);
                    }
                }
                spriteBatch.End();

                GraphicsDevice.DepthStencilState = DepthStencilState.Default;
                GraphicsDevice.SamplerStates[0]  = SamplerState.PointClamp;
                GraphicsDevice.BlendState        = BlendState.AlphaBlend;

                drawEffect.World      = Matrix.CreateRotationY(MathHelper.PiOver4) * Matrix.CreateRotationX(MathHelper.PiOver4);
                drawEffect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 0.1f, 200f);
                drawEffect.View       = Matrix.CreateLookAt(new Vector3(0, 0, -20f), Vector3.Zero, Vector3.Down);

                foreach (EffectPass pass in drawEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();

                    AnimChunk c = gameHero.spriteSheet.AnimChunks[titleCurrentFrame];
                    GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalColor>(PrimitiveType.TriangleList, c.VertexArray, 0, c.VertexArray.Length, c.IndexArray, 0, c.VertexArray.Length / 2);
                    c = gameHero.spriteSheet.AnimChunks[titleCurrentFrame + 4];
                    GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalColor>(PrimitiveType.TriangleList, c.VertexArray, 0, c.VertexArray.Length, c.IndexArray, 0, c.VertexArray.Length / 2);
                }

                spriteBatch.Begin();
                spriteBatch.Draw(texTitle, new Vector2(0, 1), new Rectangle(0, 0, 1280, 20), Color.White);
                spriteBatch.Draw(texTitle, new Vector2(0, 1), new Rectangle(0, 20, (1280 / 100) * generatedPercent, 20), Color.White);
                spriteBatch.Draw(texTitle, new Vector2(300, (GraphicsDevice.Viewport.Height / 2)), new Rectangle(0, 40, 434, 380), Color.White, 0f, new Vector2(434, 380) / 2, 1f, SpriteEffects.None, 1);
                spriteBatch.Draw(texTitle, new Vector2(GraphicsDevice.Viewport.Width - 300, (GraphicsDevice.Viewport.Height / 2)), new Rectangle(433, 40, 393, 552), Color.White, 0f, new Vector2(393, 552) / 2, 1f, SpriteEffects.None, 1);

                //spriteBatch.DrawString(font, "generating: " + generatedPercent, new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height) / 2, Color.DarkGray, 0f, font.MeasureString("generating: " + generatedPercent) / 2, 1f, SpriteEffects.None, 1);
                spriteBatch.End();

                base.Draw(gameTime);
                return;
            }

            GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            GraphicsDevice.SamplerStates[0]  = SamplerState.PointClamp;
            GraphicsDevice.BlendState        = BlendState.AlphaBlend;

            foreach (EffectPass pass in drawEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                for (int y = 0; y < currentRoom.World.Y_CHUNKS; y++)
                {
                    for (int x = 0; x < currentRoom.World.X_CHUNKS; x++)
                    {
                        Chunk c = currentRoom.World.Chunks[x, y, 0];
                        if (!c.Visible)
                        {
                            continue;
                        }

                        if (c == null || c.VertexArray.Length == 0)
                        {
                            continue;
                        }
                        if (!gameCamera.boundingFrustum.Intersects(c.boundingSphere))
                        {
                            continue;
                        }
                        GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalColor>(PrimitiveType.TriangleList, c.VertexArray, 0, c.VertexArray.Length, c.IndexArray, 0, c.VertexArray.Length / 2);
                    }
                }
            }

            currentRoom.Draw(GraphicsDevice, gameCamera, drawEffect);

            foreach (Door d in Doors)
            {
                d.Draw(GraphicsDevice, gameCamera, drawEffect);
            }
            enemyController.Draw(gameCamera, currentRoom);
            projectileController.Draw(gameCamera, currentRoom);
            pickupController.Draw(gameCamera, currentRoom);
            bombController.Draw(gameCamera, currentRoom);

            gameHero.Draw(GraphicsDevice, gameCamera);

            particleController.Draw();

            spriteBatch.Begin();
            //for (int x = 0; x < 4; x++)
            //    for (int y = 0; y < 4; y++)
            //    {
            //        if (!Rooms[x, y].IsGap) spriteBatch.Draw(roomIcon, new Vector2(5+(x*25), 5+(y*25)), null, (gameHero.RoomX==x && gameHero.RoomY==y)?Color.Magenta:Color.Gray);
            //    }
            spriteBatch.DrawString(timerFontLarge, ((int)(doorCountdown / 1000)).ToString("00"), new Vector2(GraphicsDevice.Viewport.Width - 110, 5), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1);
            double ms = doorCountdown - ((int)(doorCountdown / 1000) * 1000);

            spriteBatch.DrawString(timerFontSmall, MathHelper.Clamp(((float)ms / 10f), 0f, 99f).ToString("00"), new Vector2(GraphicsDevice.Viewport.Width - 35, 45), Color.Gray);
            spriteBatch.Draw(texHud, new Vector2(0, GraphicsDevice.Viewport.Height - texHud.Height), Color.White);
            //323,9 500,50
            //1139,9 30,50 15
            spriteBatch.Draw(texHud, new Vector2(0, GraphicsDevice.Viewport.Height - texHud.Height) + new Vector2(323, 9), new Rectangle(323, 9, (int)((500f / gameHero.MaxHealth) * gameHero.Health), 50), Color.Red);
            for (int i = 0; i < gameHero.numBombs; i++)
            {
                spriteBatch.Draw(texHud, new Vector2(0, GraphicsDevice.Viewport.Height - texHud.Height) + new Vector2(1139, 9) + new Vector2(i * 45, 0), new Rectangle(1139, 9, 30, 50), Color.Red);
            }

            if (showCompleteAlpha > 0f)
            {
                if (allRoomsComplete && !gameHero.exitReached)
                {
                    spriteBatch.Draw(texStingers, new Vector2(GraphicsDevice.Viewport.Width / 2, 200), new Rectangle(0, 0, 413, 362), Color.White * showCompleteAlpha, 0f, new Vector2(413, 362) / 2, 1f, SpriteEffects.None, 1);
                }
                else if (allRoomsComplete && gameHero.exitReached)
                {
                    spriteBatch.Draw(texStingers, new Vector2(GraphicsDevice.Viewport.Width / 2, 200), new Rectangle(413, 0, 413, 362), Color.White * showCompleteAlpha, 0f, new Vector2(413, 362) / 2, 1f, SpriteEffects.None, 1);
                }
                else if (gameHero.Dead)
                {
                    spriteBatch.Draw(texStingers, new Vector2(GraphicsDevice.Viewport.Width / 2, 200), new Rectangle(413 * 2, 0, 413, 362), Color.White * showCompleteAlpha, 0f, new Vector2(413, 362) / 2, 1f, SpriteEffects.None, 1);
                }
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
Esempio n. 2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            if (generatedPercent < 100)
            {
                spriteBatch.Begin();
                spriteBatch.DrawString(font, "generating: " + generatedPercent, new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height) / 2, Color.DarkGray, 0f, font.MeasureString("generating: " + generatedPercent) / 2, 1f, SpriteEffects.None, 1);
                spriteBatch.End();

                base.Draw(gameTime);
                return;
            }

            GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            GraphicsDevice.SamplerStates[0]  = SamplerState.PointClamp;
            GraphicsDevice.BlendState        = BlendState.AlphaBlend;

            foreach (EffectPass pass in drawEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                for (int y = 0; y < currentRoom.World.Y_CHUNKS; y++)
                {
                    for (int x = 0; x < currentRoom.World.X_CHUNKS; x++)
                    {
                        Chunk c = currentRoom.World.Chunks[x, y, 0];
                        if (!c.Visible)
                        {
                            continue;
                        }

                        if (c == null || c.VertexArray.Length == 0)
                        {
                            continue;
                        }
                        if (!gameCamera.boundingFrustum.Intersects(c.boundingSphere))
                        {
                            continue;
                        }
                        GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalColor>(PrimitiveType.TriangleList, c.VertexArray, 0, c.VertexArray.Length, c.IndexArray, 0, c.VertexArray.Length / 2);
                    }
                }
            }

            currentRoom.Draw(GraphicsDevice, gameCamera, drawEffect);

            foreach (Door d in Doors)
            {
                d.Draw(GraphicsDevice, gameCamera, drawEffect);
            }
            enemyController.Draw(gameCamera, currentRoom);
            projectileController.Draw(gameCamera, currentRoom);
            bombController.Draw(gameCamera, currentRoom);

            gameHero.Draw(GraphicsDevice, gameCamera);

            particleController.Draw();

            spriteBatch.Begin();
            for (int x = 0; x < 4; x++)
            {
                for (int y = 0; y < 4; y++)
                {
                    if (!Rooms[x, y].IsGap)
                    {
                        spriteBatch.Draw(roomIcon, new Vector2(5 + (x * 25), 5 + (y * 25)), null, (gameHero.RoomX == x && gameHero.RoomY == y)?Color.Magenta:Color.Gray);
                    }
                }
            }
            spriteBatch.DrawString(font, ((int)(doorCountdown / 1000)).ToString("00"), new Vector2(GraphicsDevice.Viewport.Width - 100, 5), Color.White, 0f, Vector2.Zero, 3f, SpriteEffects.None, 1);
            double ms = doorCountdown - ((int)(doorCountdown / 1000) * 1000);

            spriteBatch.DrawString(font, (ms / 10).ToString("00"), new Vector2(GraphicsDevice.Viewport.Width - 35, 40), Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }