private void HandleStartGame(string payload) { MatchPayload match = JsonUtility.FromJson <MatchPayload>(payload); loadingController.Hide(); string currentTurnDisplay = ""; string currentTurnPieceDisplay = ""; if (string.IsNullOrEmpty(match.winner) && match.draw == false) { currentTurnDisplay = (match.currentTurnId == LoggedInUser.Instance.GetUserUID()) ? "Your Turn" : "Opponent Turn"; currentTurnPieceDisplay = (match.currentTurnId == match.xOwner) ? "X" : "O"; } else if (!string.IsNullOrEmpty(match.winner)) { currentTurnDisplay = (match.winner == LoggedInUser.Instance.GetUserUID()) ? "You Won!" : "Opponent Won!"; } else { currentTurnDisplay = "It's a draw!"; } turnController.SetState(new TurnState() { CurrentTurn = currentTurnDisplay, CurrentTurnPiece = currentTurnPieceDisplay }); gridController.SetState(new GridState() { bottomRow = match.gameState.bottomRow, middleRow = match.gameState.middleRow, topRow = match.gameState.topRow, currentTurnId = match.currentTurnId, currentTurnPiece = GetCurrentTurnPiece(match) }); if (!string.IsNullOrEmpty(match.winner) || match.draw == true) { gridController.DisablePlacingPiece(); } else if (isYourTurn(match)) { gridController.EnablePlacingPiece(); } else { gridController.DisablePlacingPiece(); } }
void IInitializable.Initialize() { Observable .EveryUpdate() .Where(_ => Input.GetKeyDown(KeyCode.S)) .Subscribe(_ => _controller.Show(SocialGame.Loading.LoadingType.Sample)) .AddTo(_disposable); Observable .EveryUpdate() .Where(_ => Input.GetKeyDown(KeyCode.H)) .Subscribe(_ => _controller.Hide()) .AddTo(_disposable); }
IEnumerator LoadNextScene() { yield return(null); asyncOperation = SceneManager.LoadSceneAsync("MainScene"); asyncOperation.allowSceneActivation = false; loadingController.loadingText.text = "Loading Progress : " + (asyncOperation.progress * 100) + "%"; while (!asyncOperation.isDone) { if (asyncOperation.progress >= 0.89f) { asyncOperation.allowSceneActivation = true; loadingController.Hide(); } yield return(null); } }
IEnumerator LoadNextScene() { yield return(null); asyncOperation = SceneManager.LoadSceneAsync("GameScene"); asyncOperation.allowSceneActivation = false; loadingController.loadingText.text = "Loading Progress : " + (asyncOperation.progress * 100) + "%"; while (!asyncOperation.isDone) { if (asyncOperation.progress >= 0.89f) { loadingController.loadingText.text = "Please Press Space Bar To Continue"; if (Input.GetKeyDown(KeyCode.Space)) { asyncOperation.allowSceneActivation = true; loadingController.Hide(); } } yield return(null); } }