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

namespace PenniesAreGold
{
    class Menu : Scene
    {
        public Image titleImage = new Image(Assets.TITLE_IMAGE);

        public Menu()
        {
            this.AddGraphic(titleImage);
            AddTitle();
            AddOnePlayerStart();
            Add(new Penny(195, 270));
        }

        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)
            {
                //player values!
                Global.PlayerX = 0.0f;
                Global.PlayerY = 0.0f;
                Global.PlayerHealth = 300;
                Global.PlayerSpeed = new Speed(300);//was 300 testing
                //extras
                Global.troopSpeed = 1f;
                Global.TroopBuildingCost = 5;
                Global.enemyBulletSpeed = 1f;
                Global.troopBulletSpeed = 1f;
                //main values
                Global.numberOfCoins = 0;
                Global.totalNumberOfCoins = 0;
                Global.kills = 0;
                Global.Score = 0;
                //class public statics:
                Player.canPlayerCollide = true;
                Player.isSpritemapChanged = true;
                MineButton.IsMiningBuildingOnMouse = false;
                TroopButton.IsTroopBuildingOnMouse = false;
                //load the level
                Global.GAME.RemoveScene();
                Global.GAME.AddScene(new LevelOne()); 
            }
            Add(new MenuPenny(Global.MW / 2, Global.MH / 2));
        }

        private void AddTitle()
        {
            string author = "Start the game!";
            var y = 0;
            for (var i = 0; i < author.Length; i++)
            {
                Add(new Numbers(202 + y, 262, author[i].ToString(), Color.FromBytes(175,100,50,255), 2f));
                Add(new Numbers(200 + y, 260, author[i].ToString(), Color.White, 2f));
                y += 14;
            }
        }

        private void AddOnePlayerStart()
        {
            string author = " Press enter! hurray!";
            var y = 0;
            for (var i = 0; i < author.Length; i++)
            {
                Add(new Numbers(202 + y, 287, author[i].ToString(), Color.FromHSV(10,1,.5f,1), 2f));
                Add(new Numbers(200 + y, 285, author[i].ToString(), Color.White, 2f));
                y += 14;
            }
        }


    }
}

