using KellysMarvelousAdventure.Scenes;
using KellysMarvelousAdventure.UI;
using KellysMarvelousAdventure.Utilities;
using Otter;

namespace KellysMarvelousAdventure
{
    class LoseScreen : Scene
    {
        public Image loseImage = new Image(Assets.LOSESCREEN);
        private int _xo = 30; //offset because i'm lazy xD
        private int _yo = 30; //offset because i'm lazy xD

        public LoseScreen()
        {
            //loseImage.ScaleY = 0.80f;
            this.AddGraphic(loseImage);
            AddScore();
            AddClicks();
            AddKills();
            AddShips();
            SoundManager.PlayRequestedSound("_oldManSlowLaugh");
        }

        public override void Update()
        {
            base.Update();
            if (Global.PlayerSession.Controller.Button("Start").Pressed)
            {
                Global.GAME.RemoveScene();
                Global.GAME.AddScene(new TitleScreen());
            }
        }

        private void AddScore()
        {
            string author = Global.score.ToString();
            var y = 0;
            for (var i = 0; i < author.Length; i++)
            {
                Add(new Numbers(271 + _xo + y, 186 - _yo, author[i].ToString(), Color.Red, 2f));
                Add(new Numbers(270 + _xo + y, 185 - _yo, author[i].ToString(), Color.White, 2f));
                y += 17;
            }
        }

        private void AddClicks()
        {
            string author = Global.Clicks.ToString();
            var y = 0;
            for (var i = 0; i < author.Length; i++)
            {
                Add(new Numbers(271 + _xo + y, 221 - _yo, author[i].ToString(), Color.Red, 2f));
                Add(new Numbers(270 + _xo + y, 220 - _yo, author[i].ToString(), Color.White, 2f));
                y += 17;
            }
        }

        private void AddKills()
        {
            string author = Global.kills.ToString();
            var y = 0;
            for (var i = 0; i < author.Length; i++)
            {
                Add(new Numbers(271 + _xo + y, 255 - _yo, author[i].ToString(), Color.Red, 2f));
                Add(new Numbers(270 + _xo + y, 254 - _yo, author[i].ToString(), Color.White, 2f));
                y += 17;
            }
        }
        private void AddShips()
        {
            string author = Global.NumberOfShips.ToString();
            var y = 0;
            for (var i = 0; i < author.Length; i++)
            {
                Add(new Numbers(271 + y, 285, author[i].ToString(), Color.Red, 2f));
                Add(new Numbers(270 + y, 284, author[i].ToString(), Color.White, 2f));
                y += 17;
            }
        }
    }
}


