public Task <HighScore> Create(NewHighScore newHighScore) { HighScore highScore = new HighScore() { Id = Guid.NewGuid(), Name = newHighScore.Name, Score = newHighScore.Score, }; return(_repository.CreateHighScore(highScore)); }
void Update() { Text myText = GetComponent <Text>(); if ((Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W)) && alphaPosition < 26) { alphaPosition += 1; nameField[index] = NumberToChar(alphaPosition); } if ((Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S)) && alphaPosition > 1) { alphaPosition -= 1; nameField[index] = NumberToChar(alphaPosition); } if ((Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) && index < nameField.Length - 1) { index += 1; alphaPosition = CharToNumber(nameField[index]); } if ((Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) && index > 0) { index -= 1; alphaPosition = CharToNumber(nameField[index]); } for (int i = 0; i < nameField.Length; i++) { text = text + nameField[i].ToString(); } myText.text = text; // Submit initals and save to high score board // Disables the panel and returns to ordinary game over scene if (Input.GetKeyDown(KeyCode.Return)) { HighScoreManager highScoreManager = new HighScoreManager(); highScoreManager.SaveHighScores(text); NewHighScore.DisableNewHSPanel(); } text = ""; // Reset text variable after displaying it // Stuck this at the bottom so that text won't reset before hitting enter }
private void OnNewHighScore(NewHighScore newScore) { if (newScore.IsNewHighScore && newHighScoreLabel != null && highScoreText != null) { newHighScoreLabel.SetActive (true); highScoreText.text = string.Format ("New High Score: {0}", newScore.Score); } if (newScore.IsNewMaxHeight && newMaxHeightLabel != null && maxHeightText != null) { newMaxHeightLabel.SetActive (true); maxHeightText.text = string.Format ("New Max Height: {0} Meters", (int)newScore.Height); } }
private async Task RenderWonGame() { var text = $"Congratulations you won!"; var length = await _context.MeasureTextAsync(text); await _context.FillTextAsync(text, _width / 2 - (length.Width / 2), 150); text = $"Press space to start a new game"; length = await _context.MeasureTextAsync(text); await _context.FillTextAsync(text, _width / 2 - (length.Width / 2), 200); Started = false; if (_points > HighScore) { HighScore = _points; NewHighScore?.Invoke(this, new EventArgs()); } }
private void CheckForHighScore() { long highScore = (long)PlayerPrefs.GetInt("HighScore", -1); float maxHeight = PlayerPrefs.GetFloat("MaxHeight", -1); bool isNewHighScore = false; bool isNewMaxHeight = false; isNewHighScore = highScore == -1 || player.PlayerScore > highScore; isNewMaxHeight = maxHeight == -1 || playerMaxHeight > maxHeight; if (isNewHighScore || isNewMaxHeight) { NewHighScore newScore = new NewHighScore(isNewHighScore ? player.PlayerScore : 0, isNewMaxHeight ? playerMaxHeight : 0f); newScore.SaveScores(); Messenger <NewHighScore> .Broadcast(NewHighScore.MSG_NEW_HIGH_SCORE, newScore, MessengerMode.DONT_REQUIRE_LISTENER); } else { Messenger <EndGameEvent> .Broadcast(MSG_END_GAME, new EndGameEvent (player.PlayerScore, playerMaxHeight), MessengerMode.DONT_REQUIRE_LISTENER); } }
public Task <HighScore> Create(NewHighScore highScore) { return(_processor.Create(highScore)); }
private IEnumerator CheckForHighScoreWWW() { long score = player.PlayerScore; float height = Mathf.Floor(playerMaxHeight); var networkReachability = Application.internetReachability; var networkConnectionStatus = Network.TestConnection(); if (networkReachability == NetworkReachability.NotReachable || networkConnectionStatus == ConnectionTesterStatus.Error || networkConnectionStatus == ConnectionTesterStatus.Undetermined) { Messenger <EndGameEvent> .Broadcast(MSG_END_GAME, new EndGameEvent (score, height), MessengerMode.DONT_REQUIRE_LISTENER); yield break; } WWWForm requestData = new WWWForm(); requestData.AddField("score", score.ToString()); requestData.AddField("height", height.ToString()); requestData.AddField("initials", "ABC"); //string dbURL = "http://10.0.0.10:1337/connect"; string dbURL = "http://71.229.150.150:1337/score"; WWW request = new WWW(dbURL, requestData); yield return(new WaitUntil(() => request.isDone)); if (request.error == null) { if (!string.IsNullOrEmpty(request.text)) { string[] responseParams = request.text.Split(':'); if (responseParams.Length == 3) { if (responseParams[0] == "0") { int highScoreRank = System.Convert.ToInt32(responseParams [1]); int heightRank = System.Convert.ToInt32(responseParams [2]); bool isNewHighScore = highScoreRank != -1; bool isNewMaxHeight = heightRank != -1; if (isNewHighScore || isNewMaxHeight) { NewHighScore newScore = new NewHighScore(isNewHighScore ? score : 0, isNewMaxHeight ? height : 0f); newScore.SaveScores(); Messenger <NewHighScore> .Broadcast(NewHighScore.MSG_NEW_HIGH_SCORE, newScore, MessengerMode.DONT_REQUIRE_LISTENER); } else { Messenger <EndGameEvent> .Broadcast(MSG_END_GAME, new EndGameEvent (player.PlayerScore, playerMaxHeight), MessengerMode.DONT_REQUIRE_LISTENER); } } } } } else { Debug.Log(request.error); Messenger <EndGameEvent> .Broadcast(MSG_END_GAME, new EndGameEvent (score, height), MessengerMode.DONT_REQUIRE_LISTENER); } }