12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System;
- using UnityEngine;
- using System.Collections;
- public class Costumes : MonoBehaviour
- {
- public static Costumes Instance;
- public CostumeObject[] Items;
- private static Finances.Costumes _curcostume;
- public static Finances.Costumes CurrentCostume
- {
- get
- {
- return _curcostume;
- }
- set
- {
- if (value < 0)
- {
- return;
- }
- if (_curcostume != value)
- {
- _curcostume = value;
- PlayerPrefs.SetInt("CurrentCostume", (int)_curcostume);
- PlayerPrefs.Save();
- }
- }
- }
- // Use this for initialization
- void Start ()
- {
- Instance = this;
- _curcostume = (Finances.Costumes) PlayerPrefs.GetInt("CurrentCostume", 0);
- Equip(CurrentCostume);
- }
-
- // Update is called once per frame
- void Update () {
-
- }
- public static void Equip(Finances.Costumes costume)
- {
- CurrentCostume = costume;
- foreach (var costumeObject in Instance.Items)
- {
- costumeObject.Object.SetActive(costumeObject.Costume == costume);
- }
- }
- [Serializable]
- public class CostumeObject
- {
- public Finances.Costumes Costume;
- public GameObject Object;
- }
- }
|