Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using System;
- using UnityEngine;
- using UnityEngine.UI;
- public class InstagramSkript : MonoBehaviour
- {
- public SympathysUpping sympathysUpping;
- public GameObject MainCamera;
- public Image MainBttn;
- [Header("Инстаграм Маркет")]
- public int[] SkinPrice;
- public Image[] mainSkin;
- public Text[] SkinPriceText;
- private Save sv = new Save();
- private void Awake()
- {
- if(PlayerPrefs.HasKey("SV"))
- {
- sv = JsonUtility.FromJson<Save>(PlayerPrefs.GetString("SV"));
- for (int i = 0; i < SkinPrice[4]; i++)
- {
- SkinPrice[i] = sv.SkinPrice[i];
- }
- }
- }
- private void OnApplicationQuit()
- {
- sv.SkinPrice = new int[4];
- for (int i = 0; i < SkinPrice[4]; i++)
- {
- sv.SkinPrice[i] = SkinPrice[i];
- }
- PlayerPrefs.SetString("SV", JsonUtility.ToJson(sv));
- }
- void Start()
- {
- sympathysUpping = MainCamera.GetComponent<SympathysUpping>();
- }
- public void PressSkin(int index)
- {
- if(sympathysUpping.sympathy >= SkinPrice[index])
- {
- sympathysUpping.sympathy = sympathysUpping.sympathy - SkinPrice[index];
- SkinPrice[index] = 0;
- MainBttn.sprite = mainSkin[index].sprite;
- SkinPriceText[index].text = "Куплено";
- PlayerPrefs.SetInt("SkinPrice", SkinPrice[index]);
- }
- }
- }
- [Serializable]
- public class Save
- {
- public int[] SkinPrice;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement