Example #1
0
        void Init(bool createGround)
        {
            Chunks = new Chunk[X_CHUNKS, Y_CHUNKS, Z_CHUNKS];

            for (int x = 0; x < X_CHUNKS; x++)
            {
                for (int y = 0; y < Y_CHUNKS; y++)
                {
                    for (int z = 0; z < Z_CHUNKS; z++)
                    {
                        Chunks[x, y, z] = new Chunk(this, x, y, z, createGround);
                    }
                }
            }

            X_SIZE = X_CHUNKS * Chunk.X_SIZE;
            Y_SIZE = Y_CHUNKS * Chunk.Y_SIZE;
            Z_SIZE = Z_CHUNKS * Chunk.Z_SIZE;
        }
Example #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);
        }
Example #3
0
        void AddToUpdateQueue(Chunk c)
        {
            c.Updated = true;

            foreach (Chunk cc in updateQueue) if (cc == c) return;

            updateQueue.Enqueue(c);
        }