IEnumerator WaitForChangesInner() { bool infinite = true; while (infinite) { if (client.connected && wrapper != null) { wrapper.xayaGameService.WaitForChange(""); GameStateResult actualState = wrapper.xayaGameService.GetCurrentState(); if (actualState != null) { if (actualState.gamestate != null) { GameState state = JsonConvert.DeserializeObject <GameState>(actualState.gamestate); MoveGUIAndGameController.Instance.state = state; MoveGUIAndGameController.Instance.totalBlock = client.GetTotalBlockCount(); var currentBlock = client.xayaService.GetBlock(actualState.blockhash); MoveGUIAndGameController.Instance._sVal = currentBlock.Height; MoveGUIAndGameController.Instance.needsRedraw = true; } else { Debug.LogError("Retuned state is not valid? We had some error with JSON"); } yield return(null); } else { Debug.LogWarning("actualState is null"); infinite = false; yield return(null); } } else { yield return(new WaitForSeconds(0.5f)); } } }
public static Dictionary <State, GameState> CreateStates() { // Create basic states for the game. Dictionary <State, GameState> stateList = new Dictionary <State, GameState> (); GameStateMenu menuState = new GameStateMenu(); GameStatePlay playState = new GameStatePlay(); GameStateResult resultState = new GameStateResult(); GameStateHighScore highScoreState = new GameStateHighScore(); GameStateHighScoreInput highScoreInput = new GameStateHighScoreInput(); stateList.Add(menuState.GetStateType(), menuState); stateList.Add(playState.GetStateType(), playState); stateList.Add(resultState.GetStateType(), resultState); stateList.Add(highScoreInput.GetStateType(), highScoreInput); stateList.Add(highScoreState.GetStateType(), highScoreState); return(stateList); }