Exemple #1
0
        private void DrawHud(SpriteBatch sb)
        {
            sb.Begin(samplerState: SamplerState.PointClamp);
            sb.Draw(blackRect, new Rectangle(0, Game1.height - 35, Game1.width, 35), Color.Black);
            sb.Draw(blackRect, new Rectangle(0, 0, Game1.width, 32), Color.Black);
            travis.Draw(sb);
            if (curPhase == Phase.PlayerPhase)
            {
                if (waiter == null)
                {
                    commandName.Draw(sb);
                    //Draw spell icons
                    options.Draw(sb, options.GetIndex());
                }
            }

            if (combatTimer > secondsPerBeat - threshHold)            // && combatTimer < 0.6)
            {
                if (combatTimer > secondsPerBeat + threshHold)
                {
                    combatTimer = threshHold;
                }
            }
            sb.End();

            if (options.IndexChanged())
            {
                commandName = new Hud(new string[] { options.GetSelectedName() }, content, 6, 0, Game1.width / 3 - 50, 2, canClose: false, centered: true);
            }
        }
Exemple #2
0
        void MiniScreen.Draw(SpriteBatch sb)
        {
            if (effect.IsDisposed)
            {
                return;
            }

            DrawBackground(sb);
            DrawHud(sb);

            sb.Begin(samplerState: SamplerState.PointClamp);

            if (enemyDraw)
            {
                enemy.Draw(sb, bgTimer, flashColor, offsetHeightTop, offsetHeightBottom);
            }

            sb.End();
            sb.Begin(samplerState: SamplerState.PointWrap);

            if (!victory || turnWaiter > 0.4)
            {
                text.Draw(sb);
            }

            if (victory && turnWaiter > 0.4)
            {
                sb.Draw(youWon, new Rectangle((Game1.width - 102) / 2, 18, 102, 10), new Rectangle(0, 0, 102, 10), victoryColor);
            }

            if (curPhase == Phase.AnimPhase && !text.visible)
            {
                int frame = magicAnim.getFrame();
                sb.Draw(magic, new Rectangle(0, 0, Game1.width, Game1.height), new Rectangle((frame % 4) * Game1.width, (frame / 4) * Game1.height, Game1.width, Game1.height), magicColor);
            }
            sb.End();
        }
Exemple #3
0
        void MiniScreen.Draw(SpriteBatch pSb)
        {
            mapRenderer.Draw(tMap.GetLayer("Ground"), camera.GetViewMatrix());
            pSb.Begin(transformMatrix: camera.GetViewMatrix(), samplerState: SamplerState.PointClamp);//SpriteSortMode.Immediate required for pixel shader

            //pSb.Begin();
            //pSb.Draw(debug, new Rectangle(0, 0, debug.Width, debug.Height), Color.White);
            //mapRenderer.Draw(tMap, camera.GetViewMatrix());
            foreach(MapEntity entity in entityList)
            {
                entity.Draw(pSb);
            }
            /*
            foreach (NPC n in npcs)
                n.Draw(pSb);
            player.Draw(pSb);
            */
            //g.SamplerStates[0] = SamplerState.PointClamp;

            Vector2 tilePos = Vector2.Zero;

            //DrawDebug(pSb);
            pSb.End();
            mapRenderer.Draw(tMap.GetLayer("Hills"), camera.GetViewMatrix());
            pSb.Begin(samplerState: SamplerState.PointClamp);// effect: effect);
            //effect.CurrentTechnique.Passes[1].Apply();
            if (speaking)
                hud.Draw(pSb);

            //menu.Draw(pSb);
            pSb.End();

            Matrix proj = Matrix.CreateOrthographicOffCenter(0f, Game1.width, Game1.height, 0f, 0f, 1f);
            Matrix view = camera.GetViewMatrix();
            //debugView.RenderDebugData(ref proj, ref view);
        }
Exemple #4
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();
            }
        }