Пример #1
0
        public static void DebugDraw()
        {
            if (DebugEnabled == false)
            {
                return;
            }

            //FPS counter
            FPSCounter.Draw();

            //Camera info
            Vector2 cameraBasePos = new Vector2(0, 510);

            SpriteRenderer.Instance.DrawText(AssetManager.Instance.TTYDFont, "Camera:", cameraBasePos, Color.White, 0f, Vector2.Zero, 1.2f, .1f);
            SpriteRenderer.Instance.DrawText(AssetManager.Instance.TTYDFont, $"Pos: {Camera.Instance.Position}", cameraBasePos + new Vector2(0, 20), Color.White, 0f, Vector2.Zero, 1.2f, .1f);
            SpriteRenderer.Instance.DrawText(AssetManager.Instance.TTYDFont, $"Rot: {Camera.Instance.Rotation}", cameraBasePos + new Vector2(0, 40), Color.White, 0f, Vector2.Zero, 1.2f, .1f);
            SpriteRenderer.Instance.DrawText(AssetManager.Instance.TTYDFont, $"Zoom: {Camera.Instance.Scale}", cameraBasePos + new Vector2(0, 60), Color.White, 0f, Vector2.Zero, 1.2f, .1f);
        }
Пример #2
0
        public static void DebugDraw()
        {
            if (DebugEnabled == false)
            {
                return;
            }

            //FPS counter
            FPSCounter.Draw();

            //Memory usage
            Vector2 memBasePos = new Vector2(0, 70);

            SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"Managed Mem: {Math.Round(GC.GetTotalMemory(false) / 1024f / 1024f, 2)} MB", memBasePos, Color.White, 0f, Vector2.Zero, 1f, .1f);

            //Camera info
            Vector2 cameraBasePos = new Vector2(0, 510);

            SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, "Camera:", cameraBasePos, Color.White, 0f, Vector2.Zero, 1.2f, .1f);
            SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"Pos: {Camera.Instance.Position}", cameraBasePos + new Vector2(0, 20), Color.White, 0f, Vector2.Zero, 1.2f, .1f);
            SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"Rot: {Camera.Instance.Rotation}", cameraBasePos + new Vector2(0, 40), Color.White, 0f, Vector2.Zero, 1.2f, .1f);
            SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"Zoom: {Camera.Instance.Scale}", cameraBasePos + new Vector2(0, 60), Color.White, 0f, Vector2.Zero, 1.2f, .1f);
        }
