/// <summary> /// Binaries the deserializer. /// Precondition: none /// Postcondition: reads the binary file data into the scoreboard. /// </summary> /// <param name="board">The board.</param> public static async void BinaryDeserializer(HighScoreBoard board) { var folder = ApplicationData.Current.LocalFolder; StorageFile file; try { file = await folder.GetFileAsync(FilenameBinary); } catch (IOException) { await folder.CreateFileAsync(FilenameBinary); return; } var reader = new BinaryReader(await file.OpenStreamForReadAsync()); while (reader.BaseStream.Position != reader.BaseStream.Length) { var val1 = reader.ReadString(); var val2 = reader.ReadInt32(); var val3 = reader.ReadInt32(); var highScore = new HighScore(val1, val2, val3); board.Add(highScore); } reader.Dispose(); }
public void AddPlayerTest7Players() { TopPlayer player1 = new TopPlayer("Vasil", 5); TopPlayer player2 = new TopPlayer("Pesho", 1); TopPlayer player3 = new TopPlayer("Vesko", 4); TopPlayer player4 = new TopPlayer("Nasko", 2); TopPlayer player5 = new TopPlayer("Nasko", 8); TopPlayer player6 = new TopPlayer("Nasko", 7); TopPlayer player7 = new TopPlayer("Nasko", 0); HighScoreBoard highScoreBoard = new HighScoreBoard(); highScoreBoard.AddPlayer(player1); highScoreBoard.AddPlayer(player2); highScoreBoard.AddPlayer(player3); highScoreBoard.AddPlayer(player4); highScoreBoard.AddPlayer(player5); highScoreBoard.AddPlayer(player6); highScoreBoard.AddPlayer(player7); Assert.AreEqual(player7, highScoreBoard.HighScores[0]); Assert.AreEqual(player2, highScoreBoard.HighScores[1]); Assert.AreEqual(player4, highScoreBoard.HighScores[2]); Assert.AreEqual(player3, highScoreBoard.HighScores[3]); Assert.AreEqual(player1, highScoreBoard.HighScores[4]); }
public void AddPlayerTest1Players() { TopPlayer player1 = new TopPlayer("Vasil", 5); HighScoreBoard highScoreBoard = new HighScoreBoard(); highScoreBoard.AddPlayer(player1); Assert.AreEqual(player1, highScoreBoard.HighScores[0]); }
/// <summary> /// This methods is used for returning the engine in its initial state /// </summary> public void InitializeEngine() { this.highScoreBoard = new HighScoreBoard(); this.currentWord = null; this.currentMistakesCount = 0; this.usedHelp = false; this.restart = false; }
private void Awake() { songSettings = GameObject.FindGameObjectWithTag("SongSettings").GetComponent <SongSettings>(); sceneHandling = GameObject.FindGameObjectWithTag("SceneHandling").GetComponent <SceneHandling>(); scoreHandling = GameObject.FindGameObjectWithTag("ScoreHandling").GetComponent <ScoreHandling>(); scoreSystem = GameObject.FindGameObjectWithTag("HighScore").GetComponent <HighScoreSystem>(); scoreBoard = GetComponentInChildren <HighScoreBoard>(true); }
// Start is called before the first frame update void Start() { if (instance == null) { instance = this; } printScores(); }
public void AddPlayerTest3Players() { TopPlayer player1 = new TopPlayer("Vasil", 5); TopPlayer player2 = new TopPlayer("Pesho", 1); TopPlayer player3 = new TopPlayer("Vesko", 4); HighScoreBoard highScoreBoard = new HighScoreBoard(); highScoreBoard.AddPlayer(player1); highScoreBoard.AddPlayer(player2); highScoreBoard.AddPlayer(player3); Assert.AreEqual(player2, highScoreBoard.HighScores[0]); Assert.AreEqual(player3, highScoreBoard.HighScores[1]); Assert.AreEqual(player1, highScoreBoard.HighScores[2]); }
public void GameOver() { StopGame(); gameObject.SetActive(true); sc.scorePerSecond = 0; scoreText.text = sc.score.ToString() + "m"; //hsb = new HighScoreBoard(); hsb = gameObject.AddComponent <HighScoreBoard>(); if (hsb.AddScore(sc.score)) { highscoretext.SetActive(true); } }
void LoadHighScoreBoard() { HighScoreBoard.HighScoreList scoreList = null; if (File.Exists(_highScoreBoardPath)) { string rawJson = File.ReadAllText(_highScoreBoardPath); scoreList = JsonUtility.FromJson <HighScoreBoard.HighScoreList>(rawJson); LocalHighScoreBoard = new HighScoreBoard(scoreList); } if (scoreList == null) { LocalHighScoreBoard = new HighScoreBoard(null); } }
void LoadHighScoreBoard() { _highScoreBoard = null; Directory.CreateDirectory(Path.GetDirectoryName(HighScoreBoardPath)); using (FileStream fs = new FileStream(HighScoreBoardPath, FileMode.OpenOrCreate)) { using (StreamReader reader = new StreamReader(fs)) { string jsonDataString = reader.ReadLine(); _highScoreBoard = JsonUtility.FromJson <HighScoreBoard>(jsonDataString); } } if (_highScoreBoard == null) { _highScoreBoard = new HighScoreBoard(); } }
// Use this for initialization void Start() { NameResultText.text = ""; TimeResultText.text = ""; ScoreResultText.text = ""; HighScoreBoard temp = GameManager.Instance.LocalHighScoreBoard; List <HighScoreBoard.HighScoreEntry> highScoreList = temp.ScoreList.MainList; var query = highScoreList.OrderBy(w => w.Score).ToList(); for (int i = highScoreList.Count - 1; i >= 0; i--) { GameObject Child2 = Instantiate(ChildPanel); Child2.transform.SetParent(ContentPanel.transform, false); var childlist = Child2.GetComponentsInChildren <Text>(); childlist[0].text = query[i].Name; childlist[1].text = query[i].DateTime.Substring(0, 10); childlist[2].text = query[i].Score.ToString(); } ChildPanel.SetActive(false); }