//Method process information from server private void HandleMessage(string serverMsg) { JObject jsonResponse = new JObject(); bool isResponse = false; try { object objResponse = JsonConvert.DeserializeObject(serverMsg); jsonResponse = JObject.Parse(objResponse.ToString()); isResponse = true; } catch (Exception e) { Debug.Log(e); isResponse = false; } if (isResponse) { var valueRaw = jsonResponse["EventType"]; if (valueRaw == null) { valueRaw = jsonResponse["eventType"]; } if (valueRaw == null) { valueRaw = jsonResponse["errorType"]; } if (valueRaw != null) { switch (valueRaw.ToString()) { case "ChatMessage": chat.AddMessageToHistory(jsonResponse["Username"].ToString(), jsonResponse["Message"].ToString()); break; case "InitialInformation": map.SetRegionsValues(jsonResponse); InfoManager.Instance.armyCollections.SetUnitsCollection(jsonResponse); InfoManager.Instance.armyCollections.SetGeneralsCollection(jsonResponse); InfoManager.Instance.factionsManager.SetFactionInformation(jsonResponse, true); InfoManager.Instance.factionsManager.SetFactionMaintenance(jsonResponse); InfoManager.Instance.factionsManager.SetFactionsWarsStates(jsonResponse, false); clock.GetComponent <StopWatch>().SetRound(jsonResponse); foreach (Faction fac in InfoManager.Instance.factionsManager.factions) { if (fac.player == userID) { InfoManager.Instance.factionsManager.myFaction = fac.name; scrollFaction.text = fac.name; scrollFaction.color = SetScrollFactionColor(fac.name); } } showResources.GetComponent <ShowResources>().UpdateResources(); myFaction = Utils.GetMyFaction(); if (clock.GetComponent <StopWatch>().roundNum == 0) { loadingScreen.SetActive(false); startGame = true; } else { Text showFaction = loadingScreen.transform.Find("Faction").gameObject.GetComponent <Text>(); showFaction.text = "WAIT FOR END OF ROUND" + "\n" + showFaction.text; } this.WinConditionText(); break; case "UpdateInformation": roundUpdatesText.text = ""; canvasManager.GetComponent <PanelsManager>().CloseAllPanels(); clock.GetComponent <StopWatch>().SetRound(jsonResponse); InfoManager.Instance.factionsManager.SetFactionInformation(jsonResponse, false); InfoManager.Instance.factionsManager.SetFactionMaintenance(jsonResponse); InfoManager.Instance.armyCollections.SetGeneralsCollection(jsonResponse); InfoManager.Instance.factionsManager.AddArmies(jsonResponse); InfoManager.Instance.factionsManager.SetFactionsWarsStates(jsonResponse, true); DefineRegionAbleToCreateAndMove(); map.UpdateRegionsOwners(jsonResponse); RoundUpdatesText(); if (!startGame) { loadingScreen.SetActive(false); startGame = true; } break; case "GameUpdatedConn": ShowFaction(jsonResponse); break; case "RoomNotFoundException": Task taskOne = CloseGame("Game not found"); break; case "PlayerGameStarted": Task taskTwo = CloseGame("Player already connected to game"); break; default: print("Response type not found."); break; } } } }