Пример #3
0
        public static void DebugUpdate()
        {
            #if DEBUG
            //Toggle debug
            if (Input.GetKey(Keys.LeftControl, DebugKeyboard) && Input.GetKeyDown(Keys.D, DebugKeyboard))
            {
                ToggleDebug();
            }
            #endif

            //Return if debug isn't enabled
            if (DebugEnabled == false)
            {
                if (Time.InGameTimeEnabled == false)
                {
                    Time.ToggleInGameTime(true);
                }
                return;
            }

            //Reset frame advance
            AdvanceNextFrame = false;

            //Debug controls
            if (Input.GetKey(Keys.LeftControl, DebugKeyboard))
            {
                //Toggle pause
                if (Input.GetKeyDown(Keys.P, DebugKeyboard))
                {
                    DebugPaused = !DebugPaused;
                }
                //Toggle frame advance
                else if (Input.GetKeyDown(Keys.OemSemicolon, DebugKeyboard))
                {
                    AdvanceNextFrame = true;
                }
                //Toggle logs
                else if (Input.GetKeyDown(Keys.L, DebugKeyboard))
                {
                    ToggleLogs();
                }
            }

            //Camera controls
            if (Input.GetKey(Keys.LeftShift, DebugKeyboard))
            {
                if (Input.GetKeyDown(Keys.Space, DebugKeyboard))
                {
                    //Reset camera coordinates
                    Camera.Instance.SetTranslation(Vector2.Zero);
                    Camera.Instance.SetRotation(0f);
                    Camera.Instance.SetZoom(1f);
                }
                else
                {
                    Vector2 translation = Vector2.Zero;
                    float   rotation    = 0f;
                    float   zoom        = 0f;

                    //Translation
                    if (Input.GetKey(Keys.Left, DebugKeyboard))
                    {
                        translation.X -= 2;
                    }
                    if (Input.GetKey(Keys.Right, DebugKeyboard))
                    {
                        translation.X += 2;
                    }
                    if (Input.GetKey(Keys.Down, DebugKeyboard))
                    {
                        translation.Y += 2;
                    }
                    if (Input.GetKey(Keys.Up, DebugKeyboard))
                    {
                        translation.Y -= 2;
                    }

                    //Rotation
                    if (Input.GetKey(Keys.OemComma, DebugKeyboard))
                    {
                        rotation -= .1f;
                    }
                    if (Input.GetKey(Keys.OemPeriod, DebugKeyboard))
                    {
                        rotation += .1f;
                    }

                    //Scale
                    if (Input.GetKey(Keys.OemMinus, DebugKeyboard))
                    {
                        zoom -= .1f;
                    }
                    if (Input.GetKey(Keys.OemPlus, DebugKeyboard))
                    {
                        zoom += .1f;
                    }

                    if (translation != Vector2.Zero)
                    {
                        Camera.Instance.Translate(translation);
                    }
                    if (rotation != 0f)
                    {
                        Camera.Instance.Rotate(rotation);
                    }
                    if (zoom != 0f)
                    {
                        Camera.Instance.Zoom(zoom);
                    }
                }
            }

            //Battle Debug
            if (Input.GetKey(Keys.RightShift, DebugKeyboard) == true)
            {
                DebugBattle();
            }

            //Unit Tests
            if (Input.GetKey(Keys.U, DebugKeyboard) == true)
            {
                DebugUnitTests();
            }

            //If a pause is eventually added that can be performed normally, put a check for it in here to
            //prevent the in-game timer from turning on when it shouldn't
            Time.ToggleInGameTime(DebugPaused == false || AdvanceNextFrame == true);

            FPSCounter.Update();
            Input.UpdateInputState(ref DebugKeyboard);
        }
