//------------------------------------------------------------------- public void Update() { if ((CurrentState != eClientState.DISCOVER) && (!NetworkManager.singleton.isNetworkActive)) { SetState(eClientState.DISCOVER); } if (Controller != null) { ActionAnimator.SetBool("IsWolf", Controller.IsWolf); ActionAnimator.SetBool("IsDead", Controller.IsDead); ActionAnimator.SetBool("IsReady", Controller.ClientIsReady); ActionAnimator.SetBool("IsInGame", Controller.IsInGame()); } DebugText.gameObject.SetActive(Controller != null); UpdateDebugText(); switch (CurrentState) { case eClientState.DISCOVER: UpdateDiscovery(); break; case eClientState.LOBBY: UpdateLobby(); break; case eClientState.IN_GAME: UpdateInGame(); break; default: break; } }
//------------------------------------------------------------------- public void UpdateInGame() { VirtualNetworkController controller = HopperNetwork.GetMyController(); if (!controller.IsInGame()) { SetState(eClientState.LOBBY); return; } if (controller.IsWolf) { ActionImage.sprite = WolfAction; } else { ActionImage.sprite = BunnyAction; } }
//--------------------------------------------------------------------- void DoAction() { ActionAnimator.SetTrigger("DoAction"); VirtualNetworkController controller = HopperNetwork.GetMyController(); if (controller != null) { controller.DoAction(); if (controller.IsInGame()) { if (controller.IsWolf) { AudioManager.Play(eSoundType.FOX_BITE); } else { AudioManager.Play(eSoundType.BUNNY_LAUGH); } } } }
//------------------------------------------------------------------- public void UpdateDebugText() { if (DebugText == null) { return; } DebugText.gameObject.SetActive(true); VirtualNetworkController controller = HopperNetwork.GetMyController(); if (controller == null) { DebugText.text = "No Controller"; return; } string str = ""; str += "Ready: " + (controller.ClientIsReady ? "Y" : "N") + "\n"; str += "Game: " + (controller.IsInGame() ? "Y" : "N") + "\n"; str += "Wolf: " + (controller.IsWolf ? "Y" : "N") + "\n"; DebugText.text = str; }