Esempio n. 1
0
    IEnumerator Start()
    {
        // Apparently PixelPerfectCamera takes a couple frames before it starts
        // adjusting the viewport...good stuff
        yield return(null);

        yield return(null);

        _term = TerminalBehaviour.CreateAtScreenPosition("Terminal",
                                                         44, 1, posX, posY, alignX, alignY);
        _term.Print(0, 0, "The quick brown fox jumps over the lazy dog.");

        // Initial alignment fails since WithFont gets called after construction...
        _halfTerm = TerminalBehaviour.CreateAtScreenPosition("HalfTerminal",
                                                             44, 1, posX, posY, alignX, alignY).WithFont("Terminal8x16");
        _halfTerm.transform.position = Camera.main.GetAlignedViewportPosition(
            new float2(0, 1),
            new float2(1, -1),
            _halfTerm.GetWorldSize().xy);
        _halfTerm.transform.position += Vector3.down;
        _halfTerm.Print(0, 0, "The quick brown fox jumps over the lazy dog.");
    }
Esempio n. 2
0
        void Print()
        {
            string vsync = QualitySettings.vSyncCount switch
            {
                1 => "60",
                2 => "30",
                _ => "OFF"
            };

            _term.Resize(_term.Width, _strings.Count + 3);
            Align();
            int y = _term.Size.y - 1;

            for (int i = 0; i < _strings.Count; ++i)
            {
                _term.Print(2, y--, _strings[i]);
            }

            _term.Print(2, y--, $"VSync {vsync} FPS {1F / avg}     ");
            --y;
            if (!string.IsNullOrEmpty(_displayText))
            {
                _term.Print(1, y--, _displayText + "       ");
            }

            //_term.Print(1, y--, "CONTROLS");
            //_term.Print(1, y--, "F1 - Toggle help");
            //_term.Print(1, y--, "LMB + Drag - Place/Remove walls");
            //_term.Print(1, y--, "N - Add noise to the map");
            //_term.Print(1, y--, "C - Clear");
            //_term.Print(1, y--, "Arrow Keys - Resize");
            //_term.Print(1, y--, "RMB - place start/end points");
            //_term.Print(1, y--, "Space - Find Path");
            //_term.Print(1, y--, $"VSync {vsync} FPS {1F / avg}     ");
            //--y;
            //if (!string.IsNullOrEmpty(_displayText))
            //    _term.Print(1, y--, _displayText + "       ");
        }

        void Align()
        {
            float3 p = transform.position;
            float2 viewportPosition = new float2(0, 1);
            float2 align            = new float2(1, -1);
            float2 size             = _term.GetWorldSize().xy;

            p.xy = Camera.main.GetAlignedViewportPosition(viewportPosition, align, size).xy;
            transform.position = p;
        }

        void ToggleVisibility(InputAction.CallbackContext ctx)
        {
            float3 p = transform.position;

            if (p.z == -1)
            {
                p.z = 1;
            }
            else
            {
                p.z = -1;
            }

            transform.position = p;
        }
    }