示例#1
0
        public MainScreen(ContentManager contentManager, RenderTarget2D final, GraphicsDevice graphicsDevice, PresentationParameters pp, FileStream fs, Game game)
        {
            beginSong           = false;
            this.game           = game;
            this.contentManager = contentManager;
            this.fs             = fs;
            cm = new ContentManager(contentManager.ServiceProvider);
            cm.RootDirectory = contentManager.RootDirectory;
            this.pp          = pp;
            paletteShader    = contentManager.Load <Effect>("Battle/BattleBG");
            introText        = new Hud(new string[] { "Welcome to Microgames!\nClick the mouse or press the spacebar to continue.", "Because this is your first time, continue to see\nthe controls." }, cm, 30, 2, posY: -1, canClose: true);
            if (fs.ReadByte().Equals('P'))
            {
                curPhase = Phase.MainMenu;
                fs.Close();
                practiceUnlocked = GetSaveElem("Practice") == 1;
                SetColor(GetSaveElem("Palette"));                //Restore palette from save
                introText.finishText();
            }
            else
            {
                paletteShader.Parameters["col_light"].SetValue(new Color(250, 231, 190).ToVector4());
                paletteShader.Parameters["col_extra"].SetValue(new Color(234, 80, 115).ToVector4());
                paletteShader.Parameters["col_med"].SetValue(new Color(113, 68, 123).ToVector4());
                paletteShader.Parameters["col_dark"].SetValue(new Color(176, 108, 57).ToVector4());

                practiceUnlocked = false;
                curPhase         = Phase.Introduction;
            }

            battleSong     = contentManager.Load <Song>("Music/fight");
            previewSong    = contentManager.Load <Song>("Music/trouble_ahead");
            transitionSong = contentManager.Load <Song>("Music/transition");

            fromGame    = false;
            exitConfirm = false;
            //curPhase = Phase.BetweenGames;
            currentFlashes     = 7;
            maxFlashes         = 7;
            timer              = 0.2;
            countdownTimer     = 0.0;
            timerMult          = 1.0;
            betweenGamesOffset = 0.0;
            countdownColor     = Color.White;

            controlsShown  = false;
            controlRevisit = false;
            controlHint    = false;

            this.graphicsDevice = graphicsDevice;
            practiceMode        = false;

            lastFrame    = new RenderTarget2D(graphicsDevice, Game1.width + 2, Game1.height, false, SurfaceFormat.Color, DepthFormat.None, pp.MultiSampleCount, RenderTargetUsage.DiscardContents);
            bufferTarget = new RenderTarget2D(graphicsDevice, Game1.width, Game1.height, false, SurfaceFormat.Color, DepthFormat.None, pp.MultiSampleCount, RenderTargetUsage.DiscardContents);
            mainTarget   = final;

            lio          = contentManager.Load <Texture2D>("Menus/TransitionTest");
            stairClimber = contentManager.Load <Texture2D>("Map/TransitionAnim");
            pauseScreen  = contentManager.Load <Texture2D>("Menus/PauseScreen");
            areYouSure   = contentManager.Load <Texture2D>("Menus/AreYouSure");
            continueIcon = contentManager.Load <Texture2D>("Menus/TransitionButton");
            countdown    = contentManager.Load <Texture2D>("Menus/Countdown");

            if (Environment.OSVersion.Platform.ToString().Contains("Win"))
            {
                controls = contentManager.Load <Texture2D>("Menus/Controls");
            }
            else
            {
                controls = contentManager.Load <Texture2D>("Menus/Controls_Unix");
            }

            transition = contentManager.Load <Effect>("Map/transitions");
            transition.Parameters["time"].SetValue((float)timer);

            continues = 3;
            score     = 0;

            prevStateKb = Keyboard.GetState();
            prevStateM  = Mouse.GetState();

            lastGame      = -1;
            timesRepeated = 0;

            practiceIntro = false;

            microgame = new TitleScreen(cm, paletteShader, practiceUnlocked);

            random = new Random();

            exitButton   = new Button(contentManager, 4, 1, text: "OK");
            pauseButton  = new Button(contentManager, 4, 1, text: "Pause");
            resumeButton = new Button(contentManager, 4, 1, text: "Resume");

            noButton   = new Button(contentManager, Game1.width / 2 - 60, Game1.height / 2 + 20, text: "No");
            yesButton  = new Button(contentManager, Game1.width / 2 + 20, Game1.height / 2 + 20, text: "Yes");
            backButton = new Button(contentManager, 4, 1, text: "Back");

            pauseMenu = new Menu(contentManager, new string[] { "Palette", "Return to Title", "P1", null, "P2", null, "P3", null, "P4", null, "P5", null }, 2, 69, offsetX: Game1.width / 4, offsetY: Game1.height / 2, defaultSpacingX: 75);
        }
