using System;
using Otter;

namespace KellysMarvelousAdventure.UI
{
    class SapIndicator : Entity
    {
        private Spritemap<string> _spriteMap;
        
        public SapIndicator(float x, float y)
        {
            X = x; Y = y;
            _spriteMap = new Spritemap<string>(Assets.SAPINDICATOR, 100, 10);
            AddSprites();
            _spriteMap.Play("0");
            Graphic = _spriteMap;
            Layer = -2;
        }

        public override void Update()
        {
            base.Update();
            X = Scene.CameraX + 570;
            Y = Scene.CameraY + 180;
            if (Global.SapCollected == 0) _spriteMap.Play("0");
            if (Global.SapCollected == 1) _spriteMap.Play("1");
            if (Global.SapCollected == 2) _spriteMap.Play("2");
            if (Global.SapCollected == 3) _spriteMap.Play("3");
            if (Global.SapCollected == 4) _spriteMap.Play("4");
            if (Global.SapCollected == 5) _spriteMap.Play("5");
            if (Global.SapCollected == 6) _spriteMap.Play("6");
            if (Global.SapCollected == 7) _spriteMap.Play("7");
            if (Global.SapCollected == 8) _spriteMap.Play("8");
            if (Global.SapCollected == 9) _spriteMap.Play("9");
            if (Global.SapCollected == 10) _spriteMap.Play("10");
            if (Global.SapCollected == 11) _spriteMap.Play("11");
            if (Global.SapCollected == 12) _spriteMap.Play("12");
            if (Global.SapCollected == 13) _spriteMap.Play("13");
            if (Global.SapCollected == 14) _spriteMap.Play("14");
            if (Global.SapCollected == 15) _spriteMap.Play("15");
            if (Global.SapCollected == 16) _spriteMap.Play("16");
            if (Global.SapCollected == 17) _spriteMap.Play("17");
            if (Global.SapCollected == 18) _spriteMap.Play("18");
            if (Global.SapCollected == 19) _spriteMap.Play("19");
            if (Global.SapCollected == 20) _spriteMap.Play("20");
            if (Global.SapCollected == 21) _spriteMap.Play("21");
            if (Global.SapCollected == 22) _spriteMap.Play("22");
            if (Global.SapCollected == 23) _spriteMap.Play("23");
            if (Global.SapCollected == 24) _spriteMap.Play("24");
            if (Global.SapCollected == 25) _spriteMap.Play("25");
            if (Global.SapCollected == 26) _spriteMap.Play("26");
            if (Global.SapCollected == 27) _spriteMap.Play("27");
            if (Global.SapCollected == 28) _spriteMap.Play("28");
            if (Global.SapCollected == 29) _spriteMap.Play("29");
            if (Global.SapCollected == 30) _spriteMap.Play("30");
            if (Global.SapCollected == 31) _spriteMap.Play("31");
            if (Global.SapCollected == 32) _spriteMap.Play("32");
            if (Global.SapCollected == 33) _spriteMap.Play("33");
            if (Global.SapCollected == 34) _spriteMap.Play("34");
            if (Global.SapCollected == 35) _spriteMap.Play("35");
            if (Global.SapCollected == 36) _spriteMap.Play("36");
            if (Global.SapCollected == 37) _spriteMap.Play("37");
            if (Global.SapCollected == 38) _spriteMap.Play("38");
            if (Global.SapCollected == 39) _spriteMap.Play("39");
            if (Global.SapCollected == 40) _spriteMap.Play("40");
            if (Global.SapCollected == 41) _spriteMap.Play("41");
            if (Global.SapCollected == 42) _spriteMap.Play("42");
            if (Global.SapCollected == 43) _spriteMap.Play("43");
            if (Global.SapCollected == 44) _spriteMap.Play("44");
            if (Global.SapCollected == 45) _spriteMap.Play("45");
            if (Global.SapCollected == 46) _spriteMap.Play("46");
            if (Global.SapCollected == 47) _spriteMap.Play("47");
            if (Global.SapCollected == 48) _spriteMap.Play("48");
            if (Global.SapCollected == 49) _spriteMap.Play("49");
            if (Global.SapCollected == 50) _spriteMap.Play("50");
            if (Global.SapCollected == 51) _spriteMap.Play("51");
            if (Global.SapCollected == 52) _spriteMap.Play("52");
            if (Global.SapCollected == 53) _spriteMap.Play("53");
            if (Global.SapCollected == 54) _spriteMap.Play("54");
            if (Global.SapCollected == 55) _spriteMap.Play("55");
            if (Global.SapCollected == 56) _spriteMap.Play("56");
            if (Global.SapCollected == 57) _spriteMap.Play("57");
            if (Global.SapCollected == 58) _spriteMap.Play("58");
            if (Global.SapCollected == 59) _spriteMap.Play("59");
            if (Global.SapCollected == 60) _spriteMap.Play("60");
            if (Global.SapCollected == 61) _spriteMap.Play("61");
            if (Global.SapCollected == 62) _spriteMap.Play("62");
            if (Global.SapCollected == 63) _spriteMap.Play("63");
            if (Global.SapCollected == 64) _spriteMap.Play("64");
            if (Global.SapCollected == 65) _spriteMap.Play("65");
            if (Global.SapCollected == 66) _spriteMap.Play("66");
            if (Global.SapCollected == 67) _spriteMap.Play("67");
            if (Global.SapCollected == 68) _spriteMap.Play("68");
            if (Global.SapCollected == 69) _spriteMap.Play("69");
            if (Global.SapCollected == 70) _spriteMap.Play("70");
            if (Global.SapCollected == 71) _spriteMap.Play("71");
            if (Global.SapCollected == 72) _spriteMap.Play("72");
            if (Global.SapCollected == 73) _spriteMap.Play("73");
            if (Global.SapCollected == 74) _spriteMap.Play("74");
            if (Global.SapCollected == 75) _spriteMap.Play("75");
            if (Global.SapCollected == 76) _spriteMap.Play("76");
            if (Global.SapCollected == 77) _spriteMap.Play("77");
            if (Global.SapCollected == 78) _spriteMap.Play("78");
            if (Global.SapCollected == 79) _spriteMap.Play("79");
            if (Global.SapCollected == 80) _spriteMap.Play("80");
            if (Global.SapCollected == 81) _spriteMap.Play("81");
            if (Global.SapCollected == 82) _spriteMap.Play("82");
            if (Global.SapCollected == 83) _spriteMap.Play("83");
            if (Global.SapCollected == 84) _spriteMap.Play("84");
            if (Global.SapCollected == 85) _spriteMap.Play("85");
            if (Global.SapCollected == 86) _spriteMap.Play("86");
            if (Global.SapCollected == 87) _spriteMap.Play("87");
            if (Global.SapCollected == 88) _spriteMap.Play("88");
            if (Global.SapCollected == 89) _spriteMap.Play("89");
            if (Global.SapCollected == 90) _spriteMap.Play("90");
            if (Global.SapCollected == 91) _spriteMap.Play("91");
            if (Global.SapCollected == 92) _spriteMap.Play("92");
            if (Global.SapCollected == 93) _spriteMap.Play("93");
            if (Global.SapCollected == 94) _spriteMap.Play("94");
            if (Global.SapCollected == 95) _spriteMap.Play("95");
            if (Global.SapCollected == 96) _spriteMap.Play("96");
            if (Global.SapCollected >= 97) { if (_spriteMap.CurrentAnim != "97") _spriteMap.Play("97"); }

            if (_spriteMap.CurrentAnim == "97" && _spriteMap.CurrentFrameIndex == 10)
            {
                Global.SapBombs++;
                Global.SapCollected = 0;
                if (Global.SapBombs < 8)
                    Global.SapBar += Global.SapBar;//this will make it longer to reach the fill.
                if (Global.Increaser > 1)
                    Global.Increaser /= 2;//this will multiply the time to get to it by 2.
                Global.once = true;
                //Console.WriteLine("sapbombs: {0} sapCollected: {1} sapbar: {2} increaser: {3} once: {4}", Global.SapBombs, Global.SapCollected, Global.SapBar, Global.Increaser, Global.once);
                _spriteMap.Play("0");
            }

        }

