示例#1
0
        public void Draw(SpriteBatch batch)
        {
            batch.Draw(background, new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height), Color.White);
            levels[currentLevel].Draw(batch);
            goal.Draw(batch, Color.White);
            player.Draw(batch, Color.White);
            foreach (Enemy e in enemies)
            {
                e.Draw(batch, Color.White);
            }

            switch (selectedType)
            {
            case BlockType.Basic:
                inkFill.Draw(batch, Color.Black);
                inkContainer.Draw(batch, Color.White);
                break;

            case BlockType.Speed:
                inkFill.Draw(batch, Color.Blue);
                inkContainer.Draw(batch, Color.White);
                break;

            case BlockType.Bouncy:
                inkFill.Draw(batch, Color.Red);
                inkContainer.Draw(batch, Color.White);
                break;

            default:
                inkFill.Draw(batch, Color.Black);
                inkContainer.Draw(batch, Color.White);
                break;
            }

            foreach (Bullet b in bullets)
            {
                b.Draw(batch, b.Team == Teams.Player ? Color.Black : Color.Red);
            }

            foreach (Enemy e in enemies)
            {
                e.Draw(batch, Color.White);
            }

            if (customBlocks.Count > 0)
            {
                //draws each of the player-drawn blocks
                for (int i = 0; i < customBlocks.Count - 1; i++)
                {
                    switch (customBlocks[i].Type)
                    {
                    case BlockType.Basic:
                        customBlocks[i].Draw(batch, Color.Black);
                        break;

                    case BlockType.Speed:
                        customBlocks[i].Draw(batch, Color.Blue);
                        break;

                    case BlockType.Bouncy:
                        customBlocks[i].Draw(batch, Color.Red);
                        break;
                    }
                }

                //Fixes the values of the one the player is currently drawing so it draws correctly
                Block fixedBox = new Block(new Rectangle(customBlocks[customBlocks.Count - 1].X, customBlocks[customBlocks.Count - 1].Y,
                                                         customBlocks[customBlocks.Count - 1].Width, customBlocks[customBlocks.Count - 1].Height),
                                           blockTexture, customBlocks[customBlocks.Count - 1].Type);
                if (Mouse.GetState().LeftButton == ButtonState.Pressed && !invalidDrawCheck)
                {
                    if (fixedBox.Height < 0)
                    {
                        fixedBox.Y      += fixedBox.Height;
                        fixedBox.Height *= -1;
                    }
                    if (fixedBox.Width < 0)
                    {
                        fixedBox.X     += fixedBox.Width;
                        fixedBox.Width *= -1;
                    }
                    switch (fixedBox.Type)
                    {
                    case BlockType.Basic:
                        fixedBox.Draw(batch, player.InkLevels >= customBlocks[customBlocks.Count - 1].GetInkCost() ? Color.Black : new Color(0, 0, 0, 63));
                        break;

                    case BlockType.Speed:
                        fixedBox.Draw(batch, player.InkLevels >= customBlocks[customBlocks.Count - 1].GetInkCost() ? Color.Blue : new Color(0, 0, 255, 63));
                        break;

                    case BlockType.Bouncy:
                        fixedBox.Draw(batch, player.InkLevels >= customBlocks[customBlocks.Count - 1].GetInkCost() ? Color.Red : new Color(255, 0, 0, 63));
                        break;
                    }
                }
                else
                {
                    switch (fixedBox.Type)
                    {
                    case BlockType.Basic:
                        fixedBox.Draw(batch, Color.Black);
                        break;

                    case BlockType.Speed:
                        fixedBox.Draw(batch, Color.Blue);
                        break;

                    case BlockType.Bouncy:
                        fixedBox.Draw(batch, Color.Red);
                        break;
                    }
                }
            }
        }
