using Otter;
using Puppyups.UI;
using Puppyups.Utilities;
using System;

namespace Puppyups.Scenes
{
    class TitleScreen : Scene
    {
        public Image TitleImage = new Image(Assets.TITLESCREEN);

        private Color colorOption;

        public TitleScreen()
        {
            AddGraphic(TitleImage);
            for (var i = 0; i < 100; i++)
            {
                var randColor = Rand.Int(1, 3);
                if (randColor == 1)
                    colorOption = Color.Magenta;
                else if (randColor == 2)
                    colorOption = Color.Mix(Color.Blue, Color.Red);
                //WriteWord(Rand.Float(0, 360), Rand.Float(-20, 480), "dogggggggieeeeessssssssssss!!", colorOption, 1f, 1);
            }
            WriteWord(121, 101, "Welcome To PUPPYUPS", Color.Gold, 2f, 1, 13);
            WriteWord(120, 100, "Welcome To PUPPYUPS", Color.White, 2f, 1, 13);
            WriteWord(121, 151, "HA!", Color.Gold, 2f, 1, 13);
            WriteWord(120, 150, "HA!", Color.White, 2f, 1, 13);
            WriteWord(123, 203, "Puppyups!", Color.Blue, 5f, 1, 33);
            WriteWord(120, 200, "Puppyups!", Color.White, 5f, 1, 33);
            WriteWord(120, 300, "Press Enter to start!", Color.Cyan, 4f, 1, 25);
            WriteWord(100, 400, "By Commanderstitch!", Color.Cyan, 3f, 1, 20);
        }

        public override void Update()
        {
            base.Update();
            SoundManager.PlayRequestedSound(RandomYip(), .1f);//should render 1-7, It does.
            if (Global.PlayerSession.Controller.Button("Start").Pressed)
            {
                Global.GAME.RemoveScene();
                Global.GAME.AddScene(new TwoPlayerQuestion());
            }
        }

        private string RandomYip()
        {
            switch (Rand.Int(1,8))
                {
                case 1:
                    return "_yipOne1";
                case 2:
                    return "_yipTwo1";
                case 3:
                    return "_yipThree1";
                case 4:
                    return "_yipFour1";
                case 5:
                    return "_yipFive1";
                case 6:
                    return "_yipSix1";
                case 7:
                    return "_yipSeven1";
                default:
                    return "_yipOne1";
            }
        }

        public void WriteWord(float x, float y, string word, Color color, float scale, int layer, int spacer = 10)
        {
            var a = 0;
            for (var i = 0; i < word.Length; i++)
            {
                Add(new Numbers(x + a, y, word[i].ToString(), color, scale, layer));
                a += spacer;
            }
        }
    }
}
