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

namespace PenniesAreGold
{
    class WinScreen : Scene
    {
        public Image winImage = new Image(Assets.WIN_IMAGE);

        public WinScreen()
        {
            this.AddGraphic(winImage);
            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 + y, 186, author[i].ToString(), Color.Blue, 2f));
                Add(new Numbers(270 + y, 185, 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 + y, 221, author[i].ToString(), Color.Blue, 2f));
                Add(new Numbers(270 + y, 220, 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 + y, 255, author[i].ToString(), Color.Blue, 2f));
                Add(new Numbers(270 + y, 254, author[i].ToString(), Color.White, 2f));
                y += 17;
            }
        }
    }
}


