using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.Networking; public class DebugSettings : MonoBehaviour { private int money; private int moneys; private GameObject player; private GameObject Player; private GameObject Blayer; private Move move; private int Id; private int C; private List Ach; private Sprite[] US; private Sprite[] BS; private List Skins; private SpriteRenderer SpR; void LoadA() { if (PlayerPrefs.HasKey("HaveA")) { string json = PlayerPrefs.GetString("HaveA"); Ach = JsonUtility.FromJson>(json).List; } } void SaveA() { string json = JsonUtility.ToJson(new Serialization(Ach)); PlayerPrefs.SetString("HaveA", json); PlayerPrefs.Save(); } void LoadS() { if (PlayerPrefs.HasKey("HaveS")) { string json = PlayerPrefs.GetString("HaveS"); Skins = JsonUtility.FromJson>(json).List; } else { Debug.Log(Skins); } } void SaveS() { string json = JsonUtility.ToJson(new Serialization(Skins)); PlayerPrefs.SetString("HaveS", json); PlayerPrefs.Save(); } [System.Serializable] private class Serialization { public List List; public Serialization(List list) { this.List = list; } public List ToList() { return List; } } private void Start() { SpR = GetComponent(); } public void SetMoney(string Smoney) { money = int.Parse(Smoney); } public void AddMoney(string m) { moneys = PlayerPrefs.GetInt(m); moneys += money; PlayerPrefs.SetInt(m, moneys); } public void RemoveMoney(string m) { moneys = PlayerPrefs.GetInt(m); moneys -= money; PlayerPrefs.SetInt(m, moneys); } public void Lock() { DontDestroyOnLoad(gameObject); } public void FindPlayer() { player = GameObject.Find("player"); Player = GameObject.Find("Player"); Blayer = GameObject.Find("BodyPlayer"); move = player.GetComponent(); } public void SetSpeed(string speed) { move.NormalSpeed = int.Parse(speed); } public void SetJump(string jump) { move.jumpforce = int.Parse(jump); } public void SetID(string ID) { Id = int.Parse(ID); } public void GiveAchievement() { LoadA(); Ach.Add(Id); SaveA(); } public void RemoveAchievement() { LoadA(); Ach.Remove(Id); SaveA(); } public void SetSkin() { BS = Blayer.GetComponent().Skin; US = player.GetComponentInChildren().Skin; Blayer.GetComponent().sprite = BS[Id]; Player.GetComponentInChildren().sprite = US[Id]; } public void GiveSkin() { LoadS(); Skins.Add(Id); SaveS(); } public void RemoveSkin() { LoadS(); Skins.Remove(Id); SaveS(); } public void OpenScene() { SceneManager.LoadScene(Id); } public void SetC(string Count) { C = int.Parse(Count); } public void Verif() { PlayerPrefs.SetInt("LevelComplete", C); } public void VerifL() { PlayerPrefs.SetInt("CompleteLeftL", C); } public void VerifC() { PlayerPrefs.SetInt("CompleteCenterL", C); } public void VerifR() { PlayerPrefs.SetInt("CompleteRightL", C); } public void SetDamage() { PlayerPrefs.SetInt("SwordID", C);; } public void SetArm() { PlayerPrefs.SetInt("HeadID", C);; } public void SetHealt() { player.GetComponent().Lives = C; } public void UpdateDataBase() { StartCoroutine(UpdateDB()); } private IEnumerator UpdateDB() { string baseUrl = "http://mc1.live-on.pro:64096/api/levels/"; WWWForm form = new WWWForm(); using (UnityWebRequest www = UnityWebRequest.Post(baseUrl + "updatedb", form)) { yield return www.SendWebRequest(); if (www.result == UnityWebRequest.Result.Success) Debug.Log("База данных обновлена" + www.downloadHandler.text); } } }