using Otter;
using PpbbffttMiningHa.entities;
using PpbbffttMiningHa.entities.MapEntities;
using PpbbffttMiningHa.ui;
using PpbbffttMiningHa.Utility;

namespace PpbbffttMiningHa.scenes.Levels
{
    class LevelFour : Scene
    {
        public const int _width = Global.MW;
        public const int _height = Global.MH;
        private bool _addGlobalUI = true;
        private bool one;
        private bool _addScoreMissing;

        public LevelFour()
        {
            Add(new BackDrop4(0, 0));
            SoundManager.PlayRequestedSound("_ballHitTrashCan");
            Global.WriteWord(100, 340, "THAT's IT GET IT and get out of here!", Color.FromBytes(70, 35, 0, 255), 1, -10, this, 300, 14);
            for (var x = -64; x < Global.MW + 64; x += 32)
            {
                for (var y = 300; y < 600; y += 32)
                {
                    Add(new BottomRock(x, y));
                }
            }
            Global.cam = new Camera(100, 2);
            #region Add Players and UI
            Global.player = new Player(16, 200);// 1800 is for testing the bottom
            Add(Global.player);
            Add(new Score(16, 10));
            Add(new GemsInHand(400, 10));
            Add(new TreasureThingy(390, 180));
            Add(new PlayerHealthDisplay(240, 10));
            #endregion

            Add(Global.cam);

            //always add this guy so we can pause the game:
            Add(new PausePerson());
        }

        public override void Begin()
        {
            base.Begin();
            Global.cam.AdjustToPlayer(Global.MW, Global.MH, Global.PlayerX, Global.PlayerY);
        }
        public override void Update()
        {
            base.Update();
            if (!IsGroupPaused(0))
            {
                if (_addGlobalUI)
                {
                    _addGlobalUI = false;
                    //Global.AddAllLevelUI(Global.GAME.Scene);//so i don't have to add the same ui every level if all levels have it.
                }
                Shared.LevelUpdate(Global.GAME.Scene);
                //all other unique level updates go here:
                if (Global.PlayerY < 0 && Global.HasTreasure)
                {
                    Global.GAME.RemoveScene();
                    Global.GAME.AddScene(new WinScreen());// Add next level here or, where you want to go
                }
            }
            if (!_addScoreMissing)
            {
                _addScoreMissing = true;
                Global.WriteWord(450 - 1, 10 - 1, "Gems:", Color.FromBytes(3, 153, 209, 255), 1f, -101, this, 0, 10);//regular text  
                Global.WriteWord(450, 10, "Gems:", Color.FromBytes(0, 0, 0, 255), 1f, -100, this, 0, 10);//shadow (layers sort this)
                Global.WriteWord(20 - 1, 10 - 1, "Score:", Color.FromBytes(228, 255, 43, 255), 1f, -101, this, 0, 10);//regular text  
                Global.WriteWord(20, 10, "Score:", Color.FromBytes(0, 0, 0, 255), 1f, -100, this, 0, 10);//shadow (layers sort this)
                Global.WriteWord(230 - 1, 10 - 1, "Health:", Color.FromBytes(255, 0, 0, 255), 1f, -101, this, 0, 10);//regular text  
                Global.WriteWord(230, 10, "Health:", Color.FromBytes(0, 0, 0, 255), 1f, -100, this, 0, 10);//shadow (layers sort this)

                //first event:
                Global.WriteWordUI(20 - 1, 460 - 1, "Dig!", Color.FromBytes(0, 64, 255, 255), 1f, -101, this, 0, 10);//regular text  
                Global.WriteWordUI(20, 460, "Dig!", Color.FromBytes(0, 0, 0, 255), 1f, -100, this, 0, 10);//shadow (layers sort this)

            }
        }//end of UPDATE

        public override void Render()
        {
            base.Render();
            //grid.Render();
        }
    }
}

