public void WriteDemoFile() { string validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; ScoreEntries demoEntries = new ScoreEntries(); for (int i = 0; i < 10; i++) { // Zufälligen 3 char String erzeugen char[] nameChars = new char[3]; for (int j = 0; j < nameChars.Length; j++) { nameChars[j] = validChars[UnityEngine.Random.Range(0, validChars.Length)]; } string name = new string(nameChars); demoEntries.entryNo.Add(i + 1); demoEntries.value.Add(855 - i * 75); demoEntries.playerName.Add(name); } File.WriteAllText(scoreFilePath, demoEntries.GetString()); Debug.Log(scoreFilePath); }
private int CalculateFileLength() { var length = 0x50 + // File + BPM header ScoreEntries.Count * 0x10 + // Score headers ScoreEntries.Sum(scoreEntry => scoreEntry.Bars.Count * 0x10); // Notes return(length); }
protected override void OnProcessOutputSchema(MutableObject newSchema) { foreach (var entry in ScoreEntries.GetEntries(newSchema)) { RcsPatchingTarget.SetValue(true, entry); NdsPatchingTarget.SetValue(false, entry); } base.OnProcessOutputSchema(newSchema); }
private void PostNewScore() { ScoreEntries scoreList = ReadScoreFile(); int posOfNewScore = 0; int newScore = PlayerPrefs.GetInt("lastScore", 0); // Rank der neuen Score ermitteln: if (scoreList.value.Count < 10) { posOfNewScore = scoreList.value.Count; } else { for (int i = 0; i < scoreList.value.Count; i++) { if (newScore > scoreList.value[i]) { posOfNewScore = i; break; } } } // Platz 10 löschen, falls nötig: if (scoreList.entryNo.Count == 10) { scoreList.entryNo.RemoveAt(9); scoreList.value.RemoveAt(9); scoreList.playerName.RemoveAt(9); } // Neuen Eintrag machen: scoreList.entryNo.Insert(posOfNewScore, posOfNewScore + 1); scoreList.value.Insert(posOfNewScore, newScore); scoreList.playerName.Insert(posOfNewScore, playerNameText.text.ToUpper()); // Nachfolgende Positionsnummern um 1 erhöhen: for (int i = (posOfNewScore + 1); i < scoreList.value.Count; i++) { scoreList.entryNo[i] += 1; } // Datei überschreiben: File.WriteAllText(scoreFilePath, scoreList.GetString()); PlayerPrefs.SetInt("lastScore", 0); SceneManager.LoadScene("Scores"); }
/// <summary> /// Public Methods /// </summary> public bool CheckNewScore(ScoreEntries scoreList) { int newScore = PlayerPrefs.GetInt("lastScore", 0); if (scoreList.value.Count < 10) { return(true); } for (int i = 0; i < scoreList.value.Count; i++) { if (newScore > scoreList.value[i]) { return(true); } } return(false); }
public override IEnumerator ReceivePayload(VisualPayload payload) { // construct offlines dictionary var offlines = new Dictionary <IntPair, CsOfflineReason>(); foreach (var entry in CsOfflineScope.GetEntries(payload.Data)) { var teamId = OfflineTeamId.GetValue(entry); var csId = OfflineCsId.GetValue(entry); var offlineReason = OfflineReason.GetValue(entry); offlines[new IntPair(csId, teamId)] = offlineReason; } // check each score entry against the offlines dictionary foreach (var entry in ScoreEntries.GetEntries(payload.Data)) { var teamId = ScoreTeamId.GetValue(entry); var csId = ScoreCsId.GetValue(entry); var idPair = new IntPair(csId, teamId); bool patchingRcs = false; bool patchingNds = false; if (offlines.ContainsKey(idPair)) { var reason = offlines[idPair]; patchingRcs = reason == CsOfflineReason.Rcs || reason == CsOfflineReason.Both; patchingNds = reason == CsOfflineReason.Ids || reason == CsOfflineReason.Both; } RcsPatchingTarget.SetValue(patchingRcs, entry); NdsPatchingTarget.SetValue(patchingNds, entry); } var iterator = Router.TransmitAll(payload); while (iterator.MoveNext()) { yield return(null); } }
private void PrintList(ScoreEntries scoreList) { // Template ausblenden entryTemplate.gameObject.SetActive(false); for (int i = 0; i < scoreList.value.Count; i++) { // Aus Template neuen Eintrag erzeugen Transform entryTransform = Instantiate(entryTemplate, entryContainer); // Eintrag um "templateHeight" auf y-Achse versetzen RectTransform entryRectTransform = entryTransform.GetComponent <RectTransform>(); entryRectTransform.anchoredPosition = new Vector2(0, -templateHeight * i); // Textwerte setzen entryTransform.Find("posText").GetComponent <Text>().text = scoreList.entryNo[i].ToString(); entryTransform.Find("scoreText").GetComponent <Text>().text = scoreList.value[i].ToString(); entryTransform.Find("playerText").GetComponent <Text>().text = scoreList.playerName[i].ToString(); // Eintrag aktivieren entryTransform.gameObject.SetActive(true); } }
private MsbBar GetLastBar() { return(ScoreEntries.OrderByDescending(i => i.Bars.Last().Offset + i.Bars.Last().Length).First().Bars.Last()); }