public void Select(string gameId) { if (string.IsNullOrEmpty(gameId) || !AllCardGames.ContainsKey(gameId)) { (_, string gameUrl) = CardGame.Decode(gameId); if (!Uri.IsWellFormedUriString(gameUrl, UriKind.Absolute)) { Debug.LogError(SelectionErrorMessage); Messenger.Show(SelectionErrorMessage); } else { StartCoroutine(DownloadCardGame(gameUrl)); } return; } Current = AllCardGames[gameId]; ResetGameScene(); }
private void LookupCardGames() { if (!Directory.Exists(CardGame.GamesDirectoryPath) || Directory.GetDirectories(CardGame.GamesDirectoryPath).Length < 1) { CreateDefaultCardGames(); } foreach (string gameDirectory in Directory.GetDirectories(CardGame.GamesDirectoryPath)) { string gameDirectoryName = gameDirectory.Substring(CardGame.GamesDirectoryPath.Length + 1); (string name, string url)game = CardGame.Decode(gameDirectoryName); if (string.IsNullOrEmpty(name)) { Debug.LogWarning(EmptyNameWarning); } else if (name.Equals(CardGame.DefaultName)) { Debug.LogWarning(DefaultNameWarning); try { Directory.Delete(gameDirectory, true); } catch (Exception ex) { Debug.LogError(DeleteErrorMessage + ex.Message); } } else { CardGame newCardGame = new CardGame(this, game.name, game.url); newCardGame.ReadProperties(); if (!string.IsNullOrEmpty(newCardGame.Error)) { Debug.LogError(LoadErrorMessage + newCardGame.Error); } else { AllCardGames[newCardGame.Id] = newCardGame; } } } }