Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- using System;
- [System.Serializable]
- public class UpDataShop
- {
- public Text upName;
- public Text upPrise;
- public int Prise;
- public int upModule;
- public int prisePlus;
- public Button But;
- }
- public class GameScript : MonoBehaviour {
- [Header("Стандарт")]
- int score = 0;
- int module = 0;
- int workerCount = 0;
- int workersLvl = 1;
- public Text scoreText;
- [Header("Магазин"), Space(10)]
- public UpDataShop[] Shop;
- public GameObject shopPanel;
- private Save SaveGame = new Save();
- void Awake()
- {
- if (PlayerPrefs.HasKey("Saves"))
- {
- SaveGame = JsonUtility.FromJson<Save>(PlayerPrefs.GetString("Saves"));
- score = SaveGame.scores;
- module = SaveGame.modules;
- workerCount = SaveGame.workerCounts;
- workersLvl = SaveGame.workersLvls;
- for (int i = 0; i < Shop.Length; i++)
- {
- Shop[i].Prise = SaveGame.Prises[i];
- Shop[i].upModule = SaveGame.upModules[i];
- Shop[i].prisePlus = SaveGame.prisePluss[i];
- }
- DateTime dt = new DateTime(SaveGame.Date[0]);
- TimeSpan ts = DateTime.Now - dt;
- }
- }
- void OnApplicationQuit()
- {
- SaveGame.Prises = new int[Shop.Length];
- SaveGame.upModules = new int[Shop.Length];
- SaveGame.prisePluss = new int[Shop.Length];
- for (int i = 0; i < Shop.Length; i++)
- {
- SaveGame.Prises[i] = Shop[i].Prise;
- SaveGame.upModules[i] = Shop[i].upModule;
- SaveGame.prisePluss[i] = Shop[i].prisePlus;
- }
- SaveGame.scores = score;
- SaveGame.modules = module;
- SaveGame.workerCounts = workerCount;
- SaveGame.workersLvls = workersLvl;
- PlayerPrefs.SetString("Saves", JsonUtility.ToJson(SaveGame));
- SaveGame.Date[0] = DateTime.Now.Second;
- }
- }
- [System.Serializable]
- public class Save
- {
- public int scores;
- public int modules;
- public int workerCounts;
- public int workersLvls;
- public int[] Prises;
- public int[] upModules;
- public int[] prisePluss;
- public int[] Date;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement