void Start() { //---------------------------------------------------------------------------------// //---------------------------------------------------------------------------------// // BinaryPrefs works like PlayerPrefs: // BinaryPrefs gets values as fast as PlayerPrefs and sets them 40 times faster. // PLAYER PREFS PlayerPrefs.SetInt("testInt", 5); int playerPrefsInt = PlayerPrefs.GetInt("testInt"); // BINARY PREFS BinaryPrefs.SetInt("testInt", 5); int binaryPrefsInt = BinaryPrefs.GetInt("testInt"); //---------------------------------------------------------------------------------// //---------------------------------------------------------------------------------// // BinaryPrefs handles useful types as: BinaryPrefs.SetBool("testBool", true); BinaryPrefs.SetDouble("testDouble", 2.2); //---------------------------------------------------------------------------------// //---------------------------------------------------------------------------------// // BinaryPrefs handles multi-dimensional array serialization: BinaryPrefs.SetClass("testClass", new TwoDimensionArray() { m_Value = new int[, , ] { { { 1, 2, 3, 4 }, { 4, 5, 6, 4 } }, { { 1, 2, 3, 4 }, { 4, 5, 6, 4 } }, }, }); //---------------------------------------------------------------------------------// //---------------------------------------------------------------------------------// // BinaryPrefs is compatible with Json: BinaryPrefs.SetString("testJson", JsonUtility.ToJson(new DataToJson())); //---------------------------------------------------------------------------------// //---------------------------------------------------------------------------------// // BinaryPrefs comes along with useful tools: BinaryPrefs.HasKey("testJson"); BinaryPrefs.DeleteKey("testJson"); BinaryPrefs.ForceSave(); // Use with caution BinaryPrefs.DeleteAll(); // Use with caution //---------------------------------------------------------------------------------// //---------------------------------------------------------------------------------// }
/// <summary> /// Launch the "Random Selection Animation" in async mode with the list of skin _skins and the result skin _skin /// </summary> /// <param name="_skins"></param> /// <param name="_skin"></param> /// <returns></returns> private async Task LaunchRSAAsync(List <Skin> _skins, Skin _skin) { shop.UpdatePayment(); shopView.EnableInteractivity(false); Queue <Skin> randomSelectionSkins = new Queue <Skin>(); if (_skins.Count > 1) { int nbIteration = (int)Random.Range(numberOfRandomIteration * (1f - coeffRandomIteration), numberOfRandomIteration * (1f + coeffRandomIteration)); Skin skin = null; for (int i = 0; i < nbIteration - 1; i++) { List <Skin> localSkins = new List <Skin>(_skins); localSkins.Remove(skin); skin = localSkins.GetRandomValue(); randomSelectionSkins.Enqueue(skin); } } randomSelectionSkins.Enqueue(_skin); try { while (randomSelectionSkins.Count > 0) { shopView.SelectSkin(randomSelectionSkins.Dequeue()); await Task.Delay(selectionMaxDelay / (randomSelectionSkins.Count + 1)); } skinManager.CollectSkin(_skin); shopView.SelectToggle(_skin); await Task.WhenAny(OnSkinAcquiredInvoker(), Task.Delay(lastFocusDuration)); shopView.SelectSkin(null); shopView.EnableInteractivity(); } catch { skinManager.CollectSkin(_skin); BinaryPrefs.ForceSave(); throw; } }
private void OnDestroy() { LastLoginTime = DateTime.Now; BinaryPrefs.ForceSave(); }