StarterDeck.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class StarterDeck : MonoBehaviour
  5. {
  6. public List<StarterDeckData> starterDeckDatas = new List<StarterDeckData>();
  7. public void SetStarterDecks()
  8. {
  9. if (ContinuousController.instance.DeckDatas.Count == 0)
  10. {
  11. foreach (StarterDeckData starterDeckData in starterDeckDatas)
  12. {
  13. starterDeckData.AddDeckData();
  14. }
  15. }
  16. else
  17. {
  18. foreach(StarterDeckData starterDeckData in starterDeckDatas)
  19. {
  20. if(!starterDeckData.HasPlayerPrefs())
  21. {
  22. starterDeckData.AddDeckData();
  23. }
  24. }
  25. }
  26. }
  27. }
  28. [System.Serializable]
  29. public class StarterDeckData
  30. {
  31. public string Key;
  32. public string DeckCode;
  33. public void AddDeckData()
  34. {
  35. string deckCode = ContinuousController.instance.ShuffleDeckCode.GetDeckCode(DeckCode);
  36. ContinuousController.instance.DeckDatas.Add(new DeckData(deckCode));
  37. PlayerPrefs.SetInt(Key, 2);
  38. }
  39. public bool HasPlayerPrefs()
  40. {
  41. if(PlayerPrefs.HasKey(Key))
  42. {
  43. if(PlayerPrefs.GetInt(Key) == 2)
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. }