Пример #4
0
        public static void DebugUpdate()
        {
            #if DEBUG
            //Toggle debug
            if (Input.GetKey(Keys.LeftControl, DebugKeyboard) && Input.GetKeyDown(Keys.D, DebugKeyboard))
            {
                ToggleDebug();
            }
            #endif

            //Return if debug isn't enabled
            if (DebugEnabled == false)
            {
                if (Time.InGameTimeEnabled == false)
                {
                    Time.ToggleInGameTime(true);
                }

                //Update the input state if debug is disabled so that the toggle functions properly
                Input.UpdateInputState(ref DebugKeyboard);
                return;
            }

            //Reset frame advance
            AdvanceNextFrame = false;

            //Debug controls
            if (Input.GetKey(Keys.LeftControl, DebugKeyboard))
            {
                //Toggle pause
                if (Input.GetKeyDown(Keys.P, DebugKeyboard))
                {
                    DebugPaused = !DebugPaused;
                }
                //Toggle frame advance
                else if (Input.GetKeyDown(Keys.OemSemicolon, DebugKeyboard))
                {
                    AdvanceNextFrame = true;
                }
                //Toggle logs
                else if (Input.GetKeyDown(Keys.L, DebugKeyboard))
                {
                    ToggleLogs();
                }
                //Take screenshot
                else if (Input.GetKeyDown(Keys.S, DebugKeyboard))
                {
                    TakeScreenshot();
                }
                else if (Input.GetKeyDown(Keys.M, DebugKeyboard))
                {
                    //Log dump
                    DumpLogs();
                }
            }

            //Camera controls
            if (Input.GetKey(Keys.LeftShift, DebugKeyboard))
            {
                if (Input.GetKeyDown(Keys.Space, DebugKeyboard))
                {
                    //Reset camera coordinates
                    Camera.Instance.SetTranslation(Vector2.Zero);
                    Camera.Instance.SetRotation(0f);
                    Camera.Instance.SetZoom(1f);
                }
                else
                {
                    Vector2 translation = Vector2.Zero;
                    float   rotation    = 0f;
                    float   zoom        = 0f;

                    //Translation
                    if (Input.GetKey(Keys.Left, DebugKeyboard))
                    {
                        translation.X -= 2;
                    }
                    if (Input.GetKey(Keys.Right, DebugKeyboard))
                    {
                        translation.X += 2;
                    }
                    if (Input.GetKey(Keys.Down, DebugKeyboard))
                    {
                        translation.Y += 2;
                    }
                    if (Input.GetKey(Keys.Up, DebugKeyboard))
                    {
                        translation.Y -= 2;
                    }

                    //Rotation
                    if (Input.GetKey(Keys.OemComma, DebugKeyboard))
                    {
                        rotation -= .1f;
                    }
                    if (Input.GetKey(Keys.OemPeriod, DebugKeyboard))
                    {
                        rotation += .1f;
                    }

                    //Scale
                    if (Input.GetKey(Keys.OemMinus, DebugKeyboard))
                    {
                        zoom -= .1f;
                    }
                    if (Input.GetKey(Keys.OemPlus, DebugKeyboard))
                    {
                        zoom += .1f;
                    }

                    if (translation != Vector2.Zero)
                    {
                        Camera.Instance.Translate(translation);
                    }
                    if (rotation != 0f)
                    {
                        Camera.Instance.Rotate(rotation);
                    }
                    if (zoom != 0f)
                    {
                        Camera.Instance.Zoom(zoom);
                    }
                }
            }

            //Battle Debug
            if (Input.GetKey(Keys.RightShift, DebugKeyboard) == true)
            {
                DebugBattle();
            }

            //Unit Tests
            if (Input.GetKey(Keys.U, DebugKeyboard) == true)
            {
                DebugUnitTests();
            }

            //Damage Mario
            if (Input.GetKey(Keys.Tab, DebugKeyboard) == true)
            {
                if (Input.GetKeyDown(Keys.H) == true)
                {
                    //Make sure we damage the Shell instead if it's over Mario
                    BattleEntity entity = BattleManager.Instance.GetMario();
                    if (entity.EntityProperties.HasAdditionalProperty(Enumerations.AdditionalProperty.DefendedByEntity) == true)
                    {
                        entity = entity.EntityProperties.GetAdditionalProperty <BattleEntity>(Enumerations.AdditionalProperty.DefendedByEntity);
                    }

                    entity.TakeDamage(Enumerations.Elements.Normal, 1, true);
                }
            }

            //If a pause is eventually added that can be performed normally, put a check for it in here to
            //prevent the in-game timer from turning on when it shouldn't
            Time.ToggleInGameTime(DebugPaused == false || AdvanceNextFrame == true);

            FPSCounter.Update();
            Input.UpdateInputState(ref DebugKeyboard);
        }
