using Otter;
using PenniesAreGold.objects;
using PenniesAreGold.ui;

namespace PenniesAreGold
{
    class LoseScreen : Scene
    {
        public Image loseImage = new Image(Assets.LOSE_IMAGE);
        private int _xo = 50; //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();
            AddCoins();
            AddKills();
        }

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

        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 AddCoins()
        {
            string author = Global.totalNumberOfCoins.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;
            }
        }
    }
}


