using GiraffeRoller.scenes;
using GiraffeRoller.ui;
using Otter;

namespace GiraffeRoller
{
    class Shared
    {//all public because i'm reseting them when the level starts. Private vars didn't reset on their own. Not sure how to do that on shared class.
        public static void LevelUpdate(Scene scene)
        {
            Global.cam.followPlayer(Global.MW, Global.MH, Global.PlayerX + 100, Global.PlayerY + 100, Global.PlayerSpeed);
            #region Win Conditions
            //add win conditions here if you want the same win condition on every level... lol
            if (Global.TriggerEnd)
            {
                Global.GAME.RemoveScene();
                Global.GAME.AddScene(new WinScreen());// Add next level here or, where you want to go
            }
            #endregion
            if (Global.IsScreenShake)
                ShakeScreen(scene);
        }//end of shared level update
        public static string RandomBossLaugh()
        {
            switch (Rand.Int(1, 11))//one more than the last case number (so counting the default would be an additional one)
            {
                case 1:
                    return "_bossHa_HaHa";
                case 2:
                    return "_bossLaugh";
                case 3:
                    return "_bossLaugh2";
                case 4:
                    return "_bossLaugh3";
                case 5:
                    return "_bossScarcLaugh";
                case 6:
                    return "_bossOof";
                case 7:
                    return "_bossOh";
                case 8:
                    return "_bossIWantToGoOnTheChair";
                case 9:
                    return "_bossLaugh";
                case 10:
                    return "_bossLaugh2";
                default:
                    return "_bossHa_HaHa";
            }
        }

        public static string RandomFootstep()
        {
            switch (Rand.Int(1, 11))//one more than the last case number (so counting the default would be an additional one)
            {
                case 1:
                    return "_footstep";
                case 2:
                    return "_footstep2";
                case 3:
                    return "_footstep3";
                case 4:
                    return "_footstep4";
                case 5:
                    return "_footstep5";
                case 6:
                    return "_footstep6";
                case 7:
                    return "_footstep7";
                case 8:
                    return "_footstep8";
                case 9:
                    return "_footstep";
                case 10:
                    return "_footstep2";
                default:
                    return "_footstep";
            }
        }

        private static void DisplayText(float x, float y, string text, Color color, Scene scene)
        {
            var a = 0;
            for (var b = 0; b < text.Length; b++)
            {
                scene.Add(new Numbers(x + a, y, text[b].ToString(), color));
                a += 8;
            }
        }

        public static void ChangeAnimTo(string desiredAnimation, Spritemap<string> _spriteMap)
        {
            if (_spriteMap.CurrentAnim != desiredAnimation)
                _spriteMap.Play(desiredAnimation);
        }

        public static void ShakeScreen(Scene scene)
        {
            if (Global.CameraTimer > 0 && Global.Done < 4)
            {
                if (Global.Drection == 1)
                {
                    scene.CameraX += Rand.Int(0, 5);
                    scene.CameraY += Rand.Int(0, 5);
                }
                if (Global.Drection == 2)
                {
                    scene.CameraX -= Rand.Int(0, 5);
                    scene.CameraY += Rand.Int(0, 5);
                }
                if (Global.Drection == 3)
                {
                    scene.CameraX += Rand.Int(0, 5);
                    scene.CameraY -= Rand.Int(0, 5);
                }
                if (Global.Drection == 4)
                {
                    scene.CameraX -= Rand.Int(0, 5);
                    scene.CameraY -= Rand.Int(0, 5);
                }
                Global.CameraTimer--;
            }
            if (Global.CameraTimer <= 0 && Global.Done < 4)
            {
                Global.Drection = Rand.Int(1, 5);
                Global.CameraTimer = 3;
                scene.CameraX = 0;
                scene.CameraY = 0;
                Global.Done++;
            }
            if (Global.Done >= 4)
            {
                scene.CameraX = 0;
                scene.CameraY = 0;
                Global.IsScreenShake = false;
            }
        }
    }
}