Пример #5
0
        public static void DebugUpdate(BattleManager bManager)
        {
            //Toggle debug
            if (Input.GetKey(Keys.LeftControl, DebugKeyboard) && Input.GetKeyDown(Keys.D, DebugKeyboard))
            {
                ToggleDebug(!DebugEnabled);
            }

            //Return if debug isn't enabled
            if (DebugEnabled == false)
            {
                if (Time.InGameTimeEnabled == false)
                {
                    Time.ToggleInGameTime(true);
                }

                //Update the input state if debug is disabled so that the toggle functions properly
                Input.UpdateInputState(ref DebugKeyboard);
                return;
            }

            //Reset frame advance
            AdvanceNextFrame = false;

            //Debug controls
            if (Input.GetKey(Keys.LeftControl, DebugKeyboard))
            {
                //Toggle pause
                if (Input.GetKeyDown(Keys.P, DebugKeyboard))
                {
                    DebugPaused = !DebugPaused;
                }
                //Toggle frame advance
                else if (Input.GetKeyDown(Keys.OemSemicolon, DebugKeyboard))
                {
                    AdvanceNextFrame = true;
                }
                //Toggle logs
                else if (Input.GetKeyDown(Keys.L, DebugKeyboard))
                {
                    ToggleLogs(!LogsEnabled);
                }
                //Take screenshot
                else if (Input.GetKeyDown(Keys.S, DebugKeyboard))
                {
                    TakeScreenshot();
                }
                else if (Input.GetKeyDown(Keys.M, DebugKeyboard))
                {
                    //Log dump
                    DumpLogs();
                }
            }

            //Camera controls
            if (Input.GetKey(Keys.LeftShift, DebugKeyboard))
            {
                if (Input.GetKeyDown(Keys.Space, DebugKeyboard))
                {
                    //Reset camera coordinates
                    Camera.Instance.SetTranslation(Vector2.Zero);
                    Camera.Instance.SetRotation(0f);
                    Camera.Instance.SetZoom(1f);
                }
                else
                {
                    Vector2 translation = Vector2.Zero;
                    float   rotation    = 0f;
                    float   zoom        = 0f;

                    //Translation
                    if (Input.GetKey(Keys.Left, DebugKeyboard))
                    {
                        translation.X -= 2;
                    }
                    if (Input.GetKey(Keys.Right, DebugKeyboard))
                    {
                        translation.X += 2;
                    }
                    if (Input.GetKey(Keys.Down, DebugKeyboard))
                    {
                        translation.Y += 2;
                    }
                    if (Input.GetKey(Keys.Up, DebugKeyboard))
                    {
                        translation.Y -= 2;
                    }

                    //Rotation
                    if (Input.GetKey(Keys.OemComma, DebugKeyboard))
                    {
                        rotation -= .1f;
                    }
                    if (Input.GetKey(Keys.OemPeriod, DebugKeyboard))
                    {
                        rotation += .1f;
                    }

                    //Scale
                    if (Input.GetKey(Keys.OemMinus, DebugKeyboard))
                    {
                        zoom -= .1f;
                    }
                    if (Input.GetKey(Keys.OemPlus, DebugKeyboard))
                    {
                        zoom += .1f;
                    }

                    if (translation != Vector2.Zero)
                    {
                        Camera.Instance.Translate(translation);
                    }
                    if (rotation != 0f)
                    {
                        Camera.Instance.Rotate(rotation);
                    }
                    if (zoom != 0f)
                    {
                        Camera.Instance.Zoom(zoom);
                    }
                }
            }

            //Battle Debug
            if (Input.GetKey(Keys.RightShift, DebugKeyboard) == true)
            {
                DebugBattle(bManager);
            }

            //Unit Tests
            if (Input.GetKey(Keys.U, DebugKeyboard) == true)
            {
                DebugUnitTests();
            }

            if (Input.GetKey(Keys.Tab, DebugKeyboard) == true)
            {
                //Damage Mario
                if (Input.GetKeyDown(Keys.H) == true)
                {
                    //Make sure we damage the Shell instead if it's over Mario
                    BattleEntity entity = bManager.Mario.GetTrueTarget();

                    entity.TakeDamage(Enumerations.Elements.Normal, 1, true);
                }
                //Reload all animations
                //This can break Sequences that rely on animation timings
                else if (Input.GetKeyDown(Keys.R) == true)
                {
                    Debug.Log("Reloading all BattleEntity animations. Things may break if in a Sequence!");

                    List <BattleEntity> entities = new List <BattleEntity>();
                    bManager.GetAllBattleEntities(entities, null);

                    for (int i = 0; i < entities.Count; i++)
                    {
                        entities[i].LoadAnimations();
                    }
                }
                //Reverse flip state of all entities
                else if (Input.GetKeyDown(Keys.F) == true)
                {
                    List <BattleEntity> entities = new List <BattleEntity>();
                    bManager.GetAllBattleEntities(entities, null);

                    for (int i = 0; i < entities.Count; i++)
                    {
                        entities[i].SpriteFlip = !entities[i].SpriteFlip;
                    }
                }
            }

            //If a pause is eventually added that can be performed normally, put a check for it in here to
            //prevent the in-game timer from turning on when it shouldn't
            Time.ToggleInGameTime(DebugPaused == false || AdvanceNextFrame == true);

            FPSCounter.Update();
            Input.UpdateInputState(ref DebugKeyboard);
        }