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

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

        public TitleScreen()
        {
            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 = "Giraffe Roller";
                    var zzz = 0;
                    var ff = .1f;
                    for (var b = 0; b < giraffeRoller.Length; b++)
                    {
                        Add(new Numbers(50 + zzz, 150, giraffeRoller[b].ToString(), Color.Lerp(Color.Yellow, Color.Red, ff), .5f, 4f));
                        Add(new Numbers(50 + zzz, 150, giraffeRoller[b].ToString(), Color.Lerp(Color.Yellow, Color.Red, ff), .5f, 4f, 1, .5f));
                        Add(new Numbers(50 + zzz, 150, giraffeRoller[b].ToString(), Color.Lerp(Color.Yellow, Color.Red, ff), .5f, 4f, 1, .3f));
                        Add(new Numbers(50 + zzz, 150, giraffeRoller[b].ToString(), Color.Lerp(Color.Yellow, Color.Red, ff), .5f, 4f, 1, .1f));
                        zzz += 45;
                        ff += .05f;
                    }
                    string author = "By Commanderstitch";
                    var f = .1f;
                    var y = 0;
                    for (var i = 0; i < author.Length; i++)
                    {
                        Add(new Numbers(250 + y, 370, author[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f), .1f));
                        Add(new Numbers(250 + y, 370, author[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f), .1f, 1, 1, .5f));
                        Add(new Numbers(250 + y, 370, author[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f), .1f, 1, 1, .3f));
                        Add(new Numbers(250 + y, 370, author[i].ToString(), Color.Lerp(Color.Blue, Color.Cyan, f), .1f, 1, 1, .1f));
                        y += 10;
                        f += .05f;
                    }
                    var pressStart = "Press Start or Enter to Progress!";
                    var a = 0;
                    for (var b = 0; b < pressStart.Length; b++)
                    {
                        Add(new Numbers(240 + a, 420, pressStart[b].ToString(), Color.White));
                        Add(new Numbers(240 + a, 420, pressStart[b].ToString(), Color.White, .1f, 1, 1, .5f));
                        Add(new Numbers(240 + a, 420, pressStart[b].ToString(), Color.White, .1f, 1, 1, .3f));
                        Add(new Numbers(240 + a, 420, pressStart[b].ToString(), Color.White, .1f, 1, 1, .1f));
                        a += 10;
                    }

                    var version = "Drink up, Unicorns!";
                    var n = 0;
                    for (var b = 0; b < version.Length; b++)
                    {
                        Add(new SmallNumbers(500 + n, 460, version[b].ToString(), Color.Blue));
                        n += 5;
                    }
                }

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