Created
August 9, 2017 20:08
-
-
Save ThomasAunvik/ad9af27e218c2ed43215ad6c63a1e373 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Will keep the number of key taps that have been pressed. | |
/// </summary> | |
private int keyTaps = 0, currentXNames = 0, currentYNames = 1; | |
/// <summary> | |
/// Will launch a method that will write the word "Code" to the computer screen. | |
/// </summary> | |
void KeyTapped() { | |
if(!ComputerMenu.isMenuOpen) { //TODO add ifInMenu equals false. | |
if(!(currentYNames >= computerSettings.yNames && currentXNames == computerSettings.xNames)) { | |
WriteText(!(keyTaps < currentYNames * computerSettings.xNames)); | |
} else if(Input.GetKeyDown(KeyCode.Return)) CompleteCode(); | |
} | |
} | |
/// <summary> | |
/// Writes the text "Code" either in a new line or not | |
/// </summary> | |
/// <param name="newLine">"Code" should be placed on a new line?</param> | |
void WriteText(bool newLine) { | |
string currentText = TextObject.GetComponent<TextMesh>().text; | |
if(!newLine) { | |
currentText = currentText + "Code"; | |
currentXNames++; | |
} else { | |
currentText = currentText + "\nCode"; | |
currentYNames++; | |
currentXNames = 1; | |
} | |
keyTaps++; | |
TextObject.GetComponent<TextMesh>().text = currentText; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment