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

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

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

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

        public override void Update()
        {
            base.Update();
            if (!IsGroupPaused(0))
            {
                if (!one)
                {
                    one = true;
                    string LoL = "PPBBFFTT Mining HA !";
                    var zzz = 0;
                    var ff = .5f;
                    var rotationalSpeed = .2f;
                    for (var b = 0; b < LoL.Length; b++)
                    {
                        Add(new Numbers(30 + zzz, 140, LoL[b].ToString(), Color.Lerp(Color.Yellow, Color.FromBytes(123, 49, 33), ff), rotationalSpeed, 3f));
                        Add(new Numbers(40 + zzz, 150, LoL[b].ToString(), Color.Lerp(Color.Yellow, Color.FromBytes(123, 49, 33), ff), rotationalSpeed, 3f, 1, .5f));
                        Add(new Numbers(50 + zzz, 160, LoL[b].ToString(), Color.Lerp(Color.Yellow, Color.FromBytes(123, 49, 33), ff), rotationalSpeed, 3f, 1, .3f));
                        Add(new Numbers(60 + zzz, 170, LoL[b].ToString(), Color.Lerp(Color.Yellow, Color.FromBytes(123, 49, 33), ff), rotationalSpeed, 3f, 1, .2f));
                        Add(new Numbers(70 + zzz, 180, LoL[b].ToString(), Color.Lerp(Color.Yellow, Color.FromBytes(123, 49, 33), ff), rotationalSpeed, 3f, 1, .2f));
                        Add(new Numbers(80 + zzz, 190, LoL[b].ToString(), Color.Lerp(Color.Yellow, Color.FromBytes(123, 49, 33), ff), rotationalSpeed, 3f, 1, .2f));
                        Add(new Numbers(90 + zzz, 200, LoL[b].ToString(), Color.Lerp(Color.Yellow, Color.FromBytes(123, 49, 33), ff), rotationalSpeed, 3f, 1, .1f));
                        Add(new Numbers(100 + zzz, 210, LoL[b].ToString(), Color.Lerp(Color.Yellow, Color.FromBytes(123, 49, 33), ff), rotationalSpeed, 3f, 1, .1f));
                        Add(new Numbers(110 + zzz, 220, LoL[b].ToString(), Color.Lerp(Color.Yellow, Color.FromBytes(123, 49, 33), ff), rotationalSpeed, 3f, 1, .05f));
                        Add(new Numbers(120 + zzz, 230, LoL[b].ToString(), Color.Lerp(Color.Yellow, Color.FromBytes(123, 49, 33), ff), rotationalSpeed, 3f, 1, .005f));
                        zzz += 30;
                        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 = "It's a gaem!";
                    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 (Timer % 4 == 0)
                {
                    Add(new Bomb(changer, -20, 2, true));
                    changer += 32;
                    if (changer > Global.MW)
                        changer = 0;
                }
                if (Global.PlayerSession.Controller.Button("P1Start").Pressed)
                {
                    Global.GAME.RemoveScene();
                    Global.GAME.AddScene(new LevelOne());// Add next level here or, where you want to go
                                                         //Global.GAME.AddScene(new Tutorial1());// Add next level here or, where you want to go if you want a turutururoial or awhatever
                }
            }
        }
    }
}

