using Otter;

namespace PpbbffttMiningHa.ui
{
    class Boss3Health : Entity
    {
        public MovingNumbers place_units;
        public MovingNumbers place_tens;
        public MovingNumbers place_hundreds;
        public MovingNumbers place_thousands;
        public MovingNumbers place_tenThousands;
        public MovingNumbers place_hunThousands;
        public MovingNumbers place_millions;
        public long holdingNumber = 0;
        public int size = 0;
        public bool isUnit = false;
        public bool isTens = false;
        public bool isHundreds = false;
        public bool isThousands = false;
        public bool isTenThousands = false;
        public bool isHunThousands = false;
        public bool isMillions = false;
        private int unitsStart = 0;
        private int tensStart = 0;
        private int hunStart = 0;
        private int thouStart = 0;
        private int tenThouStart = 0;
        private int hunThouStart = 0;
        private int millStart = 0;

        private int startingPositionX = 16;
        private int startingPositionY = 16;

        public Boss3Health(int spx, int spy)
        {
            startingPositionX = spx;
            startingPositionY = spy;
        }
        public override void Added()
        {
            base.Added();
            Global.GAME.Scene.Add(place_units = new MovingNumbers(startingPositionX + 112, startingPositionY, "0", Color.FromBytes(37, 119, 28, 255)));
            Global.GAME.Scene.Add(place_tens = new MovingNumbers(startingPositionX + 104, startingPositionY, "0", Color.FromBytes(37, 119, 28, 255)));
            Global.GAME.Scene.Add(place_hundreds = new MovingNumbers(startingPositionX + 96, startingPositionY, " ", Color.FromBytes(37, 119, 28, 255)));
            Global.GAME.Scene.Add(place_thousands = new MovingNumbers(startingPositionX + 88, startingPositionY, " ", Color.FromBytes(37, 119, 28, 255)));
            Global.GAME.Scene.Add(place_tenThousands = new MovingNumbers(startingPositionX + 80, startingPositionY, " ", Color.FromBytes(37, 119, 28, 255)));
            Global.GAME.Scene.Add(place_hunThousands = new MovingNumbers(startingPositionX + 72, startingPositionY, " ", Color.FromBytes(37, 119, 28, 255)));
            Global.GAME.Scene.Add(place_millions = new MovingNumbers(startingPositionX + 64, startingPositionY, " ", Color.FromBytes(37, 119, 28, 255)));
        }
        public override void Update()
        {
            base.Update();
            if (holdingNumber != Global.GhostHealth)
            {
                size = (Global.GhostHealth.ToString()).Length;
                if (size == 1) Units();
                if (size == 2) Tens();
                if (size == 3) Hundreds();
                if (size == 4) Thousands();
                if (size == 5) TenThousands();
                if (size == 6) HunThousands();
                if (size == 7) Millions();
                if (isUnit) place_units.c = (Global.GhostHealth.ToString()).Substring(unitsStart, 1);
                else place_units.c = "";
                if (isTens) place_tens.c = (Global.GhostHealth.ToString()).Substring(tensStart, 1);
                else place_tens.c = "";
                if (isHundreds) place_hundreds.c = (Global.GhostHealth.ToString()).Substring(hunStart, 1);
                else place_hundreds.c = "";
                if (isThousands) place_thousands.c = (Global.GhostHealth.ToString()).Substring(thouStart, 1);
                else place_thousands.c = "";
                if (isTenThousands) place_tenThousands.c = (Global.GhostHealth.ToString()).Substring(tenThouStart, 1);
                else place_tenThousands.c = "";
                if (isHunThousands) place_hunThousands.c = (Global.GhostHealth.ToString()).Substring(hunThouStart, 1);
                else place_hunThousands.c = "";
                if (isMillions) place_millions.c = (Global.GhostHealth.ToString()).Substring(millStart, 1);
                else place_millions.c = "";

                holdingNumber = Global.GhostHealth;
            }
        }
        public void Units()
        {
            isUnit = true; unitsStart = 0;
            isTens = false;
            isHundreds = false;
            isThousands = false;
            isTenThousands = false;
            isMillions = false;
        }
        public void Tens()
        {
            isUnit = true; unitsStart = 1;
            isTens = true; tensStart = 0;
            isHundreds = false;
            isThousands = false;
            isTenThousands = false;
            isMillions = false;
        }
        public void Hundreds()
        {
            isUnit = true; unitsStart = 2;
            isTens = true; tensStart = 1;
            isHundreds = true; hunStart = 0;
            isThousands = false;
            isTenThousands = false;
            isMillions = false;
        }
        public void Thousands()
        {
            isUnit = true; unitsStart = 3;
            isTens = true; tensStart = 2;
            isHundreds = true; hunStart = 1;
            isThousands = true; thouStart = 0;
            isTenThousands = false;
            isMillions = false;
        }
        public void TenThousands()
        {
            isUnit = true; unitsStart = 4;
            isTens = true; tensStart = 3;
            isHundreds = true; hunStart = 2;
            isThousands = true; thouStart = 1;
            isTenThousands = true; tenThouStart = 0;
            isMillions = false;
        }
        public void HunThousands()
        {
            isUnit = true; unitsStart = 5;
            isTens = true; tensStart = 4;
            isHundreds = true; hunStart = 3;
            isThousands = true; thouStart = 2;
            isTenThousands = true; tenThouStart = 1;
            isHunThousands = true; hunThouStart = 0;
            isMillions = false;
        }
        public void Millions()
        {
            isUnit = true; unitsStart = 6;
            isTens = true; tensStart = 5;
            isHundreds = true; hunStart = 4;
            isThousands = true; thouStart = 3;
            isTenThousands = true; tenThouStart = 2;
            isHunThousands = true; hunThouStart = 1;
            isMillions = true; millStart = 0;
        }
    }
}



