//Called once per frame, polls for inputs of all kinds void Update() { delay_timer += 1; //Quit with Q if (Input.GetKeyDown(KeyCode.Q)) { print(":)"); System.Diagnostics.Process.GetCurrentProcess().Kill(); } //Option Selection Keys if (Input.GetKeyDown(KeyCode.A)) { Selector.prev_option(); } if (Input.GetKeyDown(KeyCode.D)) { Selector.next_option(); } //Manual Click Key - DON'T DO THIS ON THE GAMEPLAY SCREEN - LEADS TO WEIRD BEHAVIOR if (Input.GetKeyDown(KeyCode.S) && SceneManager.GetActiveScene().name != "Gameplay") { Manual_Click.click(); } //Color Changing Keys if (Input.GetKeyDown(KeyCode.J)) { ColorChange.ChangeColor(0); } if (Input.GetKeyDown(KeyCode.K)) { ColorChange.ChangeColor(1); } if (Input.GetKeyDown(KeyCode.L)) { ColorChange.ChangeColor(2); } //Fuel and Angle Controllers if (Input.GetKey(KeyCode.F)) { GameState.select_fuel(); } else { GameState.unselect_fuel(); } if (Input.GetKey(KeyCode.G)) { GameState.select_angle(); } else { GameState.unselect_angle(); } }
//This function handles the mapping of different Arduino inputs, //noted as arg.Value, into actual function calls for different parts //of the game. private void Serial_OnButtonPressed(object sender, ArduinoEventArg arg) { if (delay_timer >= 2) { //Left Arrow if (arg.Value == 1) { UnityMainThreadDispatcher.Instance().Enqueue(() => Selector.prev_option()); delay_timer = 0; } //Launch-OK Button if (arg.Value == 0) { UnityMainThreadDispatcher.Instance().Enqueue(() => { //If on the gameplay screen, this button acts as the ENTER key if (SceneManager.GetActiveScene().name == "Gameplay") { InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); } //Otherwise it acts as a mouse click else { Manual_Click.click(); } }); delay_timer = 0; } //Right Arrow if (arg.Value == 2) { UnityMainThreadDispatcher.Instance().Enqueue(() => Selector.next_option()); delay_timer = 0; } //Red Rutton if (arg.Value == 3) { UnityMainThreadDispatcher.Instance().Enqueue(() => InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_J)); delay_timer = 0; } //Green Button if (arg.Value == 4) { UnityMainThreadDispatcher.Instance().Enqueue(() => InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_K)); delay_timer = 0; } //Blue Button if (arg.Value == 5) { UnityMainThreadDispatcher.Instance().Enqueue(() => InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_L)); delay_timer = 0; } } }
//Go to the next scene public void NextScene() { //Play the bleeping between screens if (audio1 != null) { audio1.Play(); } float fadeTime = BeginFade(1); System.Threading.Thread.Sleep(Mathf.CeilToInt(fadeTime)); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); Manual_Click.reset(); changeMusic(); }
// Update is called once per frame void Update() { //If the option is not selected, it should be the default width and height if (Selector.get_option() != selection) { gameObject.GetComponent <RectTransform> ().sizeDelta = new Vector2(default_width, default_height); flag = 0; //If the option is selected, it should increase in size by 100 each, but only once } else if (Selector.get_option() == selection && flag == 0) { gameObject.GetComponent <RectTransform> ().sizeDelta = new Vector2(default_width + 100, default_height + 100); Manual_Click.set_name("Button" + selection.ToString()); flag = 1; } }