示例#2
0
        private void advanceBattle(GameTime gameTime, KeyboardState prevStateKb, MouseState prevStateM)
        {
            //Console.WriteLine("Calling advance!");
            switch (curPhase)
            {
            case Phase.IntroPhase:
                if (text.messageComplete())
                {
                    curPhase = Phase.PlayerPhase;
                }
                break;

            case Phase.PlayerPhase:
                if (waiter == null)
                {
                    options.Update(prevStateKb, prevStateM);
                    //selector.Update(prevState);
                }


                if ((Keyboard.GetState().IsKeyDown(Keys.Space) && prevStateKb.IsKeyUp(Keys.Space)) ||
                    (prevStateM.LeftButton == ButtonState.Pressed && Mouse.GetState().LeftButton == ButtonState.Released))
                {
                    switch (options.GetMagic())
                    {
                    //Earth
                    case "Earth":
                        //playerMove = 0;
                        playerMove = 1;
                        magic      = content.Load <Texture2D>("Battle/Effects/PkFireA_GRN");
                        toReturn   = 254;
                        magicColor = Color.Purple;

                        curPhase = Phase.EnemyPhase;
                        break;

                    //Fire
                    case "Fire":
                        playerMove = 1;
                        magic      = content.Load <Texture2D>("Battle/Effects/PkFireA_GRN");
                        toReturn   = 254;
                        magicColor = Color.White;

                        curPhase = Phase.EnemyPhase;
                        break;

                    //Water
                    case "Water":
                        playerMove = 1;
                        magic      = content.Load <Texture2D>("Battle/Effects/PkFireA_GRN");
                        toReturn   = 254;
                        magicColor = Color.LightGray;

                        curPhase = Phase.EnemyPhase;
                        break;
                    }
                }
                break;

            case Phase.EnemyPhase:
                enemyMove = 0;
                curPhase  = Phase.AttackPhase;
                break;

            case Phase.AttackPhase:
                if (enemy.health <= 0)
                {
                    if (enemyType == 0 && magicColor.Equals(Color.White) || enemyType == 1 && magicColor.Equals(Color.Purple) || enemyType == 2 && magicColor.Equals(Color.LightGray))
                    {
                        deathMessageDisplayed = false;
                        curPhase = Phase.EnemyDeathPhase;
                        flasher  = enemy;
                        enemy.ChangeToWhite();
                        flashTimer   = -0.5;
                        flashCounter = 1;
                        timerMult    = 0.5f;
                    }
                    else
                    {
                        toReturn = 2;
                    }
                    //text = new Hud(new string[] { "@The enemy dissipates into hollow armor." }, content, 30, 2, posY: 3, canClose: true);
                }
                else
                if (playerMove != -1)
                {
                    if (playerMove == 0)
                    {
                        enemy.attacked = false;
                        //text = new Hud(new string[] { "@Travis's attack!" }, content, 30, 2, posY: 3, canClose: true);
                        //enemy.TakeDamage(1, combatTimer);
                        waiter = enemy;
                        //playerMove = -1;
                    }
                    else if (playerMove == 1)
                    {
                        //text = new Hud(new string[] { "@Travis tried PK Fire [!" }, content, 30, 2, posY: 3, canClose: true);
                        //text.finishText();
                        Console.WriteLine("GetFrame: " + magicAnim.getFrame());
                        magicAnim.resetStart();
                        darkenTimer = 1;
                        curPhase    = Phase.AnimPhase;
                        //if (magicAnim.getFrame() == 25)
                        //playerMove = -1;
                        //playerMove = -1;
                        //TODO: Something
                        enemy.DecreaseHealth(5);
                    }
                    playerMove = -1;
                }
                else if (enemyMove == 0)
                {
                    flasher    = enemy;
                    flashTimer = 0;

                    travis.attacked = false;
                    text            = new Hud(new string[] { "@enemy's attack!" }, content, 30, 2, posY: 3, canClose: true);
                    //travis.TakeDamage(1, combatTimer);
                    waiter    = travis;
                    enemyMove = -1;
                    timerMult = 1;
                    //flashCounter = 1;
                    //flashTimer = 0;
                }
                else
                {
                    curPhase = Phase.PlayerPhase;
                }
                break;

            case Phase.EnemyDeathPhase:
                //Refer to the if statement in the Update() function

                break;

            case Phase.AnimPhase:
                Console.WriteLine("anim");

                if (magicAnim.getFrame() == magicAnim.frameCount)
                {
                    Console.WriteLine("Skadoosh");
                    if (darkenTimer < 1)
                    {
                        darkenTimer += gameTime.ElapsedGameTime.TotalSeconds * 4;
                    }
                    else                            //end phase
                    {
                        //curPhase = Phase.AttackPhase;
                        //magic.Dispose();
                        curPhase  = Phase.BlinkPhase;
                        enemyDraw = false;
                        magicAnim.resetStart();
                        animTimer = 0;
                    }
                }
                else
                {
                    if (darkenTimer > 0.5)
                    {
                        darkenTimer -= gameTime.ElapsedGameTime.TotalSeconds * 5;
                    }

                    animTimer += gameTime.ElapsedGameTime.TotalSeconds;

                    if (animTimer > 0.05)
                    {
                        animTimer -= 0.05;
                        magicAnim.advanceFrame();
                    }
                }
                break;

            case Phase.BlinkPhase:
                animTimer += gameTime.ElapsedGameTime.TotalSeconds;

                if (animTimer > 0.07)
                {
                    flashCount++;
                    animTimer -= 0.07;
                    if (flashCount < 11)
                    {
                        enemyDraw = !enemyDraw;
                    }
                }

                if (flashCount == 11)
                {
                    //flashCount = 0;
                    enemyDraw = true;
                    //curPhase = Phase.AttackPhase;
                }
                else if (flashCount == 17)
                {
                    flashCount = 0;
                    curPhase   = Phase.AttackPhase;
                }
                break;

            default:
                break;
            }
        }
