Пример #1
0
 void MiniScreen.Draw(SpriteBatch sb)
 {
     //Console.WriteLine("Mouse X: " + state.X);
     sb.Begin();
     //Adjust for output buffer
     sb.Draw(background, new Rectangle(0, 0, Game1.width, Game1.height), Color.White);
     sb.Draw(sprite, new Rectangle(0, Game1.height - sprite.Height, sprite.Width, sprite.Height), new Rectangle(0, 0, sprite.Width, sprite.Height), Color.White);
     options.Draw(sb);
     //startButton.Draw(sb);
     if (phase == Phase.Settings)
     {
         backButton.Draw(sb);
     }
     sb.End();
 }
Пример #2
0
        void Screen.Draw(SpriteBatch sb)
        {
            //Render microgame internally

            //Render black background, then render the last frame in the middle, leaving 2 1-pixel borders on the sides
            if (curPhase != Phase.Transition)
            {
                if (microgame is Battle)
                {
                    ((Battle)microgame).ChangeTarget(lastFrame);
                }
                graphicsDevice.SetRenderTarget(lastFrame);
                //microgame.Draw(sb);
                microgame.Draw(sb);
                sb.Begin(blendState: BlendState.Opaque);

                //Top/bottom bars
                sb.Draw(lio, new Rectangle(0, 0, 1, Game1.height), new Rectangle(0, 0, Game1.width, Game1.height), Color.Transparent);
                sb.Draw(lio, new Rectangle(Game1.width + 1, 0, 1, Game1.height), new Rectangle(0, 0, Game1.width, Game1.height), Color.Transparent);

                sb.End();
                graphicsDevice.SetRenderTarget(bufferTarget);
                if (microgame is Battle)
                {
                    ((Battle)microgame).ChangeTarget(bufferTarget);
                }
            }

            switch (curPhase)
            {
            case Phase.Introduction:

                graphicsDevice.SetRenderTarget(bufferTarget);
                microgame.Draw(sb);
                if (!introText.messageComplete())
                {
                    sb.Begin();
                    introText.Draw(sb);
                    sb.End();
                }

                break;

            case Phase.PracticeUnlock:
                graphicsDevice.SetRenderTarget(bufferTarget);
                microgame.Draw(sb);

                sb.Begin();
                introText.Draw(sb);
                sb.End();
                break;

            case Phase.FinalMessage:
                graphicsDevice.SetRenderTarget(bufferTarget);
                microgame.Draw(sb);

                sb.Begin();
                introText.Draw(sb);
                sb.End();
                break;

            case Phase.MainMenu:
                graphicsDevice.SetRenderTarget(bufferTarget);
                microgame.Draw(sb);

                break;

            //Only needed for Battle
            case Phase.InGame:
                graphicsDevice.SetRenderTarget(bufferTarget);
                microgame.Draw(sb);
                sb.Begin();
                int offset = countdownTimer >= 11 ? 7 * 48 : ((int)countdownTimer) * 48;
                sb.Draw(countdown, new Rectangle(2, 2, 48, countdown.Height), new Rectangle(offset, 0, 48, countdown.Height), countdownColor);
                sb.End();
                //microgame.Draw(sb);
                break;

            case Phase.Transition:
                //Battle uses nested render targets
                graphicsDevice.SetRenderTarget(bufferTarget);
                microgame.Draw(sb);

                if (currentFlashes > maxFlashes)
                {
                    sb.Begin();

                    //1.8 is the amount of seconds the preview is active
                    int blackBar = (int)(Math.Pow(2, (timer - 3.3 / timerMult) * 14));

                    //Move from transition into the next game
                    if (blackBar > Game1.height / 2)
                    {
                        //MediaPlayer.Stop();

                        //Reset timer variables for next time
                        currentFlashes = 7;
                        maxFlashes     = 7;
                        timer          = 0.2;

                        if (microgame is TitleScreen)
                        {
                            if (practiceIntro)
                            {
                                curPhase = Phase.PracticeUnlock;
                            }
                            else
                            {
                                curPhase = Phase.MainMenu;
                            }
                        }
                        else if (fromGame)
                        {
                            beginSong = true;
                            fromGame  = false;
                            curPhase  = Phase.BetweenGames;
                        }
                        else
                        {
                            beginSong = true;
                            curPhase  = Phase.InGame;
                        }
                        sb.End();
                        //microgame.Draw(sb);
                        sb.Begin();
                    }

                    sb.End();
                    microgame.Draw(sb);
                    sb.Begin();

                    //Top and bottom bars, don't draw during transition screen
                    if (!(microgame is BetweenGames))
                    {
                        sb.Draw(lio, new Rectangle(0, blackBar + Game1.height / 2, Game1.width, Game1.height / 2), new Rectangle(0, Game1.height / 2, Game1.width, Game1.height / 2), Color.White);
                        sb.Draw(lio, new Rectangle(0, -blackBar, Game1.width, Game1.height / 2), new Rectangle(0, 0, Game1.width, Game1.height / 2), Color.White);
                    }

                    sb.End();

                    sb.Begin(SpriteSortMode.Immediate);
                    graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
                    transition.CurrentTechnique.Passes[0].Apply();
                    //sb.Draw(internalTarget, new Rectangle(0, 0, Game1.width, Game1.height), Color.White);

                    sb.Draw(lastFrame, new Rectangle(0, 0, Game1.width, Game1.height), new Rectangle(1, 0, Game1.width, Game1.height), Color.White);
                    sb.End();
                }
                else
                {
                    sb.Begin(SpriteSortMode.Immediate);
                    int flashCol = (int)(timer * 1700);

                    sb.Draw(lastFrame, new Rectangle(0, 0, Game1.width, Game1.height), new Rectangle(1, 0, Game1.width, Game1.height), new Color(flashCol, flashCol, flashCol));
                    sb.End();

                    if (currentFlashes == maxFlashes)
                    {
                        timer = 0;
                        currentFlashes++;
                    }
                    else
                    {
                        if (flashCol > 255 && (currentFlashes & 1) == 0)
                        {
                            currentFlashes++;
                        }
                        else if (flashCol < 0 && currentFlashes <= maxFlashes && (currentFlashes & 1) == 1)
                        {
                            currentFlashes++;
                        }
                    }
                }
                break;

            case Phase.BetweenGames:
                graphicsDevice.SetRenderTarget(bufferTarget);
                microgame.Draw(sb);
                break;

            case Phase.Paused:
                graphicsDevice.SetRenderTarget(bufferTarget);
                microgame.Draw(sb);
                break;
            }
            graphicsDevice.SetRenderTarget(mainTarget);
            sb.Begin(SpriteSortMode.Immediate);

            if (curPhase == Phase.Introduction || curPhase == Phase.FinalMessage || curPhase == Phase.PracticeUnlock)
            {
                paletteShader.Techniques[3].Passes[0].Apply();
                sb.Draw(bufferTarget, new Rectangle(0, 0, Game1.width, Game1.height), new Rectangle(0, 0, Game1.width, Game1.height), Color.White);
                sb.End();

                sb.Begin(SpriteSortMode.Immediate);
                paletteShader.Techniques[1].Passes[0].Apply();

                sb.End();

                graphicsDevice.SetRenderTarget(bufferTarget);
                graphicsDevice.Clear(Color.Transparent);
                sb.Begin(blendState: BlendState.AlphaBlend);
                //The text is becoming white because the shader overrides it. Need to render the text to a buffer first
                if (introText.messageComplete() || controlHint)
                {
                    exitButton.Draw(sb);
                }

                sb.End();

                graphicsDevice.SetRenderTarget(mainTarget);
                sb.Begin(SpriteSortMode.Immediate);
                paletteShader.Techniques[1].Passes[0].Apply();
                sb.Draw(bufferTarget, new Rectangle(0, 0, Game1.width, Game1.height), new Rectangle(0, 0, Game1.width, Game1.height), Color.White);
                if (introText.messageComplete())
                {
                    sb.Draw(controls, new Rectangle(0, 0, controls.Width, controls.Height), Color.White);
                }
                else if (controlHint)
                {
                    sb.Draw(controls, new Rectangle(0, 0, controls.Width, controls.Height), Color.White);
                    introText.Draw(sb);
                }
                else
                {
                    //sb.Begin();
                    introText.Draw(sb);
                    //sb.End();
                }
                sb.End();
            }
            else if (curPhase != Phase.Paused)
            {
                paletteShader.Techniques[1].Passes[0].Apply();
                sb.Draw(bufferTarget, new Rectangle(0, 0, Game1.width, Game1.height), new Rectangle(0, 0, Game1.width, Game1.height), Color.White);
                sb.End();
            }
            else
            {
                paletteShader.Techniques[3].Passes[0].Apply();
                sb.Draw(bufferTarget, new Rectangle(0, 0, Game1.width, Game1.height), new Rectangle(0, 0, Game1.width, Game1.height), Color.White);
                sb.End();

                sb.Begin(SpriteSortMode.Immediate);
                paletteShader.Techniques[1].Passes[0].Apply();
                if (exitConfirm)
                {
                    sb.Draw(areYouSure, new Rectangle(0, 0, pauseScreen.Width, pauseScreen.Height), Color.White);
                }
                else
                {
                    sb.Draw(pauseScreen, new Rectangle(0, 0, pauseScreen.Width, pauseScreen.Height), Color.White);
                }
                sb.End();

                graphicsDevice.SetRenderTarget(bufferTarget);
                graphicsDevice.Clear(Color.Transparent);
                sb.Begin(blendState: BlendState.AlphaBlend);
                //The text is becoming white because the shader overrides it. Need to render the text to a buffer first
                if (exitConfirm)
                {
                    backButton.Draw(sb);
                    yesButton.Draw(sb);
                    noButton.Draw(sb);
                }
                else
                {
                    pauseMenu.Draw(sb);
                    resumeButton.Draw(sb);
                }
                sb.End();

                graphicsDevice.SetRenderTarget(mainTarget);
                sb.Begin(SpriteSortMode.Immediate);
                paletteShader.Techniques[1].Passes[0].Apply();
                sb.Draw(bufferTarget, new Rectangle(0, 0, Game1.width, Game1.height), new Rectangle(0, 0, Game1.width, Game1.height), Color.White);
                sb.End();
            }
        }