using Otter;
using PpbbffttMiningHa.ui.PauseMenu;
using PpbbffttMiningHa.Utility;

namespace PpbbffttMiningHa.entities
{
    class PausePerson : Entity
    {
        public static bool IsJoystickAxisActive = false;
        public PausePerson()
        {
            Group = 100;
        }

        public override void Update()
        {
            base.Update();
            var cn = Global.PausePersonSession.Controller;
            if (!PauseMenuBubble.IsChangingEscape && cn.Button("PPEscape").Pressed)
            {
                if (!Global.IsGamePaused)
                {
                    Scene.PauseGroup(0);
                    //Console.WriteLine("Pause!");
                    //Global.music.Pause();
                    Scene.Add(new PauseMenuBackground(100, 100));
                    Scene.Add(new PauseMenuBubble(Scene.CameraX + 255, Scene.CameraY + 198));
                    SoundManager.PlayRequestedSound("_open");
                }
                else
                {
                    Scene.ResumeGroup(0);
                    //Console.WriteLine("UnPause!");
                    //Global.music.Play();
                    SoundManager.PlayRequestedSound("_close");
                }
                Global.IsGamePaused = !Global.IsGamePaused;//Flip the pause state. (whatever it is flip!)
            }
            if (Global.IsGamePaused)
            {
                //run the menu commands based on this "pause person"'s actions
                //should work.
                if (cn.Button("PPUp").Pressed)
                    SoundManager.PlayRequestedSound("_blip");
                if (cn.Button("PPDown").Pressed)
                    SoundManager.PlayRequestedSound("_blip");
                if (cn.Button("PPLeft").Pressed)
                    SoundManager.PlayRequestedSound("_blip");
                if (cn.Button("PPRight").Pressed)
                    SoundManager.PlayRequestedSound("_blip");
                if (cn.Button("PPFire").Pressed)
                    SoundManager.PlayRequestedSound("_blip");
                if (cn.Button("PPJump").Pressed)
                    SoundManager.PlayRequestedSound("_blip");
                if (cn.Button("PPStart").Pressed)
                    SoundManager.PlayRequestedSound("_tone");
                /*if (cn.Button("PPMute").Pressed)
                    Console.WriteLine("PPMute  pressed");
                if (cn.Button("PPTesting").Pressed)
                    Console.WriteLine("PPTesting  pressed");
                if (cn.Button("PPTesting2").Pressed)
                    Console.WriteLine("PPTesting2  pressed");*/
            }
        }
    }
}
