Costumes.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using UnityEngine;
  3. using System.Collections;
  4. public class Costumes : MonoBehaviour
  5. {
  6. public static Costumes Instance;
  7. public CostumeObject[] Items;
  8. private static Finances.Costumes _curcostume;
  9. public static Finances.Costumes CurrentCostume
  10. {
  11. get
  12. {
  13. return _curcostume;
  14. }
  15. set
  16. {
  17. if (value < 0)
  18. {
  19. return;
  20. }
  21. if (_curcostume != value)
  22. {
  23. _curcostume = value;
  24. PlayerPrefs.SetInt("CurrentCostume", (int)_curcostume);
  25. PlayerPrefs.Save();
  26. }
  27. }
  28. }
  29. // Use this for initialization
  30. void Start ()
  31. {
  32. Instance = this;
  33. _curcostume = (Finances.Costumes) PlayerPrefs.GetInt("CurrentCostume", 0);
  34. Equip(CurrentCostume);
  35. }
  36. // Update is called once per frame
  37. void Update () {
  38. }
  39. public static void Equip(Finances.Costumes costume)
  40. {
  41. CurrentCostume = costume;
  42. foreach (var costumeObject in Instance.Items)
  43. {
  44. costumeObject.Object.SetActive(costumeObject.Costume == costume);
  45. }
  46. }
  47. [Serializable]
  48. public class CostumeObject
  49. {
  50. public Finances.Costumes Costume;
  51. public GameObject Object;
  52. }
  53. }