void CastRay(Ray ray) { RaycastHit rhit; GameObject gObjectHit = null; if (Physics.Raycast(ray, out rhit, 1000.0f) && round.getCanSelect()) { UIManager uiManager = (UIManager)GameObject.Find("Managers").GetComponent(typeof(UIManager)); if (round.checkObjective(rhit.transform.gameObject)) { Debug.Log("Correct selection"); StartCoroutine(uiManager.triggerFeedbackPopup(true)); NetworkClientManager clientManager = (NetworkClientManager)GameObject.Find("Managers").GetComponent(typeof(NetworkClientManager)); clientManager.sendWinnerMessageToServer(); StartCoroutine(round.disableSelection()); } else { Debug.Log("Incorrect selection"); StartCoroutine(uiManager.triggerFeedbackPopup(false)); StartCoroutine(round.disableSelection()); } } }
public void OnServerMessage(UnityEngine.Networking.NetworkMessage netMsg) { NetworkInstanceVars json = JsonUtility.FromJson <NetworkInstanceVars>(netMsg.reader.ReadString()); switch (json.messageType) { case "start": Debug.Log("Client Message type: start"); SceneManager.LoadScene("mainScene"); objective = json.objective; round.startRound(objective); break; case "player list": Debug.Log("Client Message type: player list"); clientPlayerList = new List <string>(json.playerListName); uiManager.updatePlayerListUI(clientPlayerList); break; case "winner": Debug.Log("Client Message type: winner: " + json.name); //winner panel show subroutine StartCoroutine(uiManager.showWinnerPanel(json.name)); StartCoroutine(round.disableSelection()); objective = json.objective; round.startRound(objective); Debug.Log("objective: " + objective); break; case "end": Debug.Log("game end"); SceneManager.LoadScene("VictoryScene"); uiManager.setVictoryMessage(json.name); break; default: Debug.Log("unknown message from server type: " + json.messageType); break; } }