using Otter;

namespace KellysMarvelousAdventure.UI
{
    class SappCollected : Entity
    {
        public Numbers place_units;
        public Numbers place_tens;
        public Numbers place_hundreds;
        public Numbers place_thousands;
        public Numbers place_tenThousands;
        public Numbers place_hunThousands;
        public Numbers place_millions;
        public Numbers place_tenMillions;
        public Numbers place_hunMillions;
        public Numbers place_billions;
        public Numbers place_tenBillions;
        public Numbers place_hunBillions;
        public Numbers place_trillions;
        public Numbers place_tenTrillions;
        public Numbers place_hunTrillions;
        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;
        public bool isTenMillions = false;
        public bool isHunMillions = false;
        public bool isBillions = false;
        public bool isTenBillions = false;
        public bool isHunBillions = false;
        public bool isTrillions = false;
        public bool isTenTrillions = false;
        public bool isHunTrillions = 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 tenMillStart = 0;
        private int hunMillStart = 0;
        private int billStart = 0;
        private int tenBillStart = 0;
        private int hunBillStart = 0;
        private int trillStart = 0;
        private int tenTrillStart = 0;
        private int hunTrillStart = 0;

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

        public SappCollected(int spx, int spy)
        {
            startingPositionX = spx;
            startingPositionY = spy;
        }
        public override void Added()
        {
            base.Added();
            Global.GAME.Scene.Add(place_units = new Numbers(startingPositionX + 112, startingPositionY, "0", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_tens = new Numbers(startingPositionX + 104, startingPositionY, "0", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_hundreds = new Numbers(startingPositionX + 96, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_thousands = new Numbers(startingPositionX + 88, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_tenThousands = new Numbers(startingPositionX + 80, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_hunThousands = new Numbers(startingPositionX + 72, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_millions = new Numbers(startingPositionX + 64, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_tenMillions = new Numbers(startingPositionX + 56, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_hunMillions = new Numbers(startingPositionX + 48, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_billions = new Numbers(startingPositionX + 40, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_tenBillions = new Numbers(startingPositionX + 32, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_hunBillions = new Numbers(startingPositionX + 24, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_trillions = new Numbers(startingPositionX + 16, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_tenTrillions = new Numbers(startingPositionX + 8, startingPositionY, " ", Color.White, 1f, -10));
            Global.GAME.Scene.Add(place_hunTrillions = new Numbers(startingPositionX, startingPositionY, " ", Color.White, 1f, -10));
        }
        public override void Update()
        {
            base.Update();
            X = Scene.CameraX + startingPositionX;
            Y = Scene.CameraY + startingPositionY;
            if (holdingNumber != Global.SapCollected)
            {
                size = (Global.SapCollected.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 (size == 8) TenMillions();
                if (size == 9) HunMillions();
                if (size == 10) Billions();
                if (size == 11) TenBillions();
                if (size == 12) HunBillions();
                if (size == 13) Trillions();
                if (size == 14) TenTrillions();
                if (size == 15) HunTrillions();
                if (isUnit) place_units.c = (Global.SapCollected.ToString()).Substring(unitsStart, 1);
                else place_units.c = "";
                if (isTens) place_tens.c = (Global.SapCollected.ToString()).Substring(tensStart, 1);
                else place_tens.c = "";
                if (isHundreds) place_hundreds.c = (Global.SapCollected.ToString()).Substring(hunStart, 1);
                else place_hundreds.c = "";
                if (isThousands) place_thousands.c = (Global.SapCollected.ToString()).Substring(thouStart, 1);
                else place_thousands.c = "";
                if (isTenThousands) place_tenThousands.c = (Global.SapCollected.ToString()).Substring(tenThouStart, 1);
                else place_tenThousands.c = "";
                if (isHunThousands) place_hunThousands.c = (Global.SapCollected.ToString()).Substring(hunThouStart, 1);
                else place_hunThousands.c = "";
                if (isMillions) place_millions.c = (Global.SapCollected.ToString()).Substring(millStart, 1);
                else place_millions.c = "";
                if (isTenMillions) place_tenMillions.c = (Global.SapCollected.ToString()).Substring(tenMillStart, 1);
                else place_millions.c = "";
                if (isHunMillions) place_hunMillions.c = (Global.SapCollected.ToString()).Substring(hunMillStart, 1);
                else place_hunMillions.c = "";
                if (isBillions) place_billions.c = (Global.SapCollected.ToString()).Substring(billStart, 1);
                else place_billions.c = "";
                if (isTenBillions) place_tenBillions.c = (Global.SapCollected.ToString()).Substring(tenBillStart, 1);
                else place_tenBillions.c = "";
                if (isHunBillions) place_hunBillions.c = (Global.SapCollected.ToString()).Substring(hunBillStart, 1);
                else place_hunBillions.c = "";
                if (isTrillions) place_trillions.c = (Global.SapCollected.ToString()).Substring(trillStart, 1);
                else place_trillions.c = "";
                if (isTenTrillions) place_tenTrillions.c = (Global.SapCollected.ToString()).Substring(tenTrillStart, 1);
                else place_tenTrillions.c = "";
                if (isHunTrillions) place_hunTrillions.c = (Global.SapCollected.ToString()).Substring(hunTrillStart, 1);
                else place_hunTrillions.c = "";

                holdingNumber = Global.SapCollected;
            }
        }
        public void Units()
        {
            isUnit = true; unitsStart = 0;
            isTens = false;
            isHundreds = false;
            isThousands = false;
            isTenThousands = false;
            isMillions = false;
            isTenMillions = false;
            isHunMillions = false;
            isBillions = false;
            isTenBillions = false;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = false;
        }
        public void Tens()
        {
            isUnit = true; unitsStart = 1;
            isTens = true; tensStart = 0;
            isHundreds = false;
            isThousands = false;
            isTenThousands = false;
            isMillions = false;
            isTenMillions = false;
            isHunMillions = false;
            isBillions = false;
            isTenBillions = false;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = false;
        }
        public void Hundreds()
        {
            isUnit = true; unitsStart = 2;
            isTens = true; tensStart = 1;
            isHundreds = true; hunStart = 0;
            isThousands = false;
            isTenThousands = false;
            isMillions = false;
            isTenMillions = false;
            isHunMillions = false;
            isBillions = false;
            isTenBillions = false;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = false;
        }
        public void Thousands()
        {
            isUnit = true; unitsStart = 3;
            isTens = true; tensStart = 2;
            isHundreds = true; hunStart = 1;
            isThousands = true; thouStart = 0;
            isTenThousands = false;
            isMillions = false;
            isTenMillions = false;
            isHunMillions = false;
            isBillions = false;
            isTenBillions = false;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = 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;
            isTenMillions = false;
            isHunMillions = false;
            isBillions = false;
            isTenBillions = false;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = 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;
            isTenMillions = false;
            isHunMillions = false;
            isBillions = false;
            isTenBillions = false;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = 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;
            isTenMillions = false;
            isHunMillions = false;
            isBillions = false;
            isTenBillions = false;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = false;
        }
        public void TenMillions()
        {
            isUnit = true; unitsStart = 7;
            isTens = true; tensStart = 6;
            isHundreds = true; hunStart = 5;
            isThousands = true; thouStart = 4;
            isTenThousands = true; tenThouStart = 3;
            isHunThousands = true; hunThouStart = 2;
            isMillions = true; millStart = 1;
            isTenMillions = true; tenMillStart = 0;
            isHunMillions = false;
            isBillions = false;
            isTenBillions = false;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = false;
        }
        public void HunMillions()
        {
            isUnit = true; unitsStart = 8;
            isTens = true; tensStart = 7;
            isHundreds = true; hunStart = 6;
            isThousands = true; thouStart = 5;
            isTenThousands = true; tenThouStart = 4;
            isHunThousands = true; hunThouStart = 3;
            isMillions = true; millStart = 2;
            isTenMillions = true; tenMillStart = 1;
            isHunMillions = true; hunMillStart = 0;
            isBillions = false;
            isTenBillions = false;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = false;
        }
        public void Billions()
        {
            isUnit = true; unitsStart = 9;
            isTens = true; tensStart = 8;
            isHundreds = true; hunStart = 7;
            isThousands = true; thouStart = 6;
            isTenThousands = true; tenThouStart = 5;
            isHunThousands = true; hunThouStart = 4;
            isMillions = true; millStart = 3;
            isTenMillions = true; tenMillStart = 2;
            isHunMillions = true; hunMillStart = 1;
            isBillions = true; billStart = 0;
            isTenBillions = false;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = false;
        }
        public void TenBillions()
        {
            isUnit = true; unitsStart = 10;
            isTens = true; tensStart = 9;
            isHundreds = true; hunStart = 8;
            isThousands = true; thouStart = 7;
            isTenThousands = true; tenThouStart = 6;
            isHunThousands = true; hunThouStart = 5;
            isMillions = true; millStart = 4;
            isTenMillions = true; tenMillStart = 3;
            isHunMillions = true; hunMillStart = 2;
            isBillions = true; billStart = 1;
            isTenBillions = true; tenBillStart = 0;
            isHunBillions = false;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = false;
        }
        public void HunBillions()
        {
            isUnit = true; unitsStart = 11;
            isTens = true; tensStart = 10;
            isHundreds = true; hunStart = 9;
            isThousands = true; thouStart = 8;
            isTenThousands = true; tenThouStart = 7;
            isHunThousands = true; hunThouStart = 6;
            isMillions = true; millStart = 5;
            isTenMillions = true; tenMillStart = 4;
            isHunMillions = true; hunMillStart = 3;
            isBillions = true; billStart = 2;
            isTenBillions = true; tenBillStart = 1;
            isHunBillions = true; hunBillStart = 0;
            isTrillions = false;
            isTenTrillions = false;
            isHunTrillions = false;
        }
        public void Trillions()
        {
            isUnit = true; unitsStart = 12;
            isTens = true; tensStart = 11;
            isHundreds = true; hunStart = 10;
            isThousands = true; thouStart = 9;
            isTenThousands = true; tenThouStart = 8;
            isHunThousands = true; hunThouStart = 7;
            isMillions = true; millStart = 6;
            isTenMillions = true; tenMillStart = 5;
            isHunMillions = true; hunMillStart = 4;
            isBillions = true; billStart = 3;
            isTenBillions = true; tenBillStart = 2;
            isHunBillions = true; hunBillStart = 1;
            isTrillions = true; trillStart = 0;
            isTenTrillions = false;
            isHunTrillions = false;
        }
        public void TenTrillions()
        {
            isUnit = true; unitsStart = 13;
            isTens = true; tensStart = 12;
            isHundreds = true; hunStart = 11;
            isThousands = true; thouStart = 10;
            isTenThousands = true; tenThouStart = 9;
            isHunThousands = true; hunThouStart = 8;
            isMillions = true; millStart = 7;
            isTenMillions = true; tenMillStart = 6;
            isHunMillions = true; hunMillStart = 5;
            isBillions = true; billStart = 4;
            isTenBillions = true; tenBillStart = 3;
            isHunBillions = true; hunBillStart = 2;
            isTrillions = true; trillStart = 1;
            isTenTrillions = true; tenTrillStart = 0;
            isHunTrillions = false;
        }
        public void HunTrillions()
        {
            isUnit = true; unitsStart = 14;
            isTens = true; tensStart = 13;
            isHundreds = true; hunStart = 12;
            isThousands = true; thouStart = 11;
            isTenThousands = true; tenThouStart = 10;
            isHunThousands = true; hunThouStart = 9;
            isMillions = true; millStart = 8;
            isTenMillions = true; tenMillStart = 7;
            isHunMillions = true; hunMillStart = 6;
            isBillions = true; billStart = 5;
            isTenBillions = true; tenBillStart = 4;
            isHunBillions = true; hunBillStart = 3;
            isTrillions = true; trillStart = 2;
            isTenTrillions = true; tenTrillStart = 1;
            isHunTrillions = true; hunTrillStart = 0;
        }
    }
}



