private int[] highScoresArray = new int[10]; // Array with ten high scores // Use this for initialization void Start() { //Gets high score array highScoresArray = PlayerPrefsX.GetIntArray("HighScoreArray"); //Gest scores from ScoresCounter class totalPoints.text = ScoresCounter.score.ToString(); //Calculate the total points for the game over screen totalPoints.text = int.Parse(totalPoints.text).ToString(); //Parses points to int score = int.Parse(totalPoints.text); //Checks if the score is higher then the last element in the array if (score > highScoresArray[9]) { for (int i = 0; i < 10; i++) //Loops the array to add a high score { if (score > highScoresArray[i]) //Check if score is higher then the pleace in array that is in { for (int j = 9; j > i; j--) //Scores go down by one in the array { highScoresArray[j] = highScoresArray[j - 1]; }//End of for highScoresArray[i] = score;//Found the pleace in the array break;//Found the pleace so it won't look for more } //End of if } //End of for loop } //End of if PlayerPrefsX.SetIntArray("HighScoreArray", highScoresArray);//Adds result to the high score array }//End of start method
void Start() { highScoresArray = PlayerPrefsX.GetIntArray("HighScoreArray"); gainedPointsText.text = PointsManager.points.ToString(); GameManager = GameObject.Find("GameManager"); extraLifesBonusText.text = (GameManager.GetComponent <CarDurabilityManager>().lifes *everyExtraLifeBonus).ToString(); if ((PlayerCar = GameObject.FindWithTag("Player")) != null) { if (PlayerCar.GetComponent <PlayerCarMovement>().durability == PlayerCar.GetComponent <PlayerCarMovement>().maxDurability) { noCollisionBonusText.text = noCollisionBonus.ToString(); } } altogetherPointsText.text = (int.Parse(gainedPointsText.text) + int.Parse(extraLifesBonusText.text) + int.Parse(noCollisionBonusText.text)).ToString(); score = int.Parse(altogetherPointsText.text); if (score > highScoresArray[9]) { for (int i = 0; i < 10; i++) { if (score > highScoresArray[i]) { for (int j = 9; j > i; j--) { highScoresArray[j] = highScoresArray[j - 1]; } highScoresArray[i] = score; break; } } } PlayerPrefsX.SetIntArray("HighScoreArray", highScoresArray); }
private void addSort() { int index = 0; int temp = 0; int temp2 = currentScore; string tempS1 = ""; string tempS2 = nameInput.text; for (int i = userArray.Length - 1; i >= 0; i--) { if (temp2 < scoreArray [i]) { break; } index = i; } for (int i = index; i < userArray.Length; i++) { temp = scoreArray [i]; tempS1 = userArray [i]; scoreArray [i] = temp2; userArray [i] = tempS2; temp2 = temp; tempS2 = tempS1; } PlayerPrefsX.SetStringArray("userArray", userArray); PlayerPrefsX.SetIntArray("scoreArray", scoreArray); }
public static void startNewGame() { int[] area = { 0, 1, 2 }; int rand = (int)Random.Range(0, 2); int temp; for (int j = 0; j < 10; j++) { for (int i = 2; i > 0; i--) { rand = (int)Random.Range(0, 2); temp = area[rand]; area[rand] = area[i]; area[i] = temp; } } int area1 = (int)Random.Range((int)1, (int)11); int area2 = (int)Random.Range((int)1, (int)11); int area3 = (int)Random.Range((int)1, (int)11); bool[] doneArea = { false, false, false }; PlayerPrefsX.SetIntArray("areaGame", area); PlayerPrefs.SetInt("area1Key", area1); PlayerPrefs.SetInt("area2Key", area2); PlayerPrefs.SetInt("area3Key", area3); PlayerPrefsX.SetBoolArray("areaDone", doneArea); PlayerPrefsX.SetBool("saved", false); }
void Start() { /* for(var i =0;i<highscore.Length;i++){ * if(setScore.score>highscore[i]){ * if(i>0 &&highscore[i-1]>=setScore.score){ * break; * } * * highscore[i] = setScore.score; * break; * } * } */ if (!highscore.Contains(Scoring.Score)) { for (var i = 0; i < highscore.Length; i++) { newHigh[i] = highscore[i]; } newHigh[5] = Scoring.Score; Array.Sort(newHigh, (x, y) => y.CompareTo(x)); Array.Resize(ref newHigh, newHigh.Length - 1); PlayerPrefsX.SetIntArray("highscores", newHigh); } }
// resets all required persistent data for a new game public void ResetData() { int[] resetArray = new int[4]; PlayerPrefsX.SetIntArray(Convert.ToString(SavedVariables.sonicSlashUpgrades), resetArray); PlayerPrefsX.SetIntArray(Convert.ToString(SavedVariables.whirlingTidesUpgrades), resetArray); PlayerPrefsX.SetIntArray(Convert.ToString(SavedVariables.divineProtectionUpgrades), resetArray); PlayerPrefsX.SetIntArray(Convert.ToString(SavedVariables.illuminationUpgrades), resetArray); // done tutorial PlayerPrefs.SetString(Convert.ToString(SavedVariables.canLoadGame), "False"); PlayerPrefs.SetInt(Convert.ToString(SavedVariables.savedPower), 0); PlayerPrefs.SetInt(Convert.ToString(SavedVariables.savedShadowsTotal), 0); PlayerPrefs.SetInt(Convert.ToString(SavedVariables.savedSkillPoints), 0); PlayerPrefs.SetInt(Convert.ToString(SavedVariables.savedDimension), 1); PlayerPrefs.SetInt(Convert.ToString(SavedVariables.savedRealm), 1); dimension = PlayerPrefs.GetInt(Convert.ToString(SavedVariables.savedDimension)); realm = PlayerPrefs.GetInt(Convert.ToString(SavedVariables.savedRealm)); skillPoints = PlayerPrefs.GetInt(Convert.ToString(SavedVariables.savedSkillPoints)); shadowsDefeated = PlayerPrefs.GetInt(Convert.ToString(SavedVariables.savedShadowsTotal)); power = PlayerPrefs.GetInt(Convert.ToString(SavedVariables.savedPower)); // PlayerPrefs.SetFloat("topPower", 0); // PlayerPrefs.SetFloat("topDimension", 1); // PlayerPrefs.SetFloat("topShadowsDefeated", 0); }
public void GiveStars(float _currentTime) { GameAnalytics.NewProgressionEvent(GAProgressionStatus.Complete, mWinCondition.level.ToString(), (int)_currentTime);//Sends a event to GameAnalytics with the time the user needed to complete the level if (_currentTime < time3Stars) { Singleton.instance.Stars[mWinCondition.level - 1] = 3; print("Three Stars"); mWinCondition.CoinsMgr(Random.Range(20, 31)); StartCoroutine(UnlockingStars(3)); } else if (_currentTime < time2Stars) { if (Singleton.instance.Stars[mWinCondition.level - 1] < 2) { Singleton.instance.Stars[mWinCondition.level - 1] = 2; } print("Two Stars"); mWinCondition.CoinsMgr(Random.Range(10, 21)); StartCoroutine(UnlockingStars(2)); } else if (_currentTime > time2Stars) { if (Singleton.instance.Stars[mWinCondition.level - 1] < 1) { Singleton.instance.Stars[mWinCondition.level - 1] = 1; } print("One Star"); mWinCondition.CoinsMgr(Random.Range(1, 11)); StartCoroutine(UnlockingStars(1)); } PlayerPrefsX.SetIntArray("Stars", Singleton.instance.Stars); }
//These are save and load functions for the items class. //This is not currently in use but will be use in the future. public void SaveValues() { foreach (var item in m_items) { PlayerPrefs.SetInt("NumberOfItems", item.m_amountOfItemsForPlayer); PlayerPrefs.SetFloat("Durability", (float)item.durability); PlayerPrefs.SetFloat("ValueofItem", (float)item.valueOfItem); PlayerPrefs.SetString("ItemName " + item.name, item.name); PlayerPrefs.SetString("ItemDescription", item.description); PlayerPrefsX.SetBool("IsDurability", item.isDurability); PlayerPrefsX.SetBool("IsItemStatic", item.staticItem); PlayerPrefsX.SetBool("ValueIsPercentage", item.isAPercentage); PlayerPrefsX.SetBool("IsStackable", item.isStackable); //Saving only one of the arrays as they are all the same but //will be converted to the same number after it is loaded PlayerPrefsX.SetStringArray("StatusNames", item.statusNames[0].ToArray()); PlayerPrefsX.SetStringArray("TypesNames", item.typesNames[0].ToArray()); PlayerPrefsX.SetStringArray("StatsNames", item.allStatsEffected[0].ToArray()); //_______________________________________________________________________________ PlayerPrefsX.SetIntArray("StatsIndex", item.m_statIndex.ToArray()); PlayerPrefsX.SetIntArray("TypeIndex", item.typesindex.ToArray()); PlayerPrefsX.SetIntArray("StatusIndex", item.statusIndex.ToArray()); PlayerPrefs.Save(); } }
void Start() { this.gameObject.GetComponent <Text>().text = Points.points.ToString(); highScoresArray = PlayerPrefsX.GetIntArray("HighScoreArray"); score = Points.points; if (score > highScoresArray[9]) { for (int i = 0; i < highScoresArray.Length; i++) { if (score > highScoresArray[i]) { for (int j = highScoresArray.Length - 1; j > i; j--) { highScoresArray[j] = highScoresArray[j - 1]; } highScoresArray[i] = score; break; } } } PlayerPrefsX.SetIntArray("HighScoreArray", highScoresArray); }
public void End(string name) { if (testNetwork.isConnect) { myParse.InsertScore(combo, name); GameObject.Find("Preload").GetComponent <Preload>().FirstInStartScene(); Application.LoadLevel("Start"); } int[] scores = PlayerPrefsX.GetIntArray("scores"); string[] names = PlayerPrefsX.GetStringArray("names"); scores[10] = combo; names[10] = name; for (int i = 0; i < scores.Length; i++) { for (int j = i; j < scores.Length; j++) { if (scores[j] > scores[i]) { int temp = scores[j]; scores[j] = scores[i]; scores[i] = temp; string temp1 = names[j]; names[j] = names[i]; names[i] = temp1; } } } PlayerPrefsX.SetIntArray("scores", scores); PlayerPrefsX.SetStringArray("names", names); }
/// <summary> /// スコアの保存 /// </summary> void SaveHighScore() { // スコアを監視 if (creatJengaTower._layerCount <= layerScores[layerScores.Length - 1]) { return; } if (creatJengaTower._replaceCount <= pieceScores[pieceScores.Length - 1]) { return; } // ハイスコアが出た場合配列を更新 layerScores[0] = creatJengaTower._layerCount; pieceScores[0] = creatJengaTower._replaceCount; for (int i = 1; i < layerScores.Length - 1; i++) { layerScores[i] = layerScores[i + 1]; pieceScores[i] = pieceScores[i + 1]; } var unsortedScores = layerScores; Array.Sort(layerScores, (a, b) => b - a); // 配列を保存 PlayerPrefsX.SetIntArray("LayerScores", layerScores); PlayerPrefsX.SetIntArray("PieceScores", pieceScores); PlayerPrefs.Save(); }
private void OnTriggerStay(Collider other) { if (other.gameObject.tag == "AttackerBody" && !OnceAddScene) { if (LoadName != "") { // PlayerPrefsx.("AttackerSpeed",other.gameObject.GetComponentInParent<CharacterData>().Speed); PlayerPrefsX.SetIntArray("DefenderData", GetComponent <CharacterData>().CharData); PlayerPrefsX.SetIntArray("AttackerData", other.gameObject.GetComponentInParent <CharacterData>().CharData); GameManagerAll._instance.AttackerData = GetComponent <CharacterData>().CharData; GameManagerAll._instance.DefenderData = other.gameObject.GetComponentInParent <CharacterData>().CharData; // SceneManage.instace.load(LoadName); // SceneManage.instace.UnLoad("try"); } if (UnloadName != "") { // StartCoroutine(DelayTime()); } OnceAddScene = true; } }
//When the scene is disabled for any of the mnay reasons a scene is disabled, it remembers everything it should so when the game is loaded again it has the correct data protected virtual void OnDisable() { tileID = id.ToArray(); PlayerPrefsX.SetIntArray(" " + character.gameFile + "TilesToRemove", tileID); PlayerPrefs.SetInt(" " + character.gameFile + "FacingLeft", character.isFacingLeft ? 1 : 0); PlayerPrefs.SetString(" " + character.gameFile + "LoadGame", SceneManager.GetActiveScene().name); }
void Start() { if (PlayerPrefsX.GetIntArray("TablicaWynikow", 0, 10)[0] == 0) { int[] TablicaWynikow = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; PlayerPrefsX.SetIntArray("TablicaWynikow", TablicaWynikow); } if (PlayerPrefsX.GetStringArray("TablicaWynikowNick", "", 10)[0] == "") { string[] TablicaWynikowNick = new string[10] { "", "", "", "", "", "", "", "", "", "" }; PlayerPrefsX.SetStringArray("TablicaWynikowNick", TablicaWynikowNick); } scena = SceneManager.GetActiveScene(); if (scena.name != naz) { menuInGame.SetActive(false); } }
public void RemoveCard() { int[] original = PlayerPrefsX.GetIntArray("PlayerCardsIDs"); if (original.Length > 5) { List <int> iList = new List <int> (); for (int i = 0; i < original.Length; i++) { iList.Add(original [i]); } iList.Remove(lastCard.GetComponent <CardScript> ().CardID); int[] finalArray = new int[iList.Count]; int x = 0; foreach (int i in iList) { finalArray [x] = i; x++; } PlayerPrefsX.SetIntArray("PlayerCardsIDs", finalArray); DeactiveCard(); Destroy(lastCard.gameObject); this.gameObject.SetActive(false); } }
private void Update() { float playerHeight = player.transform.position.y; //Oyuncunun Yüksekliği if (playerHeight > maxHeight) //Oyuncu Yüksekliği oyuncunun oyun içinde ulaştığı max yükseklikten büyükse { maxHeight = playerHeight; text.text = "Score: " + Mathf.RoundToInt(maxHeight * 10.0f); //Sağ üst kösedeki skoru güncelle } else if (playerHeight < maxHeight - 20.0f && isFall == false) //Oyuncu Max height den 20 birim aşağı düştüyse { isFall = true; float MaxScore = maxHeight * 10; if (MaxScore > PlayerPrefs.GetFloat("MaxScore", 0)) //Skor Kırıldıysa { Debug.Log("MaxScore:" + MaxScore + " Saved"); PlayerPrefs.SetFloat("MaxScore", MaxScore); } else { Debug.Log("MaxScore Kırılamadı Max Skor:" + PlayerPrefs.GetFloat("MaxScore", 0) + " , Sizin Skor:" + MaxScore); } int[] testarray = new int[] { 1, 3, 5, 7, 9 }; PlayerPrefsX.SetIntArray("Numbers", testarray); } edgeMove(); }
public void ActiveCard() { lastCard.GetComponent <CardScript> ().SetActiveButton(); int[] original = PlayerPrefsX.GetIntArray("SelectedCardsIDs"); List <int> iList = new List <int>(); for (int i = 0; i < original.Length; i++) { iList.Add(original [i]); } iList.Add(lastCard.GetComponent <CardScript> ().CardID); int[] finalArray = new int[iList.Count]; int x = 0; foreach (int i in iList) { finalArray [x] = i; x++; } // int[] finalArray = new int[original.Length + 1 ]; // // for(int i = 0; i < original.Length; i ++ ) { // finalArray[i] = original[i]; // } // finalArray[finalArray.Length - 1] = lastCard.GetComponent<CardScript>().CardID; PlayerPrefsX.SetIntArray("SelectedCardsIDs", finalArray); }
public void UnlockLevel(string nameWorld, int indexLevel) { var tempListLockLevel = PlayerPrefsX.GetIntArray("levelLocked" + nameWorld).ToList(); tempListLockLevel.Remove(indexLevel); PlayerPrefsX.SetIntArray("levelLocked" + nameWorld, tempListLockLevel.ToArray()); }
public void DeactiveCard() { lastCard.GetComponent <CardScript> ().SetDesativeButton(); int[] original = PlayerPrefsX.GetIntArray("SelectedCardsIDs"); List <int> iList = new List <int>(); for (int i = 0; i < original.Length; i++) { iList.Add(original [i]); } iList.Remove(lastCard.GetComponent <CardScript> ().CardID); int[] finalArray = new int[iList.Count]; int x = 0; foreach (int i in iList) { finalArray [x] = i; x++; } PlayerPrefsX.SetIntArray("SelectedCardsIDs", finalArray); }
public void EndGame() { bool newHighScore = false; int tempScore = 0; int nextScore = 0; highScores = PlayerPrefsX.GetIntArray("scores"); PlayerPrefs.SetInt("orderInScore", 99); for (int i = 0; i < highScores.Length; i++) { if (newHighScore == false) { if (MyScore >= highScores [i]) { newHighScore = true; tempScore = highScores [i]; highScores [i] = MyScore; PlayerPrefs.SetInt("orderInScore", i); } } else { nextScore = highScores [i]; highScores [i] = tempScore; tempScore = nextScore; } } PlayerPrefsX.SetIntArray("scores", highScores); }
/// <summary> /// Saves the player's recent score so it can be displayed in the end /// screen. Also checks if the score should be in the player's top five /// scores. /// </summary> public void SaveScore() { // Save recent score PlayerPrefs.SetInt(scoreKey, int.Parse(scoreDisplay.text)); int recentScore = PlayerPrefs.GetInt(scoreKey); List <int> highscores = new List <int>(PlayerPrefsX.GetIntArray(highscoresKey, 0, 5)); // Check if recent score has beaten any previous scores for (int i = 0; i < highscores.Count; i++) { if (recentScore > highscores[i]) { highscores.Insert(i, recentScore); break; } } // Remove any scores not in the top five for (int i = 5; i < highscores.Count;) { highscores.RemoveAt(maxNumScores); } // Save list of high scores PlayerPrefsX.SetIntArray(highscoresKey, highscores.ToArray()); }
private void InitPrefs(bool reset = false) { bool [] levelsAvailable = PlayerPrefsX.GetBoolArray("levelsAvalable"); if (levelsAvailable.Length == 0 || reset) { levelsAvailable = new bool[maxLevels]; bool [] levelsCompleted = new bool[maxLevels]; bool [] levelsVisited = new bool[maxLevels]; int [] levelsStars = new int[maxLevels]; for (int i = 0; i < maxLevels; i++) { levelsAvailable[i] = (i == 0); levelsCompleted[i] = false; levelsVisited[i] = false; levelsStars[i] = 0; } PlayerPrefsX.SetBoolArray("levelsAvalable", levelsAvailable); PlayerPrefsX.SetBoolArray("levelsCompleted", levelsCompleted); PlayerPrefsX.SetBoolArray("levelsVisited", levelsVisited); PlayerPrefsX.SetIntArray("levelsStars", levelsStars); PlayerPrefs.SetInt("currentLevel", 0); } if (!PlayerPrefs.HasKey("currentLevel")) { PlayerPrefs.SetInt("currentLevel", 0); } }
public void Yes1000() { if (bitwallet.playerBitWallet >= 1000) { isunlocked = true; bitwallet.playerBitWallet = bitwallet.playerBitWallet - 1000; PlayerPrefs.SetInt("BitWallet", bitwallet.playerBitWallet); bit1000.gameObject.SetActive(false); enoughBits.gameObject.SetActive(true); unlocknumber = PlayerPrefs.GetInt("CharacterUnlock"); characterManager.characterAcquired[unlocknumber] = unlocknumber; PlayerPrefsX.SetIntArray("BitBotsUnlocked", characterManager.characterAcquired); //Clear Data /*for(int i = 1; i <= 42; i++){ * * characterManager.characterAcquiredlist[i] = 0; * PlayerPrefsX.SetIntArray("Bots", characterManager.characterAcquiredlist); * * }*/ } else { isunlocked = false; bit1000.gameObject.SetActive(false); not_enough_bits.gameObject.SetActive(true); } }
// Returns true if the arrow to start the next level has to be canceled public bool SetStars(int starsNum, int level) { MenuManager.Instance._countUseGame = 1; PlayerPrefs.SetInt("CountOpenGame", MenuManager.Instance._countUseGame); if (starsNum > StarsForLevel[level - 1]) { _starsCollected = _starsCollected - StarsForLevel[level - 1] + starsNum; PlayerPrefs.SetInt("StarsCollected", _starsCollected); StarsText.text = "" + _starsCollected; StarsForLevel[level - 1] = starsNum; for (int i = 0; i < StarsForLevel.Length; i++) { PlayerPrefsX.SetIntArray("StarsForLevels", StarsForLevel); } LevelStars[starsNum - 1].SetActive(true); if (_starsCollected == 21) { UnlockNewLevel(7); return(false); } if (level == 7) { return(true); } } return(false); }
// Use this for initialization void Start() { temp = new int[10]; Camera.main.gameObject.GetComponent <AudioSource> ().loop = true; Camera.main.gameObject.GetComponent <AudioSource> ().clip = bgMusic; Camera.main.gameObject.GetComponent <AudioSource> ().Play(); for (int i = 0; i < 10; i++) { temp[i] = Random.Range(1, 22); } if (PlayerPrefsX.GetIntArray("PlayerCardsIDs").Length <= 0) { PlayerPrefsX.SetIntArray("PlayerCardsIDs", temp); if (temp.Length < 15) { PlayerPrefsX.SetIntArray("SelectedCardsIDs", temp); } Debug.Log(PlayerPrefsX.GetIntArray("SelectedCardsIDs").Length); } else { if (PlayerPrefsX.GetIntArray("PlayerCardsIDs").Length > 0 || PlayerPrefsX.GetIntArray("PlayerCardsIDs").Length <= 15) { PlayerPrefsX.SetIntArray("SelectedCardsIDs", PlayerPrefsX.GetIntArray("PlayerCardsIDs")); } temp = empty; } PlayerPrefs.SetString("Tutorial", "True"); }
public void ModifyFilterSettings() { if (!initialised) { return; } settingsList.Clear(); foreach (Transform child in transform) { if (child.gameObject.GetComponent <Toggle>().isOn) { settingsList.AddRange(child.gameObject.GetComponent <EntitiesList>().codesList); PlayerPrefs.SetInt(child.name, 1); Debug.Log("setting " + child.name + " to active"); } else { PlayerPrefs.SetInt(child.name, 0); Debug.Log("setting " + child.name + " to inactive"); } } int[] settingsArray = settingsList.ToArray(); PlayerPrefsX.SetIntArray("EntitiesCodes", settingsArray); Debug.Log(settingsArray.Length); }
public void DeactiveCard() { if (PlayerPrefsX.GetIntArray("SelectedCardsIDs").Length > 15) // VERIFICA SE TEM PELO MENOS 15 CARTAS SELECIONADAS { activebutton.sprite = activeFalse; isactivebutton = false; int[] original = PlayerPrefsX.GetIntArray("SelectedCardsIDs"); List <int> iList = new List <int> (); for (int i = 0; i < original.Length; i++) { iList.Add(original [i]); } iList.Remove(CardID); int[] finalArray = new int[iList.Count]; int x = 0; foreach (int i in iList) { finalArray [x] = i; x++; } PlayerPrefsX.SetIntArray("SelectedCardsIDs", finalArray); } }
public void DoAction() { movementScript.KillMovement(); movementScript.enabled = false; endLevelCanvas.SetActive(true); pedestrianCollissionText.text = GUIController.instance.pedestrianCollissionText.text; wallCollissionsText.text = GUIController.instance.wallCollissionsText.text; resetsText.text = GUIController.instance.resetsText.text; currentScore.text = GUIController.instance.currentScore.text; if (fallScore != null) { fallScore.text = GUIController.instance.fallText.text; } PlayerPrefs.SetInt(lastScoreName, Convert.ToInt32(currentScore.text)); int[] lastScores = PlayerPrefsX.GetIntArray(levelName, 0, 10); for (int i = lastScores.Length - 1; i > 0; i--) { lastScores[i] = lastScores[i - 1]; } lastScores[0] = Convert.ToInt32(currentScore.text); PlayerPrefsX.SetIntArray(levelName, lastScores); PlayerPrefs.Save(); GameController.instance.endLevel = true; }
public void SaveAndExit() { PlayerPrefsX.SetIntArray("staff", selected.ToArray()); PlayerPrefs.SetInt("capital", capital); //PlayerPrefsX.Save(); SceneManager.LoadScene(4); }
void SaveScore(int score) { // 取得 int[] scores = PlayerPrefsX.GetIntArray(KEY); //[0,0,0] scores = Add(scores, score); // 新しい得点を追加 Debug.Log(string.Join(",", scores)); // 配列の要素を,区切りのstring型で表示する PlayerPrefsX.SetIntArray(KEY, scores); // 保存 }