public static bool[] GetBoolArray(String key) { if (ObscuredPrefs.HasKey(key)) { var bytes = System.Convert.FromBase64String(ObscuredPrefs.GetString(key)); if (bytes.Length < 5) { Debug.LogError("Corrupt preference file for " + key); return(new bool[0]); } if ((ArrayType)bytes[0] != ArrayType.Bool) { Debug.LogError(key + " is not a boolean array"); return(new bool[0]); } Initialize(); // Make a new bytes array that doesn't include the number of entries + identifier (first 5 bytes) and turn that into a BitArray var bytes2 = new byte[bytes.Length - 5]; System.Array.Copy(bytes, 5, bytes2, 0, bytes2.Length); var bits = new BitArray(bytes2); // Get the number of entries from the first 4 bytes after the identifier and resize the BitArray to that length, then convert it to a boolean array bits.Length = ConvertBytesToInt32(bytes); var boolArray = new bool[bits.Count]; bits.CopyTo(boolArray, 0); return(boolArray); } return(new bool[0]); }
void Bua() { if (countBua != 0) { if (!buaClicked) { buaClicked = true; OpenItem(ButtonBua); LockItem(ButtonBinhthuoc); LockItem(ButtonBinhxit); LockItem(ButtonBantay); } else { AllButtonNormal(); } } else { ObscuredPrefs.SetString("item", ButtonBua.name); ShowLayerShop(); } }
public void SaveLevel(int star) { var obj = JsonConvert.DeserializeObject <Levemapmanager>(ObscuredPrefs.GetString("DataMap")); // string levelString = ObscuredPrefs.GetString("level"); //int level = int.Parse(levelString.Substring(5)); int levelMax = ObscuredPrefs.GetInt("levelmax"); int level = ObscuredPrefs.GetInt("level"); if (level > levelMax) { ObscuredPrefs.SetInt("levelmax", level); Debug.Log("levelmax=" + level); } obj.LevelMaps[level - 1].KeyLock = -1; obj.LevelMaps[level].KeyLock = 1; obj.LevelMaps[level - 1].Star = star; var a = JsonConvert.SerializeObject(obj); ObscuredPrefs.SetString("DataMap", a); if (level % 10 == 0) { LayerShare.SetActive(true); } if (!string.IsNullOrEmpty(GetDataFacebook.IDFacebook)) { ObscuredPrefs.SetString("score", gm.score.ToString()); AzureUILeaderboard azure = FindObjectOfType <AzureUILeaderboard>(); if (azure != null) { azure.QueryIdFacebook(GetDataFacebook.IDFacebook, "Level" + level); } } }
public void LoadLevelData() { TextAsset textAsset = Resources.Load("Data/Levels/LevelData") as TextAsset; var serializer = new System.Xml.Serialization.XmlSerializer(typeof(LevelDataCollection)); using (var reader = new System.IO.StringReader(textAsset.text)) { this.levelDataCollection = (LevelDataCollection)serializer.Deserialize(reader); } for (int i = 0; i < levelDataCollection.ListLevelData.Count; i++) { levelDataCollection.ListLevelData [i].LevelIndex = i + 1; } lastLevel = ObscuredPrefs.GetInt("LastLevel", 0); lastLevel = 40; //test totalLevel = levelDataCollection.ListLevelData.Count; levelDataCollectionNormal = DeepClone(levelDataCollection); levelDataCollectionHard = DeepClone(levelDataCollection); GetLevelDataNormal(); GetLevelDataHard(); GetLevelInfo(); if (lastLevel >= totalLevel) { isUnlockedHardLevel = true; } }
public static TimeSpan GetLastSpeedRunTime() { long ticks = ObscuredPrefs.GetLong(kLastSpeedRunTime, long.MaxValue); TimeSpan timeSpan = new TimeSpan(ticks); return(timeSpan); }
public void EndGame() { Asteroid.isPlay = false; endTime = 2f; ScoreCounter.enable = false; if (score > max) { ObscuredPrefs.SetInt("maxScore", score); } StartCoroutine(checkInternetConnection((isConnected) => { if (isConnected) { if (AdsController.allow) { waitMenu.SetActive(true); countDownAnimator.SetTrigger("EnterAnim"); } else { ended = true; } } else { ended = true; } })); explosion.Play(); }
public void CheckEnergyGot() { string lastTimeInGameStr = ObscuredPrefs.GetString("lastTimeInGame", ""); if (lastTimeInGameStr == "") { Energy = MaxEnergy; } else { int lastTimeRemaining = ObscuredPrefs.GetInt("lastTimeRemainingEnergy", 0); DateTime lastTimeInGame = DateTime.ParseExact(lastTimeInGameStr, "yyyy-MM-dd HH:mm:ss", null); DateTime currentDateTime = DateTime.Now; int totalSeconds = (int)(currentDateTime - lastTimeInGame).TotalSeconds; int minute = totalSeconds / 60; int second = totalSeconds % 60; int minuteReduntant = 0; int energyGot = 0; if (minute > 0) { energyGot = minute / minuteFillPerEnergy; minuteReduntant = minute % minuteFillPerEnergy; } Energy += energyGot; timeRemainingCountdownEnergy = (minuteFillPerEnergy * 60) - (minuteReduntant * 60 + second) - ((minuteFillPerEnergy * 60) - lastTimeRemaining); } }
void Update () { timer += Time.deltaTime; if (timer >= delay && reverse == false) { timer = 0f; slider2.value++; } if (timer >= delay && reverse == true) { timer = 0f; slider2.value -= speed; } coin_text.text = coin_score.ToString (); ObscuredPrefs.SetInt ("Score", coin_score); if (slider2.value == 10) { bul.SetActive (false); reverse = true; } if (slider2.value == 0) { bul.SetActive (true); reverse = false; } }
private void QueryIdFacebookCallback(AzureResponse <List <pandafruitfarm> > response) { long score = Convert.ToInt64(ObscuredPrefs.GetString("score")); var list = response.ResponseData; if (list.Count > 0) { foreach (var item in list) { _selectedItem = item; if (item.Score < score) { _selectedItem.Score = score; _selectedItem.IdFacebook = GetDataFacebook.IDFacebook; _selectedItem.Level = "Level" + ObscuredPrefs.GetInt("level"); _selectedItem.Username = GetDataFacebook.UserFacebook; azure.Update <pandafruitfarm>(_selectedItem); } } } else { _selectedItem.Score = score; _selectedItem.IdFacebook = GetDataFacebook.IDFacebook; _selectedItem.Level = "Level" + ObscuredPrefs.GetInt("level"); _selectedItem.Username = GetDataFacebook.UserFacebook; azure.Insert <pandafruitfarm>(_selectedItem); } }
void CreateData() { Levemapmanager l = new Levemapmanager(); for (int i = 0; i < lstLevel.Count; i++) { LevelProperty levelmap = new LevelProperty(); if (i <= level) { levelmap.Stt = i; levelmap.KeyLock = 1; levelmap.Star = 0; } else { levelmap.Stt = i; levelmap.KeyLock = 0; levelmap.Star = 0; } l.LevelMaps.Add(levelmap); } var obj1 = JsonConvert.SerializeObject(l); ObscuredPrefs.SetString("DataMap", obj1); ReadData(); }
void Start() { m_MyAudioSource = GetComponent <AudioSource>(); //Wenn die Musik beim letzten Speichern aus war: if (ObscuredPrefs.GetInt("musicEnabled") == 0) { GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_Play = false; if (GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_MyAudioSource == null) { GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_MyAudioSource = GameObject.Find("MusicPlayer").GetComponent <AudioSource>(); } if (m_MyAudioSource.isPlaying) { GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_MyAudioSource.Stop(); } Debug.Log("Loaded: False!"); } //Wenn die Musik beim letzten Speichern an war: else if (ObscuredPrefs.GetInt("musicEnabled") == 1) { GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_Play = true; if (GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_MyAudioSource == null) { GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_MyAudioSource = GameObject.Find("MusicPlayer").GetComponent <AudioSource>(); } if (!m_MyAudioSource.isPlaying) { GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_MyAudioSource.Play(); } Debug.Log("Loaded: True!"); } }
void Update() { //Damit es nicht dauernd speichert überprüft es hier ob sich der bool actualSettings von m_Play unterscheidet. if (actualSetting != GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_Play) { //Wenn er sich unterscheidet und m_Play false ist wird false (0) gespeichert. if (!GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_Play) { ObscuredPrefs.SetInt("musicEnabled", 0); Debug.Log("Saved: False!"); } //Wenn er sich unterscheidet und m_Play true ist wird true (1) gespeichert. else { ObscuredPrefs.SetInt("musicEnabled", 1); Debug.Log("Saved: True!"); } //Und dann actualSettings wieder an m_Play angepasst. actualSetting = GameObject.Find("MusicPlayer").GetComponent <MusicScript>().m_Play; } //Wenn m_Play true ist die Musik jedoch nicht gespielt wird.... if (m_Play == true && !m_MyAudioSource.isPlaying) { //Wird die Musik gestartet. m_MyAudioSource.Play(); } //Wenn m_Play false ist die Musik jedoch gespielt wird.... if (m_Play == false && m_MyAudioSource.isPlaying) { //Wird die Musik gestoppt. m_MyAudioSource.Stop(); } }
private static void LoadDefaultProgress(GameManager gameManager) { CurrencyManager.SetCurrency(ObscuredPrefs.GetInt(WorldConsts.Currency, 80)); gameManager.PlayerModel.Health = 100f; gameManager.PlayerModel.Hunger = 80f; gameManager.PlayerModel.Thirst = 80; gameManager.PlayerModel.Energy = 90f; gameManager.PlayerModel.Breath = 100f; gameManager.PlayerModel.CurrentBackpack = BackpackType.None; gameManager.PlayerModel.PrepareInventorySlots(); gameManager.IapManager.IsBuyNoAds = ObscuredPrefs.GetBool(WorldConsts.BuyNoAds, false); TOD_Sky.Instance.Cycle.Hour = 7.0f; if (gameManager.CarInteractive != null) { gameManager.CarInteractive.Petrol = 0.5f; } gameManager.PlacementItemsController.AddStartLoot(); gameManager.CurrentTerain = gameManager.Terrain1; //gameManager.Intro.Run(gameManager); //AddTestItems(gameManager); }
public void ReadSavedGame(bool obscured) { if (obscured) { gameData = "Money: " + ObscuredPrefs.GetInt("money") + "\n"; string text = gameData; gameData = text + "Life bar: " + ObscuredPrefs.GetFloat("lifeBar") + "\n"; gameData = gameData + "Player name: " + ObscuredPrefs.GetString("playerName") + "\n"; text = gameData; gameData = text + "bool: " + ObscuredPrefs.GetBool("gameComplete") + "\n"; text = gameData; gameData = text + "long: " + ObscuredPrefs.GetLong("demoLong") + "\n"; text = gameData; gameData = text + "double: " + ObscuredPrefs.GetDouble("demoDouble") + "\n"; byte[] byteArray = ObscuredPrefs.GetByteArray("demoByteArray", 0, 4); text = gameData; gameData = text + "Vector3: " + ObscuredPrefs.GetVector3("demoVector3") + "\n"; text = gameData; gameData = text + "byte[]: {" + byteArray[0] + "," + byteArray[1] + "," + byteArray[2] + "," + byteArray[3] + "}"; } else { gameData = "Money: " + PlayerPrefs.GetInt("money") + "\n"; string text = gameData; gameData = text + "Life bar: " + PlayerPrefs.GetFloat("lifeBar") + "\n"; gameData = gameData + "Player name: " + PlayerPrefs.GetString("playerName"); } }
void Start() { if (ObscuredPrefs.GetString("unique") == "") { ObscuredPrefs.SetString("unique", Md5Sum(System.DateTime.Now + "AKufRTXukcAaiT6hvyxdJ10ac8X2iIqZ")); } playModeCanvas.SetActive(false); isMuted = ObscuredPrefs.GetBool("isMuted"); int max = ObscuredPrefs.GetInt("maxScore"); if (score > 0) { scoreboard.GetComponent <Text>().text = score.ToString() + "\nHIGH SCORE: " + max.ToString(); } else { scoreboard.GetComponent <Text>().text = "HIGH SCORE\n" + max.ToString(); } if (isMuted) { muteButton.sprite = muted; AudioListener.pause = true; } else { muteButton.sprite = soundOn; AudioListener.pause = false; } }
//public UnitData[] GetUnlockUnitAtLevel(int level) //{ // List<UnitData> listUnitUnlock = new List<UnitData>(); // UnitData[] unitsUnlock; // foreach (UnitData unitData in unitDataCollection.ListUnitsData) // { // if (unitData.UnlockAtLevel == level) // { // listUnitUnlock.Add(unitData); // } // } // if (listUnitUnlock.Count > 0) // { // unitsUnlock = new UnitData[listUnitUnlock.Count]; // for (int i = 0; i < listUnitUnlock.Count; i++) // { // unitsUnlock[i] = listUnitUnlock[i]; // } // return unitsUnlock; // } // else // { // return null; // } //} public int[] IncreaseExp(float exp, string unitID) { UnitData unitData = GetUnitDataWithUpgradeByID(unitID); float maxExp = GetMaxExpAtLevel(unitData.Level); int levelIncrease = 0; int[] result = new int[2]; //level bonus-exp while (unitData.Exp + exp >= maxExp) { levelIncrease++; unitData.Level++; exp = exp - (maxExp - unitData.Exp); unitData.Exp = 0; maxExp = GetMaxExpAtLevel(unitData.Level); } unitData.Exp += exp; string firstParam = "Unit_" + unitID + "_Upgrade_"; ObscuredPrefs.SetInt(firstParam + UnitUpgradeType.Level, unitData.Level); ObscuredPrefs.SetFloat(firstParam + UnitUpgradeType.Exp, unitData.Exp); result[0] = levelIncrease; result[1] = (int)exp; // Debug.Log(unitData.Level + " | " + levelIncrease + " | " + unitData.Exp + " | " + exp); LoadUnitUpgradeData(); return(result); }
public void SaveGame(bool obscured) { if (obscured) { ObscuredPrefs.SetInt("money", 1500); ObscuredPrefs.SetFloat("lifeBar", 25.9f); ObscuredPrefs.SetString("playerName", "focus xD"); ObscuredPrefs.SetBool("gameComplete", true); #if !UNITY_FLASH ObscuredPrefs.SetLong("demoLong", 3457657543456775432L); ObscuredPrefs.SetDouble("demoDouble", 345765.1312315678d); #endif ObscuredPrefs.SetByteArray("demoByteArray", new byte[] { 44, 104, 43, 32 }); ObscuredPrefs.SetVector3("demoVector3", new Vector3(123.312f, 453.12345f, 1223f)); Debug.Log("Game saved using ObscuredPrefs. Try to find and change saved data now! ;)"); } else { PlayerPrefs.SetInt("money", 2100); PlayerPrefs.SetFloat("lifeBar", 88.4f); PlayerPrefs.SetString("playerName", "focus :D"); Debug.Log("Game saved with regular PlayerPrefs. Try to find and change saved data now (it's easy)!"); } ObscuredPrefs.Save(); }
void Start() { //Store the current time when it starts currentDate = System.DateTime.Now; var oldTimeString = ObscuredPrefs.GetString("sysString", "10"); if (!string.IsNullOrWhiteSpace(oldTimeString)) { //Grab the old time from the player prefs as a long if (long.TryParse(oldTimeString, out var temp)) { //Convert the old time from binary to a DataTime variable var oldDate = DateTime.FromBinary(temp); var difference = currentDate.Subtract(oldDate); if (difference.TotalHours > Random.Range(4, 5)) { click = true; } else { } } } else { Debug.Log("First start -> No"); } }
public static bool SetStringArray(String key, String[] stringArray) { var bytes = new byte[stringArray.Length + 1]; bytes[0] = System.Convert.ToByte(ArrayType.String); // Identifier Initialize(); // Store the length of each string that's in stringArray, so we can extract the correct strings in GetStringArray for (var i = 0; i < stringArray.Length; i++) { if (stringArray[i] == null) { Debug.LogError("Can't save null entries in the string array when setting " + key); return(false); } if (stringArray[i].Length > 255) { Debug.LogError("Strings cannot be longer than 255 characters when setting " + key); return(false); } bytes[idx++] = (byte)stringArray[i].Length; } try { ObscuredPrefs.SetString(key, System.Convert.ToBase64String(bytes) + "|" + String.Join("", stringArray)); } catch { return(false); } return(true); }
public void ShowLayerGameover(bool playerWon, int star) { if (GameOverMessage != null) { int level = ObscuredPrefs.GetInt("level"); if (playerWon) { // player won... LayerWinAnim.SetTrigger("LayerWinShow"); txtWinLevel.text = level.ToString(); txtWinScore.text = gm.score.ToString(); SaveLevel(star); MusicControll.musicControll.MakeSound(MusicControll.musicControll.winner); } else { // player lost... MusicControll.musicControll.MakeSound(MusicControll.musicControll.gameover); txtFailLevel.text = level.ToString(); txtFailScore.text = gm.score.ToString(); LayerGameOverAnim.SetTrigger("LayerGameOverShow"); } if (admodads.bannerView != null) { admodads.showbanneradmob(); } else { admodads.RequestBanner(); } } return; }
internal PrefsRecord(string originalKey) { key = savedKey = originalKey; ReadValue(); // only string prefs may be obscured if (prefType == PrefsType.String) { Obscured = IsValueObscured(stringValue); if (Obscured) { key = DecryptKey(key); if (obscuredType == ObscuredPrefs.DataType.String) { stringValue = ObscuredPrefs.DecryptStringValue(key, stringValue, DEFAULT_STRING); } else if (obscuredType == ObscuredPrefs.DataType.Int) { intValue = ObscuredPrefs.DecryptIntValue(key, stringValue, DEFAULT_INT); } else if (obscuredType == ObscuredPrefs.DataType.Float) { floatValue = ObscuredPrefs.DecryptFloatValue(key, stringValue, DEFAULT_FLOAT); } } } }
void Start() { UIManager2.coin_score = ObscuredPrefs.GetInt("Score"); if (MainMenu3.chnum == 1) { but1.SetActive(true); } if (MainMenu3.chnum == 2) { but2.SetActive(true); } if (MainMenu3.chnum == 3) { but3.SetActive(true); } if (MainMenu3.chnum == 4) { but4.SetActive(true); } if (MainMenu3.chnum == 5) { but5.SetActive(true); } if (MainMenu3.chnum == 6) { but6.SetActive(true); } }
// Start is called before the first frame update void Start() { if (ObscuredPrefs.GetString("save") == "On") { update.SetActive(true); } }
public void SaveGame(bool obscured) { if (obscured) { ObscuredPrefs.SetString(PREFS_NAME, "obscured focus oO"); ObscuredPrefs.SetInt(PREFS_MONEY, 1500); ObscuredPrefs.SetFloat(PREFS_LIFE_BAR, 25.9f); ObscuredPrefs.SetBool(PREFS_GAME_COMPLETE, true); ObscuredPrefs.SetUInt(PREFS_UINT, 4294967290); ObscuredPrefs.SetLong(PREFS_LONG, 3457657543456775432L); ObscuredPrefs.SetDouble(PREFS_DOUBLE, 345765.1312315678d); ObscuredPrefs.SetRect(PREFS_RECT, new Rect(1, 2, 3, 4)); ObscuredPrefs.SetVector3(PREFS_VECTOR3, new Vector3(123.312f, 453.12345f, 1223f)); ObscuredPrefs.SetByteArray(PREFS_BYTE_ARRAY, new byte[] { 44, 104, 43, 32 }); Debug.Log("Game saved using ObscuredPrefs. Try to find and change saved data now! ;)"); } else { PlayerPrefs.SetString(PREFS_NAME, "focus :D"); PlayerPrefs.SetInt(PREFS_MONEY, 2100); PlayerPrefs.SetFloat(PREFS_LIFE_BAR, 88.4f); Debug.Log("Game saved with regular PlayerPrefs. Try to find and change saved data now (it's easy)!"); } ObscuredPrefs.Save(); }
public void ButtonReset() { PlayerPrefs.DeleteAll(); ObscuredPrefs.DeleteAll(); EventManager.OnResetAll(); }
public static void RemoveData(string key, int amount) { int a = ObscuredPrefs.GetInt(key); a -= amount; ObscuredPrefs.SetInt(key, a); }
public static void UpdateData(string key, int amount) { int a = ObscuredPrefs.GetInt(key); a += amount; ObscuredPrefs.SetInt(key, a); }
void Update() { if (Input.touchCount <= 0) { if (isAttacking) { fingerPanel.SetActive(false); isTouched = false; } else { fingerPanel.SetActive(true); isTouched = false; } } else { float actualDistance = Vector2.Distance(center, Input.GetTouch(0).position); float maxDistance = Screen.height / 4; if (actualDistance < maxDistance) { fingerPanel.SetActive(false); fingerPos = Input.GetTouch(0).position; isTouched = true; ScreenToWorldFingerPos = Camera.main.ScreenToWorldPoint(fingerPos); if (ScreenToWorldFingerPos.x <= 0) { attackingPlant = plant1; } else { attackingPlant = plant2; } ExitCanvas.SetActive(false); } else { fingerPanel.SetActive(true); ExitCanvas.SetActive(true); isTouched = false; } } if (isCollided) { isTouched = false; fingerPanel.SetActive(false); youLosePanel.SetActive(true); if (MenuManager.score > max) { ObscuredPrefs.SetInt("maxScore", MenuManager.score); } } scoreboard.text = MenuManager.score.ToString(); waitTime = timeArray[Random.Range(0, timeArray.Length)]; AdShow(); }
void ReadData() { string dataMap = ObscuredPrefs.GetString("DataMap"); var objdata = JsonConvert.DeserializeObject <Levemapmanager>(dataMap); if (objdata.LevelMaps.Count < totalLevel) { level = objdata.LevelMaps.FindIndex(p => p.KeyLock == 1); ObscuredPrefs.SetString("DataMap", ""); CheckDataMap(); return; } else { for (int i = 0; i < objdata.LevelMaps.Count; i++) { int keylock = objdata.LevelMaps[i].KeyLock; Image[] a = lstLevel[i].GetComponentsInChildren <Image>(); switch (keylock) { case -1: lstLevel[i].GetComponent <Animator>().enabled = false; lstLevel[i].transform.GetChild(0).GetComponent <Button>().enabled = true; a[0].sprite = lstSpriteButton[0]; lstLevel[i].transform.GetChild(0).transform.GetChild(0).GetComponent <Text>().enabled = true; break; case 0: lstLevel[i].GetComponent <Animator>().enabled = false; lstLevel[i].transform.GetChild(0).GetComponent <Button>().enabled = false; a[0].sprite = lstSpriteButton[1]; lstLevel[i].transform.GetChild(0).transform.GetChild(0).GetComponent <Text>().enabled = false; break; case 1: lstLevel[i].GetComponent <Animator>().enabled = true; lstLevel[i].transform.GetChild(0).GetComponent <Button>().enabled = true; a[0].sprite = lstSpriteButton[0]; lstLevel[i].transform.GetChild(0).transform.GetChild(0).GetComponent <Text>().enabled = true; if (count > 1 && i > 0) { Avatar.transform.position = lstLevel[i - 1].transform.position; } else { Avatar.transform.position = lstLevel[0].transform.position; } MoveAvatar(lstLevel[i].transform.position); break; default: break; } } } }
public static void SaveNonConsumableItemPurchaseInfo(UM_InAppProduct product) { #if ATC_SUPPORT_ENABLED ObscuredPrefs.SetInt(PREFS_KEY + product.id, 1); #else PlayerPrefs.SetInt(PREFS_KEY + product.id, 1); #endif }