public void AddRequestToPool(RequestVO request) { request.rid = rid++; queue.Add(request); // SecurePlayerPrefs.SetString("requests", JsonUtility.ToJson(queue)); SecurePlayerPrefs.Save(); }
public async UniTask Init(IProgress <float> progress = null) { RequestVO r = new RequestVO("profile"); Services.network.AddRequestToPool(r); await UniTask.DelayFrame(2); //if the answer is none if (!SecurePlayerPrefs.HasKey("profile")) { //Services.data.game.profiles.timestamp = GameTime.GetTime (); //string json = JsonUtility.ToJson (Services.data.game.profiles); // Debug.Log(json); // PlayerData[] players = JsonUtility.FromJson<PlayerData[]> (json); playerData = new PlayerData(); foreach (PlayerData p in Services.data.game.profiles) { if (this == Services.player && p.tags.Contains("player")) { //playerData = Utils.DeepCopy (p); playerData = Utils.DeepCopyClass(p); break; } else if (this == Services.enemy && p.tags.Contains("enemy")) { playerData = Utils.DeepCopyClass(p); break; } } switch (Services.data.tutorStep) { case 0: playerData.resources = Utils.DeepCopyList(playerData.tutorial0.current); break; case 1: playerData.resources = Utils.DeepCopyList(playerData.tutorial1.current); break; default: break; } // playerData.resources = Utils.DeepCopyList (playerData.t); //SecurePlayerPrefs.SetString ("profile", json); } OnProfileUpdated?.Invoke(); }