using GiraffeRoller.entities;
using GiraffeRoller.scenes.Levels;
using GiraffeRoller.ui;
using GiraffeRoller.Utility;
using Otter;

namespace GiraffeRoller.scenes
{
    class Tutorial2 : Scene
    {
        public Image titleImage = new Image(Assets.TITLE_IMAGE);
        private bool one = true;

        public Tutorial2()
        {
            titleImage.ScaleY = 0.80f;
            AddGraphic(titleImage);

            Add(new Title(150, -460));
            Add(new PausePerson());
            SoundManager.PlayRequestedSound("_startGame");
        }

        public override void Update()
        {
            base.Update();
            if (!IsGroupPaused(0))
            {
                if (one)
                {
                    one = false;
                    string giraffeRoller = "How To Play";
                    var zzz = 0;
                    var ff = .1f;
                    for (var b = 0; b < giraffeRoller.Length; b++)
                    {
                        Add(new Numbers(50 + zzz, 50, giraffeRoller[b].ToString(), Color.Lerp(Color.Yellow, Color.Red, ff), .5f, 4f));
                        Add(new Numbers(50 + zzz, 50, giraffeRoller[b].ToString(), Color.Lerp(Color.Yellow, Color.Red, ff), .5f, 4f, 1, .5f));
                        Add(new Numbers(50 + zzz, 50, giraffeRoller[b].ToString(), Color.Lerp(Color.Yellow, Color.Red, ff), .5f, 4f, 1, .3f));
                        Add(new Numbers(50 + zzz, 50, giraffeRoller[b].ToString(), Color.Lerp(Color.Yellow, Color.Red, ff), .5f, 4f, 1, .1f));
                        zzz += 45;
                        ff += .05f;
                    }
                    string author = "At first, there is peace.";
                    var f = .1f;
                    var y = 0;
                    for (var i = 0; i < author.Length; i++)
                    {
                        Add(new Numbers(250 + y, 150, author[i].ToString(), Color.Lerp(Color.Blue, Color.Green, f), .1f));
                        Add(new Numbers(250 + y, 150, author[i].ToString(), Color.Lerp(Color.Blue, Color.Green, f), .1f, 1, 1, .5f));
                        Add(new Numbers(250 + y, 150, author[i].ToString(), Color.Lerp(Color.Blue, Color.Green, f), .1f, 1, 1, .3f));
                        Add(new Numbers(250 + y, 150, author[i].ToString(), Color.Lerp(Color.Blue, Color.Green, f), .1f, 1, 1, .1f));
                        y += 10;
                        f += .05f;
                    }
                    string author2 = "Then They will attack.";
                    var f2 = .1f;
                    var y2 = 0;
                    for (var i = 0; i < author2.Length; i++)
                    {
                        Add(new Numbers(200 + y2, 210, author2[i].ToString(), Color.Lerp(Color.Gold, Color.Red, f2), .1f));
                        Add(new Numbers(200 + y2, 210, author2[i].ToString(), Color.Lerp(Color.Gold, Color.Red, f2), .1f, 1, 1, .5f));
                        Add(new Numbers(200 + y2, 210, author2[i].ToString(), Color.Lerp(Color.Gold, Color.Red, f2), .1f, 1, 1, .3f));
                        Add(new Numbers(200 + y2, 210, author2[i].ToString(), Color.Lerp(Color.Gold, Color.Red, f2), .1f, 1, 1, .1f));
                        y2 += 10;
                        f2 += .05f;
                    }
                    string author22 = "You will be stuck . . . in a LOOP";
                    var f22 = .1f;
                    var y22 = 0;
                    for (var i = 0; i < author22.Length; i++)
                    {
                        Add(new Numbers(200 + y22, 260, author22[i].ToString(), Color.Lerp(Color.Orange, Color.Red, f22), .1f));
                        Add(new Numbers(200 + y22, 260, author22[i].ToString(), Color.Lerp(Color.Orange, Color.Red, f22), .1f, 1, 1, .5f));
                        Add(new Numbers(200 + y22, 260, author22[i].ToString(), Color.Lerp(Color.Orange, Color.Red, f22), .1f, 1, 1, .3f));
                        Add(new Numbers(200 + y22, 260, author22[i].ToString(), Color.Lerp(Color.Orange, Color.Red, f22), .1f, 1, 1, .1f));
                        y22 += 10;
                        f22 += .05f;
                    }
                    string author3 = "Save everyone by following this order:";
                    var f3 = .1f;
                    var y3 = 0;
                    for (var i = 0; i < author3.Length; i++)
                    {
                        Add(new Numbers(200 + y3, 300, author3[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f3), .1f));
                        Add(new Numbers(200 + y3, 300, author3[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f3), .1f, 1, 1, .5f));
                        Add(new Numbers(200 + y3, 300, author3[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f3), .1f, 1, 1, .3f));
                        Add(new Numbers(200 + y3, 300, author3[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f3), .1f, 1, 1, .1f));
                        y3 += 10;
                        f3 += .05f;
                    }
                    string author33 = "WATER -- POWER -- WAREHOUSE -- BOSS";
                    var f33 = .1f;
                    var y33 = 0;
                    for (var i = 0; i < author33.Length; i++)
                    {
                        Add(new Numbers(200 + y33, 350, author33[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f33), .1f));
                        Add(new Numbers(200 + y33, 350, author33[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f33), .1f, 1, 1, .5f));
                        Add(new Numbers(200 + y33, 350, author33[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f33), .1f, 1, 1, .3f));
                        Add(new Numbers(200 + y33, 350, author33[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f33), .1f, 1, 1, .1f));
                        y33 += 10;
                        f33 += .05f;
                    }
                    var pressStart = "Press Start or Enter to BEGIN!!!!!";
                    var a = 0;
                    for (var b = 0; b < pressStart.Length; b++)
                    {
                        Add(new Numbers(200 + a, 420, pressStart[b].ToString(), Color.White));
                        Add(new Numbers(200 + a, 420, pressStart[b].ToString(), Color.White, .1f, 1, 1, .5f));
                        Add(new Numbers(200 + a, 420, pressStart[b].ToString(), Color.White, .1f, 1, 1, .3f));
                        Add(new Numbers(200 + a, 420, pressStart[b].ToString(), Color.White, .1f, 1, 1, .1f));
                        a += 10;
                    }
                }

                if (Global.PlayerSession.Controller.Button("P1Start").Pressed)
                {
                    Global.GAME.RemoveScene();
                    SoundManager.PlayRequestedSound("_bossBoom3", 2f);
                    Global.GAME.AddScene(new LevelOne(Global.MW / 2, Global.MH / 2));// Add next level here or, where you want to go
                }
            }
        }
    }
}
