// Update is called once per frame void Update() { foreach (char c in Input.inputString) { // '\b' for backspace '\n' for enter '\r' for return. rpgtext.keys.AddKeypress(new rpgtext.Key(c)); } if (Input.GetKeyDown(KeyCode.UpArrow)) { rpgtext.keys.AddKeypress(new rpgtext.Key(rpgtext.Key.Type.ARROW_UP)); } if (Input.GetKeyDown(KeyCode.DownArrow)) { rpgtext.keys.AddKeypress(new rpgtext.Key(rpgtext.Key.Type.ARROW_DOWN)); } if (Input.GetKeyDown(KeyCode.LeftArrow)) { rpgtext.keys.AddKeypress(new rpgtext.Key(rpgtext.Key.Type.ARROW_LEFT)); } if (Input.GetKeyDown(KeyCode.RightArrow)) { rpgtext.keys.AddKeypress(new rpgtext.Key(rpgtext.Key.Type.ARROW_RIGHT)); } if (Input.GetKeyDown(KeyCode.Escape)) { rpgtext.keys.AddKeypress(new rpgtext.Key(rpgtext.Key.Type.ESC)); } if (Input.GetKeyDown(KeyCode.Tab)) { rpgtext.keys.AddKeypress(new rpgtext.Key('\t')); } if (runningGame != null) { if (runningGame.ThreadState == ThreadState.Aborted || runningGame.ThreadState == ThreadState.Stopped) { runningGame.Join(); Debug.Log("Thread exited.."); if (threadEx != null) { Debug.LogException(threadEx); threadEx = null; StartGame(); } else { Application.Quit(); } } } Crt.GetGlyphs(glyphs); bool cursorOn; int cursorX; int cursorY; Crt.GetCursorInfo(out cursorOn, out cursorX, out cursorY); Vector3Int tilePos = new Vector3Int(0, 0, 0); for (int y = 0; y < Crt.consoleHeight; ++y) { tilePos.y = Crt.consoleHeight / 2 - y; for (int x = 0; x < Crt.consoleWidth; ++x) { tilePos.x = -Crt.consoleWidth / 2 + x; tilemap.SetTile(tilePos, asciiTiles[glyphs[x, y].c % 256]); tilemap.SetColor(tilePos, CrtColorToColor(glyphs[x, y].color)); background.SetColor(tilePos, CrtColorToColor(glyphs[x, y].bgColor)); } } blinkCounter += Time.deltaTime; bool blinkOn = Mathf.Repeat(blinkCounter, blinkPeriod) > blinkPeriod * 0.5f; if (cursorOn && blinkOn) { cursorSprite.enabled = true; cursorSprite.transform.position = new Vector3( (float)(-Crt.consoleWidth / 2 + cursorX) - 0.5f, (float)((Crt.consoleHeight / 2 - cursorY + 1) + 0.5f) * 1.5f - 0.75f, 0.0f); } else { cursorSprite.enabled = false; } }