        private void AddSprites()
        {
            _spriteMap.Add("0", new int[] { 0 });
            _spriteMap.Add("1", new int[] { 1 });
            _spriteMap.Add("2", new int[] { 2 });
            _spriteMap.Add("3", new int[] { 3 });
            _spriteMap.Add("4", new int[] { 4 });
            _spriteMap.Add("5", new int[] { 5 });
            _spriteMap.Add("6", new int[] { 6 });
            _spriteMap.Add("7", new int[] { 7 });
            _spriteMap.Add("8", new int[] { 8 });
            _spriteMap.Add("9", new int[] { 9 });
            _spriteMap.Add("10", new int[] { 10 });
            _spriteMap.Add("11", new int[] { 11 });
            _spriteMap.Add("12", new int[] { 12 });
            _spriteMap.Add("13", new int[] { 13 });
            _spriteMap.Add("14", new int[] { 14 });
            _spriteMap.Add("15", new int[] { 15 });
            _spriteMap.Add("16", new int[] { 16 });
            _spriteMap.Add("17", new int[] { 17 });
            _spriteMap.Add("18", new int[] { 18 });
            _spriteMap.Add("19", new int[] { 19 });
            _spriteMap.Add("20", new int[] { 20 });
            _spriteMap.Add("21", new int[] { 21 });
            _spriteMap.Add("22", new int[] { 22 });
            _spriteMap.Add("23", new int[] { 23 });
            _spriteMap.Add("24", new int[] { 24 });
            _spriteMap.Add("25", new int[] { 25 });
            _spriteMap.Add("26", new int[] { 26 });
            _spriteMap.Add("27", new int[] { 27 });
            _spriteMap.Add("28", new int[] { 28 });
            _spriteMap.Add("29", new int[] { 29 });
            _spriteMap.Add("30", new int[] { 30 });
            _spriteMap.Add("31", new int[] { 31 });
            _spriteMap.Add("32", new int[] { 32 });
            _spriteMap.Add("33", new int[] { 33 });
            _spriteMap.Add("34", new int[] { 34 });
            _spriteMap.Add("35", new int[] { 35 });
            _spriteMap.Add("36", new int[] { 36 });
            _spriteMap.Add("37", new int[] { 37 });
            _spriteMap.Add("38", new int[] { 38 });
            _spriteMap.Add("39", new int[] { 39 });
            _spriteMap.Add("40", new int[] { 40 });
            _spriteMap.Add("41", new int[] { 41 });
            _spriteMap.Add("42", new int[] { 42 });
            _spriteMap.Add("43", new int[] { 43 });
            _spriteMap.Add("44", new int[] { 44 });
            _spriteMap.Add("45", new int[] { 45 });
            _spriteMap.Add("46", new int[] { 46 });
            _spriteMap.Add("47", new int[] { 47 });
            _spriteMap.Add("48", new int[] { 48 });
            _spriteMap.Add("49", new int[] { 49 });
            _spriteMap.Add("50", new int[] { 50 });
            _spriteMap.Add("51", new int[] { 51 });
            _spriteMap.Add("52", new int[] { 52 });
            _spriteMap.Add("53", new int[] { 53 });
            _spriteMap.Add("54", new int[] { 54 });
            _spriteMap.Add("55", new int[] { 55 });
            _spriteMap.Add("56", new int[] { 56 });
            _spriteMap.Add("57", new int[] { 57 });
            _spriteMap.Add("58", new int[] { 58 });
            _spriteMap.Add("59", new int[] { 59 });
            _spriteMap.Add("60", new int[] { 60 });
            _spriteMap.Add("61", new int[] { 61 });
            _spriteMap.Add("62", new int[] { 62 });
            _spriteMap.Add("63", new int[] { 63 });
            _spriteMap.Add("64", new int[] { 64 });
            _spriteMap.Add("65", new int[] { 65 });
            _spriteMap.Add("66", new int[] { 66 });
            _spriteMap.Add("67", new int[] { 67 });
            _spriteMap.Add("68", new int[] { 68 });
            _spriteMap.Add("69", new int[] { 69 });
            _spriteMap.Add("70", new int[] { 70 });
            _spriteMap.Add("71", new int[] { 71 });
            _spriteMap.Add("72", new int[] { 72 });
            _spriteMap.Add("73", new int[] { 73 });
            _spriteMap.Add("74", new int[] { 74 });
            _spriteMap.Add("75", new int[] { 75 });
            _spriteMap.Add("76", new int[] { 76 });
            _spriteMap.Add("77", new int[] { 77 });
            _spriteMap.Add("78", new int[] { 78 });
            _spriteMap.Add("79", new int[] { 79 });
            _spriteMap.Add("80", new int[] { 80 });
            _spriteMap.Add("81", new int[] { 81 });
            _spriteMap.Add("82", new int[] { 82 });
            _spriteMap.Add("83", new int[] { 83 });
            _spriteMap.Add("84", new int[] { 84 });
            _spriteMap.Add("85", new int[] { 85 });
            _spriteMap.Add("86", new int[] { 86 });
            _spriteMap.Add("87", new int[] { 87 });
            _spriteMap.Add("88", new int[] { 88 });
            _spriteMap.Add("89", new int[] { 89 });
            _spriteMap.Add("90", new int[] { 90 });
            _spriteMap.Add("91", new int[] { 91 });
            _spriteMap.Add("92", new int[] { 92 });
            _spriteMap.Add("93", new int[] { 93 });
            _spriteMap.Add("94", new int[] { 94 });
            _spriteMap.Add("95", new int[] { 95 });
            _spriteMap.Add("96", new int[] { 96 });
            _spriteMap.Add("97", new int[] { 97, 98, 99, 97, 98, 99, 97, 98, 99, 97, 98 }, new float[] { 5f, 5f });
        }
    }
}
