// Display end game screen from the team that finished public void endGame(bool isTop) { foreach(GameObject go in Map.GetComponent<Map>().fireworkList) { go.SetActive(true); } scoreRow newRow = new scoreRow(); if (isTop) { newRow.setName(carTop.GetComponent<CarState>().name); carTopDone = true; CarmonyGUI.S.topMinimap.SetActive(false); CarmonyGUI.S.topMinimapDots.SetActive(false); CarmonyGUI.S.topImageLeft.SetActive(false); CarmonyGUI.S.topImageRight.SetActive(false); carTop.GetComponent<CarState>().totalTime = getGameTime(); CarmonyGUI.S.HideTopPowerUpActivator(); CarmonyGUI.S.topSpeedBox.gameObject.SetActive(false); CarmonyGUI.S.topSpeedSlider.gameObject.SetActive(false); CarmonyGUI.S.topSpeed.SetActive(false); CarmonyGUI.S.topLap.SetActive(false); } else { newRow.setName(carBottom.GetComponent<CarState>().name); CarmonyGUI.S.bottomMinimap.SetActive(false); CarmonyGUI.S.bottomMinimapDots.SetActive(false); CarmonyGUI.S.bottomImageLeft.SetActive(false); CarmonyGUI.S.bottomImageRight.SetActive(false); carBottom.GetComponent<CarState>().totalTime = getGameTime(); carBottomDone = true; CarmonyGUI.S.HideBottomPowerUpActivator(); CarmonyGUI.S.bottomSpeedBox.gameObject.SetActive(false); CarmonyGUI.S.bottomSpeedSlider.gameObject.SetActive(false); CarmonyGUI.S.bottomSpeed.SetActive(false); CarmonyGUI.S.bottomLap.SetActive(false); } Logger.S.printSummary(isTop); CarmonyGUI.S.endGame(isTop); int minutes = Int32.Parse(getGameTime().Substring(0, 1)); int seconds = Int32.Parse(getGameTime().Substring(2, 2)); newRow.setTime(minutes, seconds); HighScores.S.updateList(newRow); }
public bool updateList(scoreRow newRow) { int myTime = 60*newRow.getMinutes() + newRow.getSeconds(); bool inserted = false; int i = 0; for(; i < scoreList.Count; i++) { if (!inserted) { int curTime = 60* scoreList[i].getMinutes() + scoreList[i].getSeconds(); if (myTime <= curTime) { newRow.setPlace(scoreList[i].getPlace()); scoreList.Insert(i, newRow); inserted = true; i++; break; } } } for (;i < scoreList.Count; i++) { int curTime = 60*scoreList[i].getMinutes() + scoreList[i].getSeconds(); int lastTime = 60 * scoreList[i-1].getMinutes() + scoreList[i-1].getSeconds(); if (curTime == lastTime) { scoreList[i].setPlace(scoreList[i - 1].getPlace()); } else { scoreList[i].setPlace(i+1); } } if (scoreList.Count == 0) { newRow.setPlace(1); scoreList.Insert(i, newRow); inserted = true; } if (scoreList.Count < places.Count && !inserted) { int lastTime = 60 * scoreList[scoreList.Count -1].getMinutes() + scoreList[scoreList.Count - 1].getSeconds(); if (myTime == lastTime) { newRow.setPlace(scoreList[scoreList.Count - 1].getPlace()); } else { newRow.setPlace(scoreList.Count + 1); } scoreList.Add(newRow); inserted = true; } if (inserted) { if (scoreList.Count > places.Count) { scoreList.RemoveRange(places.Count, scoreList.Count - places.Count ); } recordBeaten = true; writeFile(); return true; } return false; }
void readFile() { scoreList.Clear(); StreamReader theReader = new StreamReader(Main.S.Map.GetComponent<Map>().name + filename, Encoding.Default); using (theReader) { string line; do { line = theReader.ReadLine(); if (line != null && line != "") { string[] entries = line.Split(' '); scoreRow newRow = new scoreRow(); newRow.setPlace(Int32.Parse(entries[0])); newRow.setName(entries[1]); newRow.setTime(Int32.Parse(entries[2]), Int32.Parse(entries[3])); scoreList.Add(newRow); } } while (line != null); } }