public void PlaySinglePlayer() { sc.SetState(GameState.DETECTING_POSE); mqtt.Connect(GameConstants.DEFAULT_MQTT_TOPIC); mqtt.Publish("startPose"); sc.isSinglePlayer = true; SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); }
public void JoinLobby() { // set this client as guest mqtt.isHost = false; // set nickname mqtt.myNickname = myNicknameJoin.text; // attempt mqtt connection to string in text box if (roomCodeInput.text.Length == 0) { Debug.Log("Join Lobby Error: Null room code"); return; } mqtt.Connect(roomCodeInput.text.ToUpper()); mqtt.Publish("joining," + mqtt.myNickname); Debug.Log("The room code is " + mqtt.MqttTopic); }
// Update is called once per frame void Update() { // Quit game if (Input.GetKeyDown("escape")) { Debug.Log("Quit"); Application.Quit(); } // PoseOK if (Input.GetKeyDown("p")) { if (sc.isSinglePlayer) { mqtt.Publish("poseOK"); } else { mqtt.Publish(mqtt.myNickname + "," + "poseOK"); } } // Turn left if (Input.GetKeyDown("left")) { leftArrowDownTime = Time.time; Debug.Log("Left arrow key down"); } if (Input.GetKeyUp("left")) { // time held down in ms float timeHeld = (int)(1000.0f * (Time.time - leftArrowDownTime)); Debug.Log("Left arrow key up"); Debug.Log(timeHeld); if (sc.isSinglePlayer) { mqtt.Publish("turn,left," + timeHeld); } else { mqtt.Publish(mqtt.myNickname + "," + "turn,left," + timeHeld); } } // Turn right if (Input.GetKeyDown("right")) { rightArrowDownTime = Time.time; Debug.Log("Right arrow key down"); } if (Input.GetKeyUp("right")) { // time held down in ms float timeHeld = (int)(1000.0f * (Time.time - rightArrowDownTime)); Debug.Log("Right arrow key up"); Debug.Log(timeHeld); if (sc.isSinglePlayer) { mqtt.Publish("turn,right," + timeHeld); } else { mqtt.Publish(mqtt.myNickname + "," + "turn,right," + timeHeld); } } // EndButtons if (Input.GetKeyDown("e")) { if (sc.isSinglePlayer) { mqtt.Publish("endButtons"); } else { mqtt.Publish(mqtt.myNickname + "," + "endButtons"); } } // Swing if (Input.GetKeyDown("space")) { spaceDownTime = Time.time; Debug.Log("Space key down"); } if (Input.GetKeyUp("space")) { // time held down in ms float timeHeld = (int)(1000.0f * (Time.time - spaceDownTime)); Debug.Log("Space key up"); Debug.Log(timeHeld); int msToSwingMag = (int)(7000 + (32 - 7) * Mathf.Min(timeHeld, (float)1000)); Debug.Log("Swinging with magnitude:"); Debug.Log(msToSwingMag); if (sc.isSinglePlayer) { mqtt.Publish("classifierData" + "," + msToSwingMag); } else { mqtt.Publish(mqtt.myNickname + "," + "classifierData" + "," + msToSwingMag); } } }
public void WhackBall(string whackVelocityString) { whackVelocity = Convert.ToDouble(whackVelocityString); sc.SetState(GameState.SWINGING); mqtt.Publish("startButtons"); }
private void GoodJob() { //chatBoxManager.SendMessageToChat("You: Good Job!"); mqtt.Publish("newMessage," + mqtt.myNickname + ",Good job"); }