void SetHiscore() { if (newHiscoreEntry) { scoreHeader.SetActive(true); currentWaveText.text = gi.wave - 1 + " Waves"; DataTransferManager.dataHolder.SetDefaultValues(); if (scoreBeaten) { UnmarkBars(); MarkNewScore(scoreBeatenIndex); } } if (!newHiscoreEntry) { scoreHeader.SetActive(false); } DataTransferManager.ReadHiscore(); for (int i = 0; i < hiscoreName.Length; i++) { hiscoreName[i].text = DataTransferManager.hiscore.name[i]; hiscoreValue[i].text = DataTransferManager.hiscore.value[i].ToString(); } newHiscoreEntry = false; }
public static void UpdateHiscore() { newHiscoreEntry = true; DataTransferManager.ReadHiscore(); int cs = gi.wave - 1; string name = DataTransferManager.dataHolder.name; bool stopLoop = false; for (int i = 0; i < 3; i++) { if (cs > DataTransferManager.hiscore.value[i]) { if (stopLoop == true) { break; } scoreBeaten = true; scoreBeatenIndex = i; int formerValue = DataTransferManager.hiscore.value[i]; string formerName = DataTransferManager.hiscore.name[i]; DataTransferManager.hiscore.value[i] = cs; DataTransferManager.hiscore.name[i] = name; for (int j = i + 1; j < 3; j++) { int tempValue = DataTransferManager.hiscore.value[j]; string tempName = DataTransferManager.hiscore.name[j]; DataTransferManager.hiscore.value[j] = formerValue; DataTransferManager.hiscore.name[j] = formerName; formerValue = tempValue; formerName = tempName; stopLoop = true; } } } }