示例#3
0
        void Screen.Update(GameTime dt)
        {
            if (!prevStateKb.GetPressedKeys().Equals(Keyboard.GetState().GetPressedKeys()))
            {
                game.IsMouseVisible = false;
            }

            MouseState state = Mouse.GetState();

            if (prevStateM.X != state.X || prevStateM.Y != state.Y)
            {
                game.IsMouseVisible = true;
            }

            int mouseX = (int)(state.X * Game1.resMultiplier);
            int mouseY = (int)(state.Y * Game1.resMultiplier);

            pauseButton.Update(mouseX, mouseY);
            if ((curPhase == Phase.Transition || curPhase == Phase.BetweenGames) &&
                ((Keyboard.GetState().IsKeyUp(Keys.Escape) && prevStateKb.IsKeyDown(Keys.Escape)) ||
                 (curPhase != Phase.Paused && pauseButton.IsPressed(prevStateM))))
            {
                prevStateM = state;
                prevPhase  = curPhase;
                MediaPlayer.Pause();
                curPhase = Phase.Paused;
                pauseMenu.SetSelectionY(0);
                //timer = 0.2;
            }
            else
            {
                switch (curPhase)
                {
                case Phase.Introduction:
                    exitButton.Update(mouseX, mouseY);
                    introText.Update(dt, prevStateKb, prevStateM);

                    if (controlHint)
                    {
                        if ((prevStateKb.IsKeyUp(Keys.Escape) && Keyboard.GetState().IsKeyDown(Keys.Escape)) || exitButton.IsPressed(prevStateM))
                        {
                            controlHint = false;
                            introText.finishMessage();
                            introText.finishText();
                            if (controlRevisit)
                            {
                                curPhase = Phase.MainMenu;
                            }
                            else
                            {
                                curPhase  = Phase.FinalMessage;
                                introText = new Hud(new string[] { "You can revisit that screen in Settings.\nHave fun!" }, cm, 30, 2, posY: -1, canClose: true);
                            }
                        }
                    }
                    if (introText.messageComplete())
                    {
                        if (controlHint)
                        {
                            controlHint = false;
                            //exitButton.Update(mouseX, mouseY);

                            if ((prevStateKb.IsKeyUp(Keys.Escape) && Keyboard.GetState().IsKeyDown(Keys.Escape)) || exitButton.IsPressed(prevStateM))
                            {
                                if (controlRevisit)
                                {
                                    curPhase = Phase.MainMenu;
                                }
                                else
                                {
                                    curPhase  = Phase.FinalMessage;
                                    introText = new Hud(new string[] { "You can revisit that screen in Settings.\nHave fun!" }, cm, 30, 2, posY: -1, canClose: true);
                                }
                            }
                        }
                        else if (!controlsShown)
                        {
                            controlsShown = true;
                            break;
                        }
                        else
                        {
                            //exitButton.Update(mouseX, mouseY);

                            //Hit the wrong buttons to continue
                            if ((prevStateKb.IsKeyUp(Keys.Space) && Keyboard.GetState().IsKeyDown(Keys.Space)) ||
                                !exitButton.IsPressed(prevStateM) && (prevStateM.LeftButton == ButtonState.Pressed && Mouse.GetState().LeftButton == ButtonState.Released))
                            {
                                controlHint = true;
                                introText   = new Hud(new string[] { "You can click the button in the upper left corner\nor hit the Escape key to exit this screen." }, cm, 30, 2, posY: -1, canClose: true);
                            }
                            else if ((prevStateKb.IsKeyUp(Keys.Escape) && Keyboard.GetState().IsKeyDown(Keys.Escape)) || exitButton.IsPressed(prevStateM))
                            {
                                if (controlRevisit)
                                {
                                    curPhase = Phase.MainMenu;
                                }
                                else
                                {
                                    curPhase  = Phase.FinalMessage;
                                    introText = new Hud(new string[] { "You can revisit that screen in Settings.\nHave fun!" }, cm, 30, 2, posY: -1, canClose: true);
                                }
                            }
                        }
                    }
                    else
                    {
                    }
                    break;

                case Phase.FinalMessage:
                    if (controlRevisit)
                    {
                        curPhase = Phase.MainMenu;
                        break;
                    }
                    introText.Update(dt, prevStateKb, prevStateM);
                    if (introText.messageComplete())
                    {
                        //TODO: Make an exit button
                        if (prevStateKb.IsKeyUp(Keys.Space) && Keyboard.GetState().IsKeyDown(Keys.Space) || (prevStateM.LeftButton == ButtonState.Pressed && Mouse.GetState().LeftButton == ButtonState.Released))
                        {
                            byte[] bytes = Encoding.UTF8.GetBytes("Palette: 0\nPractice: 0\nBattle: 0W 0L\nApples: 0W 0L\n");
                            fs.Write(bytes, 0, bytes.Length);
                            fs.Close();

                            curPhase = Phase.MainMenu;
                        }
                    }
                    break;

                case Phase.PracticeUnlock:
                    introText.Update(dt, prevStateKb, prevStateM);
                    if (introText.messageComplete())
                    {
                        //TODO: Make an exit button
                        if (prevStateKb.IsKeyUp(Keys.Space) && Keyboard.GetState().IsKeyDown(Keys.Space) || (prevStateM.LeftButton == ButtonState.Pressed && Mouse.GetState().LeftButton == ButtonState.Released))
                        {
                            UpdateSaveElem("Practice", 1);
                            curPhase = Phase.MainMenu;
                        }
                    }
                    break;

                case Phase.MainMenu:
                    switch (microgame.Update(dt, prevStateKb, prevStateM))
                    {
                    case 1:
                        microgame.Unload();
                        cm.Dispose();
                        cm = new ContentManager(contentManager.ServiceProvider);
                        cm.RootDirectory = contentManager.RootDirectory;
                        practiceMode     = false;
                        microgame        = ChooseGame();
                        //microgame = new TitleScreen(cm);
                        curPhase = Phase.Transition;
                        break;

                    case 2:
                        microgame.Unload();
                        cm.Dispose();
                        cm = new ContentManager(contentManager.ServiceProvider);
                        cm.RootDirectory = contentManager.RootDirectory;
                        practiceMode     = true;
                        microgame        = GetMostLost();
                        //microgame = new TitleScreen(cm);
                        curPhase = Phase.Transition;
                        break;

                    case 3:
                        game.Exit();
                        break;

                    case 4:
                        controlRevisit = true;
                        curPhase       = Phase.Introduction;
                        break;
                    }
                    break;

                case Phase.Transition:
                    if (beginSong)
                    {
                        if (microgame is BetweenGames)
                        {
                            MediaPlayer.Play(transitionSong);
                        }
                        else
                        {
                            MediaPlayer.Play(previewSong);
                        }
                        beginSong = false;
                    }

                    if ((currentFlashes & 1) == 0)
                    {
                        timer += dt.ElapsedGameTime.TotalSeconds;
                    }
                    else
                    {
                        timer -= dt.ElapsedGameTime.TotalSeconds;
                    }

                    transition.Parameters["time"].SetValue((float)timer * 4);

                    //Lets the transition animation start while borders are still animating
                    if (microgame is BetweenGames && currentFlashes > maxFlashes)
                    {
                        microgame.Update(dt, prevStateKb, prevStateM);
                    }

                    break;

                case Phase.InGame:
                    if (beginSong)
                    {
                        //if (microgame is Battle)
                        MediaPlayer.Stop();
                        MediaPlayer.Play(battleSong);
                        //else
                        //MediaPlayer.Play(previewSong);

                        beginSong = false;
                    }

                    byte result = microgame.Update(dt, prevStateKb, prevStateM);

                    if (result != 254)
                    {
                        countdownTimer += dt.ElapsedGameTime.TotalSeconds * timerMult;
                    }

                    //Won game
                    if (result == 255)
                    {
                        UpdateSaveGame(microgame.ToString(), true);
                        score++;
                        if (score == 10)
                        {
                            timerMult = 1.25;
                        }
                        else if (score == 20)
                        {
                            timerMult = 1.5;
                        }

                        countdownTimer = 0.0;
                        microgame.Unload();
                        cm.Dispose();
                        cm = new ContentManager(contentManager.ServiceProvider);
                        cm.RootDirectory = contentManager.RootDirectory;

                        if (continues <= 2)
                        {
                            if (score % 10 == 0)
                            {
                                microgame = new BetweenGames(cm, score, betweenGamesOffset, pauseButton, continues, false, true);
                                continues++;
                            }
                            else
                            {
                                microgame = new BetweenGames(cm, score, betweenGamesOffset, pauseButton, continues, false, false);
                            }
                        }
                        else
                        {
                            microgame = new BetweenGames(cm, score, betweenGamesOffset, pauseButton, continues, false);
                        }

                        curPhase  = Phase.Transition;
                        beginSong = true;
                        fromGame  = true;
                    }
                    //Lost game
                    else if (countdownTimer >= 11 || result == 2)
                    {
                        UpdateSaveGame(microgame.ToString(), false);
                        countdownTimer = 0.0;

                        microgame.Unload();
                        cm.Dispose();
                        cm = new ContentManager(contentManager.ServiceProvider);
                        cm.RootDirectory = contentManager.RootDirectory;

                        continues--;
                        microgame = new BetweenGames(cm, score, betweenGamesOffset, pauseButton, continues, true);

                        curPhase  = Phase.Transition;
                        beginSong = true;
                        fromGame  = true;
                        //BetweenGames phase will handle switching to TitleScreen on 0 continues
                    }

                    break;

                case Phase.BetweenGames:
                    if (beginSong)
                    {
                        beginSong = false;
                        MediaPlayer.Stop();
                        MediaPlayer.Play(previewSong);
                        //MediaPlayer.IsRepeating = true;
                    }
                    if (microgame.Update(dt, prevStateKb, prevStateM) == 255)
                    {
                        microgame.Unload();
                        cm.Dispose();
                        cm = new ContentManager(contentManager.ServiceProvider);
                        cm.RootDirectory = contentManager.RootDirectory;

                        if (continues > 0)
                        {
                            if (microgame is BetweenGames)
                            {
                                betweenGamesOffset = ((BetweenGames)microgame).GetAnimOffset();
                                microgame          = ChooseGame();
                            }
                            else
                            {
                                betweenGamesOffset = 0.0;
                                //beginSong = true;
                                goto case Phase.InGame;
                            }
                        }
                        else
                        {
                            //Out of continues
                            score              = 0;
                            timerMult          = 1.0;
                            timer              = 0.2;
                            betweenGamesOffset = 0.0;
                            lio = contentManager.Load <Texture2D>("Menus/TransitionQuit");
                            MediaPlayer.Stop();
                            continues = 3;

                            //First time getting a game over
                            if (!practiceUnlocked)
                            {
                                practiceIntro    = true;
                                practiceUnlocked = true;
                                introText        = new Hud(new string[] { "You've unlocked practice mode!\nYou can play the games you've lost more frequently.", "Check it out in the menu!" }, cm, 30, 2, posY: -1, canClose: true);
                            }
                            microgame = new TitleScreen(cm, paletteShader, practiceUnlocked);
                        }

                        curPhase  = Phase.Transition;
                        fromGame  = false;
                        beginSong = false;
                    }

                    break;

                case Phase.Paused:
                    resumeButton.Update(mouseX, mouseY);
                    if (!exitConfirm && (Keyboard.GetState().IsKeyUp(Keys.Escape) && prevStateKb.IsKeyDown(Keys.Escape) || resumeButton.IsPressed(prevStateM)))
                    {
                        prevStateM = state;
                        curPhase   = prevPhase;
                        MediaPlayer.Resume();
                    }
                    else
                    {
                        pauseMenu.Update(dt, prevStateKb, prevStateM, mouseX, mouseY);

                        if (!exitConfirm)
                        {
                            switch (pauseMenu.GetSelectionY(prevStateKb, prevStateM, mouseX, mouseY))
                            {
                            case 0:
                                int indX = pauseMenu.GetSelectionX(prevStateKb, prevStateM, mouseX, mouseY);
                                if (indX > 0)
                                {
                                    Console.WriteLine("tryna set color");
                                    SetColor(indX - 1);
                                }
                                break;

                            case 1:
                                if (Mouse.GetState().LeftButton == ButtonState.Released && prevStateM.LeftButton == ButtonState.Pressed ||
                                    Keyboard.GetState().IsKeyUp(Keys.Space) && prevStateKb.IsKeyDown(Keys.Space))
                                {
                                    exitConfirm = true;
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            //Check for OK, No
                            yesButton.Update(mouseX, mouseY);
                            noButton.Update(mouseX, mouseY);
                            backButton.Update(mouseX, mouseY);

                            if (yesButton.IsPressed(prevStateM) || (prevStateKb.IsKeyDown(Keys.Enter)) && Keyboard.GetState().IsKeyUp(Keys.Enter))
                            {
                                microgame.Unload();
                                cm.Dispose();
                                cm = new ContentManager(contentManager.ServiceProvider);
                                cm.RootDirectory = contentManager.RootDirectory;

                                lio = contentManager.Load <Texture2D>("Menus/TransitionQuit");
                                if (score < 10)
                                {
                                    timer = 1.8;
                                }
                                else
                                {
                                    timer = 1.4;
                                }
                                betweenGamesOffset = 0.0;
                                MediaPlayer.Stop();
                                microgame = new TitleScreen(cm, paletteShader, practiceUnlocked);
                                //microgame = new Battle(cm, mainTarget, graphicsDevice, pp);

                                curPhase  = Phase.Transition;
                                beginSong = false;
                                fromGame  = true;
                            }
                            else if (noButton.IsPressed(prevStateM) || backButton.IsPressed(prevStateM) ||
                                     ((prevStateKb.IsKeyDown(Keys.Escape)) && Keyboard.GetState().IsKeyUp(Keys.Escape)))
                            {
                                exitConfirm = false;
                            }
                        }
                        //pauseMenu.GetSelection(prevStateKb, prevStateM, mouseX, mouseY);
                    }
                    break;
                }
            }

            //microgame.Update(dt, prevStateKb, prevStateM);
            prevStateKb = Keyboard.GetState();
            prevStateM  = Mouse.GetState();
        }
示例#4
0
        byte MiniScreen.Update(GameTime gameTime, KeyboardState prevStateKb, MouseState prevStateM)
        {
            if (flasher != null)
            {
                if ((flashCounter & 1) == 0)
                {
                    flashTimer -= gameTime.ElapsedGameTime.TotalSeconds * timerMult * 4.2;
                }
                else
                {
                    flashTimer += gameTime.ElapsedGameTime.TotalSeconds * timerMult * 4.2;
                }
                if (flasher.health > 0)               //Attack Flash
                {
                    flash.Parameters["time"].SetValue((float)(flashTimer + 0.1));
                }
                else                                                                     //Dying flash
                {
                    flash.Parameters["time"].SetValue((float)(flashTimer / 1.1 + 0.01)); //the added value controls the offset, multiplication controls transition speed
                }
                if (flashTimer > 0.2)                                                    // || flashTimer < 0)
                {
                    flashTimer = 0.2;
                    flashCounter++;
                    //flashColor = Color.Red;
                }
                else if (flashTimer < 0)
                {
                    flashTimer = 0;
                    flashCounter++;
                    //flashColor = Color.Blue;
                }
                if (flashCounter > 11)
                {
                    flasher      = null;
                    flashTimer   = 0;
                    flashCounter = 1;
                    //flashColor = Color.Green;
                }

                switch (flashCounter)
                {
                case 0:
                    flashColor = Color.Red;
                    break;

                case 1:
                    //Final color
                    flashColor = Color.Transparent;
                    break;

                case 2:
                    flashColor = Color.Transparent;
                    break;

                case 3:
                    flashColor = new Color(128, 128, 64);
                    break;

                case 4:
                    flashColor = new Color(192, 192, 128);
                    break;

                case 5:
                    flashColor = new Color(192, 192, 128);
                    break;

                case 6:
                    flashColor = new Color(192, 192, 128);
                    break;

                case 7:
                    flashColor = new Color(128, 128, 64);
                    break;

                case 8:
                    flashColor = new Color(128, 128, 64);
                    break;

                case 9:
                    flashColor = new Color(128, 128, 64);
                    break;

                case 10:
                    flashColor = Color.Black;
                    break;

                default:
                    flashColor = Color.Transparent;
                    break;
                }
            }

            enemy.Update(gameTime);

            travis.Update(gameTime, Keyboard.GetState());

            world.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
            combatTimer += gameTime.ElapsedGameTime.TotalSeconds;
            waiterTimer += gameTime.ElapsedGameTime.TotalSeconds;
            turnWaiter  += gameTime.ElapsedGameTime.TotalSeconds;

            commandName.finishMessage();
            commandName.Update(gameTime, prevStateKb, prevStateM);
            UpdateBackground(gameTime);

            if (curPhase == Phase.EnemyDeathPhase)
            {
                if (flasher == null)                //Executed after flashing finishes
                {
                    //Renders an extra frame at the end so the sprite is invisible during transition
                    if (exitReady)
                    {
                        return(255);
                    }
                    if (enemy.IsKilled() && !deathMessageDisplayed)
                    {
                        exitReady = true;
                        //return 255;
                        text = new Hud(new string[] { enemy.deathMessage }, content, 30, 2, posY: 3, canClose: true);
                        text.finishMessage();
                        text.visible          = false;
                        deathMessageDisplayed = true;
                    }
                    enemy.Kill();
                }
                Console.WriteLine("flash: " + flashCounter);

                if (text.messageComplete())
                {
                    if (flashCounter == 1)
                    {
                        text = new Hud(new string[] { "" }, content, 30, 2, posY: 3, canClose: false);
                        text.finishMessage();
                        //text.finishText();
                        //text.visible = false;
                        victory    = true;
                        turnWaiter = 0;
                    }
                }
            }


            if (turnWaiter > 0.2)
            {
                if (text.messageComplete())
                {
                    if (waiter != null)
                    {
                        if (waiter.attacked)
                        {
                            if (waiter is Enemy)
                            {
                                if (waiter.IsDone(gameTime, combatTimer))
                                {
                                    waiter.ForceFinish();
                                    waiter     = null;
                                    turnWaiter = 0;
                                }
                            }
                            else
                            {
                                if (waiter.IsDone(gameTime, waiterTimer))
                                {
                                    waiterTimer = 0;
                                    waiter.ForceFinish();
                                    waiter     = null;
                                    turnWaiter = 0;
                                }
                            }
                        }
                        else
                        {
                            waiter.TakeDamage(10, combatTimer);
                            waiter.attacked = true;
                        }
                    }
                    else
                    {
                        advanceBattle(gameTime, prevStateKb, prevStateM);
                    }
                }
                //else
                //text.Update(gameTime, prevState);

                if (victory && turnWaiter > 0.5)
                {
                    return(255);
                }
            }
            text.Update(gameTime, prevStateKb, prevStateM);

            //prevState = Keyboard.GetState();

            //if (prevStateKb.IsKeyDown(Keys.Q) && Keyboard.GetState().IsKeyUp(Keys.Q))
            //	return 255;

            return(toReturn);
        }