示例#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.CornflowerBlue);

            spriteBatch.Begin();
            switch (currentGameState)
            {
            case GameStates.MainMenu:
                mainMenuBackground.Draw(spriteBatch, Color.White);
                // Writes the title
                //spriteBatch.DrawString(
                //fontArial,
                //"Inkorporated",
                //new Vector2((GraphicsDevice.Viewport.Width / 2) - (fontArial.MeasureString("Inkorporated").X / 2), GraphicsDevice.Viewport.Height / 4),
                //Color.White);

                //Draws buttons
                play.Draw(spriteBatch, Color.Black, Color.White, fontArial);
                options.Draw(spriteBatch, Color.Black, Color.White, fontArial);

                break;

            case GameStates.Options:
                // ***Controls***
                spriteBatch.DrawString(fontArial, "Controls:", new Vector2(20, 20), Color.White);

                spriteBatch.DrawString(fontArial, "A - Move left", new Vector2(20, 80), Color.White);

                spriteBatch.DrawString(fontArial, "D - Move right", new Vector2(20, 115), Color.White);

                spriteBatch.DrawString(fontArial, "W - Jump", new Vector2(20, 150), Color.White);

                spriteBatch.DrawString(fontArial, "Space - Shoot", new Vector2(20, 185), Color.White);

                spriteBatch.DrawString(fontArial, "1/2/3 - Change ink color (black/blue/red)", new Vector2(20, 220), Color.White);

                spriteBatch.DrawString(fontArial, "Q/E - Cycle between ink colors", new Vector2(20, 255), Color.White);

                backToTitle.Draw(spriteBatch, Color.Black, Color.White, fontArial);
                break;

            case GameStates.LevelSelect:
                levelSelectBackground.Draw(spriteBatch, Color.Black);
                foreach (Tuple <Button <int>, bool> b in levelButtons)
                {
                    b.Item1.Draw(spriteBatch, b.Item2 ? Color.Gray : Color.Red, Color.Black, fontArial);
                }
                break;

            case GameStates.Game:
                controller.Draw(spriteBatch);
                // Writes the current ink level
                spriteBatch.DrawString(fontArial,
                                       "Ink Level: " + controller.LevelPlayer.InkLevels,
                                       new Vector2(10, 10),
                                       Color.Black);
                break;

            case GameStates.PauseMenu:
                GraphicsDevice.Clear(Color.MediumPurple);

                // Writes 'Paused'
                spriteBatch.DrawString(
                    fontArial,
                    "Paused",
                    new Vector2((GraphicsDevice.Viewport.Width / 2) - (fontArial.MeasureString("Paused").X / 2), GraphicsDevice.Viewport.Height / 4),
                    Color.White);

                // Draws "unpause" button
                unpause.Draw(spriteBatch, Color.Black, Color.White, fontArial);

                //Draws "Back to Title" button
                backToTitle.Draw(spriteBatch, Color.Black, Color.White, fontArial);

                /* Writes the instructions
                 * spriteBatch.DrawString(
                 * fontArial,
                 * "Hit 'Esc' to Return to Game.",
                 * new Vector2((GraphicsDevice.Viewport.Width / 2) - (fontArial.MeasureString("Hit 'Esc' to Return to Game").X / 2), (GraphicsDevice.Viewport.Height / 4) + 50),
                 * Color.White); */
                break;

            case GameStates.GameOver:
                GraphicsDevice.Clear(Color.Black);

                // Writes GameOver
                gameOver.Draw(spriteBatch, Color.White);

                // Writes the instructions
                spriteBatch.DrawString(
                    fontArial,
                    "Hit 'Enter' to Return to Try Again.",
                    new Vector2((GraphicsDevice.Viewport.Width / 2) - (fontArial.MeasureString("Hit 'Enter' to Return to Try Again.").X / 2), (GraphicsDevice.Viewport.Height / 2)),
                    Color.White);
                break;

            case GameStates.GameWon:
                GraphicsDevice.Clear(Color.Gold);

                // Writes GameWon
                gameWon.Draw(spriteBatch, Color.White);

                backToTitle.Draw(spriteBatch, Color.Black, Color.White, fontArial);
                break;
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }