private bool ProcessMessage(string message) { if (!string.IsNullOrEmpty(message)) { //Debug.Log(message); try { var typeOfMessage = JsonConvert.DeserializeObject <TypeMessage>(message).Type; switch (typeOfMessage) { case MessageType.TILE: var tileMessage = JsonConvert.DeserializeObject <TileMessage>(message); _grid.HandleTile(tileMessage.tile, false); break; case MessageType.NONE: break; case MessageType.CHARACTER: var characterMessage = JsonConvert.DeserializeObject <CharacterMessage>(message); var character = characterMessage.character as Character; _unitController.HandleCharacter(character); break; case MessageType.SUMMON: var summonMessage = JsonConvert.DeserializeObject <SummonMessage>(message); var storedCharacter = _unitController.GetUnit(summonMessage.ObjectId); if (storedCharacter != null) { SummonQueue.Add(storedCharacter); } break; case MessageType.CHOICE: var choiceMessage = JsonConvert.DeserializeObject <ChoiceMessage>(message); CurrentChoice = new Choice(choiceMessage); NewChoice = true; break; case MessageType.RESOLVE_CHOICE: var resolveChoice = JsonConvert.DeserializeObject <ResolveChoiceMessage>(message); ResolveChoice = true; break; case MessageType.CARD: var drawMessage = JsonConvert.DeserializeObject <CardMessage>(message); _cardController.AddOrUpdateCard(drawMessage.Card); /*_interface.Targets.Add(card.Id, JsonConvert.DeserializeObject<TargetList>(_server.GetTargets( * new ResolveTargetRequest() * { * Target = card.Targets.FirstOrDefault(), * Targets = Array.Empty<string>(), * LastTarget = null * } * ).Result));*/ break; default: throw new ArgumentOutOfRangeException(); } } catch (JsonReaderException e) { Debug.LogException(e, this); Debug.LogError(message); return(false); } } return(true); }