Beispiel #1
0
 public void Show(UnityDeck deckToShow, OnNameChangeDelegate nameChangeCallback = null,
                  OnDeckSavedDelegate deckSaveCallback = null, bool overwrite = false)
 {
     Show();
     _currentDeck        = deckToShow ?? new UnityDeck(CardGameManager.Current);
     _nameChangeCallback = nameChangeCallback;
     _deckSaveCallback   = deckSaveCallback;
     _doesAutoOverwrite  = overwrite;
     nameInputField.text = _currentDeck.Name;
     textOutputArea.text = _currentDeck.ToString();
 }
Beispiel #2
0
        private static void SaveToFile(UnityDeck deck, OnDeckSavedDelegate deckSaveCallback = null)
        {
            try
            {
                if (!Directory.Exists(CardGameManager.Current.DecksDirectoryPath))
                {
                    Directory.CreateDirectory(CardGameManager.Current.DecksDirectoryPath);
                }
                File.WriteAllText(deck.FilePath, deck.ToString());
            }
            catch (Exception e)
            {
                Debug.LogError(DeckSaveErrorMessage + e.Message);
            }

            deckSaveCallback?.Invoke(deck);
        }
Beispiel #3
0
        public void ChangeName(string newName)
        {
            if (_nameChangeCallback != null)
            {
                newName = _nameChangeCallback(newName);
            }
            if (!string.IsNullOrEmpty(newName))
            {
                nameInputField.text = newName;
            }
            var deck = new UnityDeck(CardGameManager.Current, newName, CardGameManager.Current.DeckFileType);

            foreach (var card in _currentDeck.Cards)
            {
                deck.Add((UnityCard)card);
            }
            textOutputArea.text = deck.ToString();
        }