IEnumerator CheckHighScore() { GameObject lbName = GameObject.Find("/Canvas/LBName"); GameObject lbScore = GameObject.Find("/Canvas/LBScore"); dl.AddScore("abb", 1); List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); while (scoreList.Count == 0) { yield return(new WaitForSeconds(1.0f)); scoreList = dl.ToListHighToLow(); } lbPlace = 1; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { lbNameString += "\n" + lbPlace + ": " + currentScore.playerName; lbScoreString += "\n" + currentScore.score.ToString(); lbPlace++; } Text myLBName = lbName.GetComponent <Text>(); myLBName.text = lbNameString; Text myLBScore = lbScore.GetComponent <Text>(); myLBScore.text = lbScoreString; }
public void setWinner() { List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); if (scoreList.Count == 0) { return; } string[] y = scoreList[0].playerName.Split("$".ToCharArray()); submitPeriod.instance.winnerName = y[0]; submitPeriod.instance.winnerClub = klub.options[int.Parse(y[1])].text; submitPeriod.instance.winnerScore = scoreList[0].score; }
void OnGUI() { scoreList = _MyLeaderBoard.ToListHighToLow(); //Font Size GUI.skin.label.fontSize = 48; if (gs == GameState.ended) { if (_MyLeaderBoard.publicCode == "") { Debug.LogError("You forgot to set the public Code variable"); } if (_MyLeaderBoard.privateCode == "") { Debug.LogError("You forgot to set the private Code variable"); } _MyLeaderBoard.AddScore(_PlayerName, _Score); print("upload"); gs = GameState.waiting; } if (gs == GameState.leaderboard) { if (scoreList == null) { GUILayout.Label("(Loading...)"); //gs = GameState.waiting; } else { int maxToDisplay = 10; int count = 0; float totalHeight = Screen.height * 0.66f; float heightEach = totalHeight / maxToDisplay; textStyle.fontSize = (int)(heightEach * 0.6f); float areaWidth = 350; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { count++; GUILayout.BeginArea(new Rect((Screen.width - 350) / 2, ((Screen.height - totalHeight) / 2) + count * heightEach, 350, heightEach)); GUILayout.BeginHorizontal("box"); GUILayout.Label(count + ") ", textStyle, GUILayout.MinWidth(areaWidth * 0.2f)); GUILayout.Label(currentScore.playerName, textStyle, GUILayout.MinWidth(areaWidth * 0.5f)); GUILayout.Label(currentScore.score.ToString(), textStyle, GUILayout.MinWidth(areaWidth * 0.3f)); GUILayout.EndHorizontal(); GUILayout.EndArea(); if (count >= maxToDisplay) { break; } } } } }
public void HighScores() { bsAudio.Play(); if (Application.internetReachability == NetworkReachability.NotReachable) { Debug.Log("Error. Check internet connection!"); HS[0].text = "NO INTERNET CONNECTION"; HighScoresPanel.SetActive(true); } else { List <dreamloLeaderBoard.Score> scoreList = DL.ToListHighToLow(); if (scoreList.Count < 1) { HS [0].text = "NO HIGHSCORES!"; HighScoresPanel.SetActive(true); } else { int maxToDisplay = 10; int count = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { HS [count].text = currentScore.playerName + " ... " + currentScore.score.ToString(); if (count >= maxToDisplay) { break; } count++; HighScoresPanel.SetActive(true); } } } }
IEnumerator GlobalHighscoreStuff(dreamloLeaderBoard dreamlo, GameObject gameEndObj) { yield return(new WaitForSeconds(1f)); while (dreamlo.ToStringArray() == null) { yield return(new WaitForSeconds(0.25f)); } List <dreamloLeaderBoard.Score> globalScores = dreamlo.ToListHighToLow(); var globalHighScoreContent = gameEndObj.transform.Find("GlobalScoreList/GlobalHighscore/Viewport/Content"); foreach (Transform child in globalHighScoreContent.transform) { Destroy(child.gameObject); } for (int i = 0; i < globalScores.Count; i++) { var score = globalScores[i]; var txtInst = Instantiate(textPrefab); txtInst.transform.SetParent(globalHighScoreContent); txtInst.transform.localScale = Vector3.one; txtInst.text = (i + 1) + " - " + score.playerName + ": " + (score.score * 0.1f).ToString("0.0"); } }
IEnumerator DoLeaderboardUI() { float timer = 0.0f; while (timer < 5.0f && dreamloRef.highScores == "") { timer += Time.deltaTime; yield return(null); } if (dreamloRef.highScores != "") { List <dreamloLeaderBoard.Score> scores = dreamloRef.ToListHighToLow(); Debug.Log("tata mata dhghjghjfjh"); for (int i = 0; i < scores.Count; ++i) { var go = Instantiate(statsPrefab, ParentContent.transform, false); go.name = "Player" + (i + 1); go.GetComponent <LeaderBoardui>().setStats((i + 1) + "", scores[i].playerName, scores[i].score.ToString() + ""); statobs.Add(go); } } // StopCoroutine(DoLeaderboardUI()); }
public void LoadHighscore() { scoreList = leaderBoard.ToListHighToLow(); print(scoreList.Count); int maxToDisplay = 20; int count = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { print(currentScore.score); count++; GameObject newScore = Instantiate(lvlMan.scoreUI, transform.position, Quaternion.identity); newScore.GetComponent <UI_Score>().player_Name.text = currentScore.playerName; newScore.GetComponent <UI_Score>().player_Score.text = currentScore.score.ToString(); newScore.GetComponent <UI_Score>().player_Time.text = currentScore.seconds.ToString(); newScore.GetComponent <UI_Score>().player_Kills.text = currentScore.shortText; newScore.transform.SetParent(lvlMan.leaderboardUIList.transform, false); if (count >= maxToDisplay) { break; } } }
private void OnGUI() { var width200 = new GUILayoutOption[] { GUILayout.Width(200) }; GUILayout.Label("High Scores:"); List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); if (scoreList == null) { GUILayout.Label("(loading...)"); } else { int maxToDisplay = 20; int count = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { count++; GUILayout.BeginHorizontal(); GUILayout.Label(currentScore.playerName, width200); GUILayout.Label(currentScore.score.ToString(), width200); GUILayout.EndHorizontal(); if (count >= maxToDisplay) { break; } } } }
IEnumerator updateLeaderboardCo() { _scoreList = null; WaitForSeconds waitForSec = new WaitForSeconds(0.1f); bool scoreUpdated = false; while (state == GameState.Leaderboard && scoreUpdated == false) { _scoreList = _leaderboard.ToListHighToLow(); if (_scoreList != null) { if (leaderboardFilter.Length > 0) { string filter = leaderboardFilter + "_"; for (int i = _scoreList.Count - 1; i >= 0; i--) { if (_scoreList[i].playerName.StartsWith(filter) == false) { _scoreList.RemoveAt(i); } } } scoreUpdated = UIManager.inst.showLeaderboard( _playerUniqueName, _playerInitials, _finalScore, _scoreList); } yield return(waitForSec); } }
void Check() { List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); if (scoreList == null) { GUILayout.Label("(loading...)"); } else { nameField.text = ""; scoreField.text = ""; int maxToDisplay = 20; int count = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { count++; nameField.text = nameField.text + count + ". " + currentScore.playerName + "\n"; scoreField.text = scoreField.text + currentScore.score.ToString() + "\n"; if (count >= maxToDisplay) { break; } } count++; for (; count <= maxToDisplay; count++) { nameField.text = nameField.text + count + ". " + "\n"; } } }
void Update() { if (updateRequest) { Debug.Log("Update request"); dl.LoadScores(); updateRequest = false; fetchScores = true; submit.SetActive(false); } if (fetchScores) { Debug.Log("fetchScores"); scoreList = dl.ToListHighToLow(); if (scoreList.Count != oldCount) { Debug.Log("score fetched"); populateBoard(); fetchScores = false; if (isInTop()) { submit.SetActive(true); } oldCount = scoreList.Count(); } } }
public void formatScores() { repeats = 0; List <dreamloLeaderBoard.Score> scoreList02 = dl.ToListHighToLow(-2); lvl02Text.text = formatList(scoreList02, 1); List <dreamloLeaderBoard.Score> scoreList01 = dl.ToListHighToLow(-1); lvl01Text.text = formatList(scoreList01, 1); List <dreamloLeaderBoard.Score> scoreList0 = dl.ToListHighToLow(0); lvl0Text.text = formatList(scoreList0, 0); List <dreamloLeaderBoard.Score> scoreList1 = dl.ToListHighToLow(1); lvl1Text.text = formatList(scoreList1, 0); List <dreamloLeaderBoard.Score> scoreList2 = dl.ToListHighToLow(2); lvl2Text.text = formatList(scoreList2, 0); List <dreamloLeaderBoard.Score> scoreList3 = dl.ToListHighToLow(3); lvl3Text.text = formatList(scoreList3, 0); List <dreamloLeaderBoard.Score> scoreList4 = dl.ToListHighToLow(4); lvl4Text.text = formatList(scoreList4, 0); List <dreamloLeaderBoard.Score> scoreList5 = dl.ToListHighToLow(5); lvl5Text.text = formatList(scoreList5, 0); setTexts(); if (GetScoreOrRefresh == 0) { checkDisplay(); outputText.text = ""; } else { GetScoreOrRefresh = 0; if (repeats > 0) { toggleSubmitTrue(); outputText.text = "Name Taken"; } else { outputText.text = "Uploading..."; dl.DeletePrevious(PlayerPrefs.GetString("YourName", "No Name")); } } }
async Task <List <dreamloLeaderBoard.Score> > GetHighscores() { while (leaderBoard.highScores == "") { await Task.Delay(500); } return(leaderBoard.ToListHighToLow()); }
System.Collections.IEnumerator AddScoreRoutine() { dl.AddScore(playerName.text, score); //yield return new WaitForSeconds(2.1f); //dl.LoadScores(); used = true; yield return(new WaitForSeconds(2.1f)); scoreList = dl.ToListHighToLow(); yield return(new WaitForSeconds(2.1f)); DisplayScores(); addScoreBtnText.text = "Saved"; yield return(new WaitForSeconds(2.1f)); scoreList = dl.ToListHighToLow(); yield return(new WaitForSeconds(2.1f)); DisplayScores(); }
void OnGUI() { if (gs == gameState.ended) { playerName = PlayerPrefs.GetString("Name"); totalScore = GameManager.TotalScore; if (_MyLeaderBoard.publicCode == "") { Debug.LogError("You forgot to set the public Code variable"); } if (_MyLeaderBoard.privateCode == "") { Debug.LogError("You forgot to set the private Code variable"); } _MyLeaderBoard.AddScore(playerName, totalScore); print("Leaderboards"); print(playerName + totalScore); gs = gameState.leaderboard; } if (gs == gameState.leaderboard) { GUILayout.Label("High Scores:"); List <dreamloLeaderBoard.Score> scoreList = _MyLeaderBoard.ToListHighToLow(); if (scoreList == null) { GUILayout.Label("(Loading...)"); } else { int maxToDisplay = 15; int count = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { count++; GUILayout.BeginHorizontal(); GUILayout.Label(currentScore.playerName); GUILayout.Label(currentScore.score.ToString()); GUILayout.EndHorizontal(); if (count >= maxToDisplay) { break; } } } } }
private void Update() { HighScoresList = dl.ToListHighToLow(); for (int i = 0; i < highScoreTexts.Length; i++) { highScoreTexts[i].text = i + 1 + ". N/A..."; if (HighScoresList.Count > i) { //Debug.Log("yes"); highScoreTexts[i].text = i + 1 + ". " + HighScoresList[i].playerName + " - " + HighScoresList[i].score; } } }
public static void GetLeaderboardString(dreamloLeaderBoard lb) { List <dreamloLeaderBoard.Score> scores = lb.ToListHighToLow().Take(10).ToList(); if (scores != null && scores.Count > 0) { // parse scores string allScores = ""; int index = 1; foreach (dreamloLeaderBoard.Score score in scores) { allScores += ( (index > 9 ? "" : " ") + index.ToString() + ". " // position in list + string.Format("{0:F1}", Utils.ScoreToTime(score.score)) + "s | " // score + score.playerName // name + (score.playerName == PlayerPrefs.GetString("Name") ? " <-" : "") // player indicator + "\n" ); index += 1; } GameObject.Find("Content").GetComponent <Text> ().text = allScores; } }
private void Update() { if (_init) { return; } var scores = _leaderBoard.ToListHighToLow(); if (scores == null || scores.Count == 0) { return; } for (int i = 0; i < scores.Count && i < _rows.Count; i++) { var score = scores[i]; _rows[i].SetData(score.playerName, score.score.ToString()); _rows[i].gameObject.SetActive(true); } _init = true; }
// Update is called once per frame void Update() { if (gs == gameState.enterscore) { scorePanel.SetActive(true); } else if (gs == gameState.leaderboard) { List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); if (scoreList == null || scoreList.Count == 0) { namesList.text = "(loading...)"; } else { Debug.Log("scorelist not null"); int maxToDisplay = 5; int count = 0; namesList.text = ""; Debug.Log(scoreList.Count); foreach (dreamloLeaderBoard.Score currentScore in scoreList) { Debug.Log("scoreList iterate"); count++; namesList.text = namesList.text + "\n" + currentScore.playerName + " " + currentScore.score.ToString(); if (count >= maxToDisplay) { Debug.Log("scorelist too big"); gs = gameState.waiting; break; } } gs = gameState.waiting; } } }
void OnGUI() { GUILayoutOption[] width200 = new GUILayoutOption[] { GUILayout.Width(200) }; float width = 400; // Make this wider to add more columns float height = 200; Rect r = new Rect((Screen.width / 2) - (width / 2), (Screen.height / 2) - (height), width, height); GUILayout.BeginArea(r, new GUIStyle("box")); GUILayout.BeginVertical(); if (gs == gameState.waiting || gs == gameState.running) { GUILayout.Label("Total Score: " + this.totalScore.ToString()); } if (gs == gameState.enterscore) { GUILayout.Label("Total Score: " + this.totalScore.ToString()); GUILayout.BeginHorizontal(); GUILayout.Label("Your Name: "); this.playerName = GUILayout.TextField(this.playerName, width200); if (GUILayout.Button("Save Score")) { // add the score... if (dl.publicCode == "") { Debug.LogError("You forgot to set the publicCode variable"); } if (dl.privateCode == "") { Debug.LogError("You forgot to set the privateCode variable"); } dl.AddScore(this.playerName, totalScore); gs = gameState.leaderboard; } GUILayout.EndHorizontal(); } if (true) { GUILayout.Label("High Scores:"); List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); if (scoreList == null) { GUILayout.Label("(loading...)"); } else { int maxToDisplay = 20; int count = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { count++; GUILayout.BeginHorizontal(); GUILayout.Label(currentScore.playerName, width200); GUILayout.Label(currentScore.score.ToString(), width200); GUILayout.EndHorizontal(); if (count >= maxToDisplay) { break; } } } } GUILayout.EndArea(); r.y = r.y + r.height + 20; GUILayout.BeginArea(r, new GUIStyle("box")); GUILayout.BeginHorizontal(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndArea(); }
void OnGUI() { var width200 = new GUILayoutOption[] { GUILayout.Width(200) }; var width = 400; // Make this wider to add more columns var height = 200; var r = new Rect((Screen.width / 2) - (width / 2), (Screen.height / 2) - (height), width, height); GUILayout.BeginArea(r, new GUIStyle("box")); GUILayout.BeginVertical(); if (this.gs == gameState.enterscore) { GUILayout.Label("Total Score: " + ScoreScript.scoreValue); GUILayout.BeginHorizontal(); GUILayout.Label("Your Name: "); this.playerName = GUILayout.TextField(this.playerName, width200); if (GUILayout.Button("Save Score")) { // add the score... if (dl.publicCode == "") { Debug.LogError("You forgot to set the publicCode variable"); } if (dl.privateCode == "") { Debug.LogError("You forgot to set the privateCode variable"); } dl.AddScore(this.playerName, ScoreScript.scoreValue); this.gs = gameState.leaderboard; } GUILayout.EndHorizontal(); } if (this.gs == gameState.leaderboard) { GUILayout.Label("High Scores:"); List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); if (scoreList == null) { GUILayout.Label("(loading...)"); } else { int maxToDisplay = 20; int count = 0; if (GUILayout.Button("Exit")) { FindObjectOfType <GameManager>().Restart(); } foreach (dreamloLeaderBoard.Score currentScore in scoreList) { count++; GUILayout.BeginHorizontal(); GUILayout.Label(currentScore.playerName, width200); GUILayout.Label(currentScore.score.ToString(), width200); GUILayout.EndHorizontal(); if (count >= maxToDisplay) { break; } //FindObjectOfType<GameManager>().Restart(); } } } //GUILayout.BeginHorizontal(); //GUILayout.Label("Return to Menu"); //if (GUILayout.Button("Exit")) //{ // FindObjectOfType<GameManager>().Restart(); //} //GUILayout.EndHorizontal(); }
public void GameOver() { if (gameState == 2) { return; } if (lapCount > PlayerPrefs.GetInt("highscore", 0)) { PlayerPrefs.SetInt("highscore", lapCount); UImanager.instance.SetHighscore("New Highscore: " + lapCount.ToString()); } else { UImanager.instance.SetHighscore("Highscore: " + PlayerPrefs.GetInt("highscore")); } if (lapCount > 1) { Debug.Log("SHOWADS"); ShowInterstitialAd(); } AudioManager.instance.PlaySound("death"); gameState = 2; capturing = false; AudioManager.instance.GetComponent <AudioSource>().volume = 1; AudioManager.instance.GetComponent <AudioSource>().pitch = 2.5f; UImanager.instance.BtnPanel.SetActive(true); UImanager.instance.SetDeathQuote(deathQuotes[Random.Range(0, deathQuotes.Length)]); //highscore stuff // get the reference here... // add the score... if (dl.publicCode == "") { Debug.LogError("You forgot to set the publicCode variable"); } if (dl.privateCode == "") { Debug.LogError("You forgot to set the privateCode variable"); } string players = ""; string scores = ""; bool playerintop10 = false; scoreList = dl.ToListHighToLow(); if (scoreList == null) { } else { int maxToDisplay = 10; int count = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { count++; players = players + count.ToString() + "." + currentScore.playerName + "\n"; scores = scores + currentScore.score.ToString() + "\n"; if (currentScore.playerName == playerName) { playerintop10 = true; } if (count >= maxToDisplay) { break; } } } if (playerintop10 == false) { players += "...\n"; scores += "...\n"; players += playerName + "\n"; scores += lapCount + "\n"; } playersText.text = players; scoresText.text = scores; }
void GetScores() { this.scoreList = dl.ToListHighToLow(); }
void Update() { if (ls == leaderboardState.leaderboard) { List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); if (scoreList != null && dl.highScores != lastHighScores) { foreach (dreamloLeaderBoard.Score currentScore in scoreList) { SetScore(currentScore.playerName, currentScore.playerName, "mantis", currentScore.score); } lastHighScores = dl.highScores; ls = leaderboardState.done; if (loading) { loading = false; foreach (Text text in entries) { text.text = ""; } } if (restartOnLoad) { Debug.Log("highscore string: " + lastHighScores); SceneManager.LoadScene(SceneManager.GetActiveScene().name); } } } if (player.gameOver || lastHighestmantis == player.mantisDestroyedCount || ls == leaderboardState.leaderboard) { return; } lastHighestmantis = player.mantisDestroyedCount; SetScore(youUserID, "you", "mantis", player.mantisDestroyedCount); string[] userIds = GetUserIDs("mantis"); int playerIndex = System.Array.IndexOf(userIds, youUserID); int iterations = Mathf.Min(entries.Length, userIds.Length); //entries [entries.Length - 1].text = (2 + playerIndex) + ". " + " you / " + player.highestMass; if (playerIndex + iterations + 1 > userIds.Length) { playerIndex = userIds.Length - iterations; } else { playerIndex -= iterations / 2; } if (playerIndex < 0) { playerIndex = 0; } for (int i = 0; i < iterations; i++) { string curUserId = userIds [playerIndex + i]; entries [i].text = (playerIndex + 1 + i) + ". " + (curUserId == youUserID ? "you" : curUserId) + " / " + GetScore(curUserId, "mantis"); entries [i].color = (curUserId == youUserID ? playerColour : Color.black); } }
IEnumerator ShowScores() { yield return(new WaitForSeconds(4)); try { List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); int maxToDisplay = 11; float count = 0f; print("ScoreList: " + scoreList[0].playerName); if (scoreList[0].playerName != "") { loadingIcon.SetActive(false); foreach (dreamloLeaderBoard.Score currentScore in scoreList) { float lineSpace = hSName.GetComponent <RectTransform>().sizeDelta.y; float move = hSName.transform.position.y - (lineSpace * (count + 1)); float move2 = hSScore.transform.position.y - (lineSpace * (count + 1)); //Criar linhas player GameObject clone = Instantiate(hSName, hSName.transform.position, Quaternion.identity); clone.transform.SetParent(gameObject.transform); clone.transform.localScale = hSName.transform.localScale; clone.GetComponent <RectTransform>().anchoredPosition = hSName.GetComponent <RectTransform>().anchoredPosition; clone.transform.localRotation = hSName.transform.localRotation; clone.transform.localPosition = new Vector3(hSName.transform.position.x, move, hSName.transform.position.z); clone.GetComponent <Text>().text = currentScore.playerName; clone.transform.SetParent(hSName.transform.parent); //criar linhas score GameObject clone2 = Instantiate(hSScore, hSScore.transform.position, Quaternion.identity); clone2.transform.SetParent(gameObject.transform); clone2.transform.localScale = hSScore.transform.localScale; clone2.transform.localRotation = hSScore.transform.localRotation; clone2.transform.localPosition = new Vector3(hSScore.transform.position.x, move2, hSScore.transform.position.z); clone2.GetComponent <Text>().text = currentScore.score.ToString(); clone2.transform.SetParent(hSScore.transform.parent); //criar linhas do flag GameObject clone3 = Instantiate(hardFlag, hardFlag.transform.position, Quaternion.identity); clone3.transform.SetParent(gameObject.transform); clone3.transform.localScale = hardFlag.transform.localScale; clone3.transform.localRotation = hardFlag.transform.localRotation; clone3.transform.localPosition = new Vector3(hardFlag.transform.position.x, move2, hardFlag.transform.position.z); clone3.transform.SetParent(hardFlag.transform.parent); if (currentScore.seconds == 0) { clone3.GetComponent <Image>().enabled = true; } count++; // print(currentScore.playerName); // print(currentScore.score.ToString()); if (count >= maxToDisplay) { break; } } } } catch (ArgumentOutOfRangeException) { print("Connection fail catch"); loadingIcon.GetComponent <Text>().color = Color.red; Start(); } }
void OnGUI() { if (this.gs == gameState.leaderboard) { List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); if (scoreList == null) { firstPlaceText.text = "Loading..."; secondPlaceText.text = ""; thirdPlaceText.text = ""; } else { int maxToDisplay = 3; int count = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { count++; var duration = GetDurationFromSeconds(currentScore.score); var boardEntry = currentScore.playerName + " (" + duration + ")"; if (count == 1) { firstPlaceText.text = boardEntry; } else if (count == 2) { secondPlaceText.text = boardEntry; } else if (count == 3) { thirdPlaceText.text = boardEntry; } if (count >= maxToDisplay) { break; } } if (count == 0) { firstPlaceText.text = ""; } if (count > 0 && count <= 1) { secondPlaceText.text = ""; } if (count > 1 && count < maxToDisplay) { thirdPlaceText.text = ""; } } } else { /* * * GUILayoutOption[] width200 = new GUILayoutOption[] {GUILayout.Width(200)}; * * float width = 400; // Make this wider to add more columns * float height = 200; * * Rect r = new Rect((Screen.width / 2) - (width / 2), (Screen.height / 2) - (height), width, height); * GUILayout.BeginArea(r, new GUIStyle("box")); * * GUILayout.BeginVertical(); * GUILayout.Label("Time Left:" + this.timeLeft.ToString("0.000")); * if (this.gs == gameState.waiting || this.gs == gameState.running) * { * if (GUILayout.Button("Click me as much as you can in " + this.startTime.ToString("0") + " seconds!")) * { * this.totalScore++; * this.gs = gameState.running; * } * * GUILayout.Label("Total Score: " + this.totalScore.ToString()); * } * * * * if (this.gs == gameState.enterscore) * { * GUILayout.Label("Total Score: " + this.totalScore.ToString()); * GUILayout.BeginHorizontal(); * GUILayout.Label("Your Name: "); * this.playerName = GUILayout.TextField(this.playerName, width200); * * if (GUILayout.Button("Save Score")) * { * // add the score... * if (dl.publicCode == "") Debug.LogError("You forgot to set the publicCode variable"); * if (dl.privateCode == "") Debug.LogError("You forgot to set the privateCode variable"); * * dl.AddScore(this.playerName, totalScore); * * this.gs = gameState.leaderboard; * } * GUILayout.EndHorizontal(); * } * * if (this.gs == gameState.leaderboard) * { * GUILayout.Label("High Scores:"); * List<dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); * * if (scoreList == null) * { * GUILayout.Label("(loading...)"); * } * else * { * int maxToDisplay = 20; * int count = 0; * foreach (dreamloLeaderBoard.Score currentScore in scoreList) * { * count++; * GUILayout.BeginHorizontal(); * GUILayout.Label(currentScore.playerName, width200); * GUILayout.Label(currentScore.score.ToString(), width200); * GUILayout.EndHorizontal(); * * if (count >= maxToDisplay) break; * } * } * } * GUILayout.EndArea(); * * r.y = r.y + r.height + 20; * * GUILayout.BeginArea(r, new GUIStyle("box")); * GUILayout.BeginHorizontal(); * GUILayout.Label("Redeem Code: "); * this.code = GUILayout.TextField(this.code, width200); * * if (GUILayout.Button("Redeem")) * { * this.pc.RedeemCode(this.code); * } * GUILayout.EndHorizontal(); * * GUILayout.Space(50); * if (this.pc != null) * { * GUILayout.Label("State: " + this.pc.state.ToString()); * GUILayout.Label("Error: " + this.pc.error); * GUILayout.Label("Value: " + this.pc.value); * } * * GUILayout.EndVertical(); * GUILayout.EndArea(); */ } }
/** * Update is called once per frame. */ void Update() { OVRInput.Update(); // Display the number of cycles left in the therapy. ScoreText.GetComponent <Text>().text = "Cycles Left: " + (numOfCycles - cycleCounter).ToString(); // Set game over to true once the therapy rounds are completed. if (cycleCounter == numOfCycles) { gameOver = true; } if (!gameOver) { leader.SetActive(false); // If there are stones left, bring towards the player on inhale. if (canSummon && Input.GetKey(KeyCode.Space) || OVRInput.Get(OVRInput.RawButton.RIndexTrigger) || flag == 1) { if (count == stones.Count) { Debug.Log("No more stones left"); } else { cont = stones[count].GetComponent <ParabolaController>(); isMovingTowardsPlayer = true; //vfx[count].transform.GetChild(0).gameObject.SetActive(false); if (stoneHandUpdate) { CanvasText.GetComponent <Text>().text = "Inhale Target Time: " + inhaleTime.ToString(); coroutineInhale = StartCoroutine(countDownInhale(inhaleTime)); stoneHandDistance = Vector3.Distance(stones[count].transform.position, transform.position); stoneHandDistance -= 0.4f; stoneHandUpdate = false; } if (Vector3.Distance(stones[count].transform.position, transform.position) > 0.45f) { stones[count].transform.position = Vector3.MoveTowards(stones[count].transform.position, transform.position + transform.forward * 0.4f - transform.up * 0.1f, Time.deltaTime * (stoneHandDistance / inhaleTime)); } } } // called if player stops inhaling before stone reaches the player //else if (move && flag!=1 && Vector3.Distance(stones[count].transform.position, transform.position) > 0.2f) else if (isMovingTowardsPlayer && !Input.GetKey(KeyCode.Space) && Vector3.Distance(stones[count].transform.position, transform.position) > 0.45f) { stones[count].GetComponent <Rigidbody>().useGravity = true; StopCoroutine(coroutineInhale); //vfx[count].SetActive(false); count++; isMovingTowardsPlayer = false; stoneHandUpdate = true; cycleCounter++; } // for the stone to always be in front of the camera if (Vector3.Distance(stones[count].transform.position, this.transform.position) <= 0.45f) { stones[count].transform.position = transform.position + transform.forward * 0.4f - transform.up * 0.1f; //stones[count].transform.rotation = new Quaternion(0.0f, transform.rotation.y, 0.0f, transform.rotation.w); } // When stone has arrived if ((Input.GetKey(KeyCode.D) || OVRInput.Get(OVRInput.RawButton.A) || flag == 3) && Vector3.Distance(stones[count].transform.position, this.transform.position) <= 0.45f && fruitCount < fru.Count && s.stay) { vfx[count].SetActive(true); //vfx[count].transform.GetChild(0).gameObject.SetActive(true); isMovingTowardsPlayer = false; canShoot = true; canSummon = false; GameObject.Find("Trails").GetComponent <ParticleSystem>().Play(); GameObject point1 = new GameObject(); GameObject point2 = new GameObject(); GameObject point3 = new GameObject(); GameObject root = new GameObject(); point1.name = "child1"; point2.name = "child2"; point3.name = "child3"; root.name = "parent"; point1.transform.parent = root.transform; point2.transform.parent = root.transform; point3.transform.parent = root.transform; point1.transform.position = stones[count].transform.position; point3.transform.position = s.go.transform.position; point2.transform.position = new Vector3((point1.transform.position.x + point3.transform.position.x) / 2, point3.transform.position.y + 0.3f, (point1.transform.position.z + point3.transform.position.z) / 2); if (!cont.enabled) { cont.enabled = true; } if (stoneFruitUpdate) { CanvasText.GetComponent <Text>().text = "Exhale Target Time: " + exhaleTime.ToString(); coroutineExhale = StartCoroutine(countDownExhale(exhaleTime)); stoneFruitDistance = Vector3.Distance(stones[count].transform.position, s.go.transform.position); stoneFruitDistance -= 1f; cont.Speed = stoneFruitDistance / exhaleTime; stoneFruitUpdate = false; } cont.ParabolaRoot = root; cont.Autostart = true; cont.Animation = true; cont.Speed = stoneFruitDistance / exhaleTime; } // when player stops exhaling before stone hits the fruit //else if (canShoot && flag!=3 && Vector3.Distance(stones[count].transform.position, transform.position) >= 1f) // For keyboard playability, uncomment else if below and comment out the else if on line 221. //else if (canShoot && !Input.GetKey(KeyCode.D) && Vector3.Distance(stones[count].transform.position, transform.position) >= 1f) else if (canShoot && flag != 3 && Vector3.Distance(stones[count].transform.position, transform.position) >= 1f) { stones[count].GetComponent <Rigidbody>().useGravity = true; vfx[count].SetActive(false); count++; StopCoroutine(coroutineExhale); cont.enabled = false; canSummon = true; canShoot = false; stoneHandUpdate = true; stoneFruitUpdate = true; cycleCounter++; } //When stone has hit the fruit if (s.go && count < stones.Count && stones[count] && Vector3.Distance(stones[count].transform.position, s.go.transform.position) < 1f && fruitCount < fru.Count) { var particleEffect = stones[count].transform.GetChild(0); stones[count].transform.GetChild(0).transform.parent = null; stones[count].GetComponent <Rigidbody>().useGravity = true; playPluck = true; CanvasText.GetComponent <Text>().text = "Inhale Target Time: " + inhaleTime.ToString(); Destroy(stones[count]); //toDestory.Add(vfx[count]); for (int i = 0; i < 3; i++) { GameObject.Find("stoneVFX").transform.GetChild(i).gameObject.GetComponent <ParticleSystem>().Stop(); } StartCoroutine(destory(vfx[count])); count++; s.go.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; s.go.GetComponent <Rigidbody>().isKinematic = false; s.go.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; s.go.GetComponent <Rigidbody>().useGravity = true; ParticleSystem points = s.go.transform.GetChild(1).gameObject.GetComponent <ParticleSystem>(); points.Play(); score += 5; fruitCount++; canShoot = false; canSummon = true; stoneHandUpdate = true; stoneFruitUpdate = true; cycleCounter++; } } else { ScoreText.GetComponent <Text>().text = ""; CanvasText.GetComponent <Text>().text = ""; FinalScoreText.GetComponent <Text>().text = "Final Score: " + score + "/" + (numOfCycles * 5); leader.SetActive(true); if (fwLeaderBoard.publicCode == "") { Debug.LogError("You forgot to set the publicCode variable"); } if (fwLeaderBoard.privateCode == "") { Debug.LogError("You forgot to set the privateCode variable"); } fwLeaderBoard.AddScore(userName, (int)(100 * score / (numOfCycles * 5))); //fwLeaderBoard.GetScores(); List <dreamloLeaderBoard.Score> scoreList = fwLeaderBoard.ToListHighToLow(); if (scoreList == null) { Debug.Log("(loading...)"); } else { int maxToDisplay = 6; int countScr = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { countScr++; //Debug.Log(currentScore.score.ToString()); topRankList.text += countScr + "\n"; topScoreList.text += currentScore.score.ToString() + "%\n"; topNameList.text += currentScore.playerName.Replace("+", " ") + "\n"; if (countScr >= maxToDisplay) { break; } } } } }
public IEnumerator GetHighScores() { // TODO deal w/ empty player names more gracefully // TODO deal with profanity in usernames? if (pilot_ID_Field.PilotID.Length <= 2) { pilot_ID_Field.PilotID = "TheUnknownComic"; pilot.ID = "FrenchConnection"; } else if (pilot_ID_Field.PilotID.Contains("BukarooBonzai")) { pilot.MasterPilot = true; } else { pilot.MasterPilot = false; } yield return(new WaitForSeconds(1.0f)); // TODO Optimize this delay? highStrings = new string[11]; int rank = 0; if (!webGL) { highScores = leaderBoard.ToListHighToLow(); highStrings[0] = ApplyColour.Blue + "Rank - Name - Score" + ApplyColour.Close + "\n"; global = false; GlobalHighScore = 0; GlobalScorer = ""; pilot.HighScore = 0; pilot.Rank = 0; foreach (dreamloLeaderBoard.Score record in highScores) { string[] userCredentials = record.playerName.Split(timeKeeper.Splitter); rank++; if (!global) { GlobalHighScore = record.score; GlobalScorer = userCredentials[0]; global = true; } if (userCredentials[0] == pilot.ID && userCredentials[1] == pilot.Unique) { pilot.HighScore = record.score; pilot.Rank = rank; } if (rank <= 10) { highStrings[rank] = (rank).ToString() + ". " + userCredentials[0]; highStrings[rank] += " " + record.score + "\n"; } } Debug.Log("Records:GetHighScores() # of Records: " + rank + " Player High: " + pilot.HighScore + ", Player Rank #" + pilot.Rank + ", ID: " + pilot.ID + " Field ID: " + pilot_ID_Field.PilotID + " Master Pilot: " + pilot.MasterPilot); totalRankings = rank; } else { highStrings[0] = "No Global Leader Board\nin WebGL Version"; } highScoreText.text = ""; foreach (string highScore in highStrings) { highScoreText.text += highScore; } PrintRecords(); }
void OnGUI() { var width200 = new GUILayoutOption[] { GUILayout.Width(Screen.width / 2.66f) }; // var width = 200; // Make this wider to add more columns // var height = 440; // var r = new Rect((Screen.width / 2) + (width / 8), (Screen.height / 2) - (height / 2), width * 2 - 50, height); var r = new Rect((Screen.width / 2) + 25, 20, Screen.width / 2 - 25, Screen.height - 50); GUI.skin.label.fontSize = (int)Screen.width / 45; GUI.skin.button.fontSize = (int)Screen.width / 45; GUILayout.BeginArea(r, new GUIStyle("box")); GUILayout.BeginVertical(); if (this.gs == gameState.waiting || this.gs == gameState.running) { GUILayout.Label("CLICK HERE TO CREATE YOUR USER_NAME"); } if (this.gs == gameState.enterscore) { if (PlayerPrefs.GetInt("HasName") == 0) { GUILayout.BeginHorizontal(); // GUILayout.Label("Your Name: "); this.playerName = GUILayout.TextField(this.playerName, width200); GUI.skin.textField.fontSize = (int)Screen.width / 45; if (GUILayout.Button("Submit")) { // add the score... if (dl.publicCode == "") { Debug.LogError("You forgot to set the publicCode variable"); } if (dl.privateCode == "") { Debug.LogError("You forgot to set the privateCode variable"); } dl.AddScore(this.playerName, PlayerPrefs.GetInt("HighScoreCoin")); PlayerPrefs.SetInt("HasName", 1); this.gs = gameState.leaderboard; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); //New Try GUILayout.Label("\n Enter Your Name\n" + "\nThis will be your User_Name for all time" + "\nYou will not be able to rename it " + "\n" + "\nPlease Create your Unique User_Name"); PlayerPrefs.SetString("PlayerName", playerName); GUILayout.EndHorizontal(); } else if (PlayerPrefs.GetInt("HasName") == 1) { GUILayout.Label("You already have a UserName :- " + PlayerPrefs.GetString("PlayerName")); GUILayout.BeginHorizontal(); if (GUILayout.Button("Update LeaderBoard")) { // add the score... if (dl.publicCode == "") { Debug.LogError("You forgot to set the publicCode variable"); } if (dl.privateCode == "") { Debug.LogError("You forgot to set the privateCode variable"); } dl.AddScore(PlayerPrefs.GetString("PlayerName"), PlayerPrefs.GetInt("HighScoreCoin")); this.gs = gameState.leaderboard; } GUILayout.EndHorizontal(); } } if (this.gs == gameState.leaderboard) { GUILayout.Label("High Scores: Coin Master : "); List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); //2 if (scoreList == null) { GUILayout.Label("(loading...)"); } else { int maxToDisplay = 50; int count = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { count++; GUILayout.BeginHorizontal(); GUILayout.Label(currentScore.playerName, width200); GUILayout.Label(currentScore.score.ToString(), width200); GUILayout.EndHorizontal(); if (count >= maxToDisplay) { break; } } } } GUILayout.EndVertical(); GUILayout.EndArea(); }
void OnGUI() { var width200 = new GUILayoutOption[] { GUILayout.Width(200) }; var width = 400; // Make this wider to add more columns var height = 200; var r = new Rect((Screen.width / 2) - (width / 2), (Screen.height / 2) - (height), width, height); GUILayout.BeginArea(r, new GUIStyle("box")); GUILayout.BeginVertical(); GUILayout.Label("Time Left:" + this.timeLeft.ToString("0.000")); if (this.gs == gameState.waiting || this.gs == gameState.running) { if (GUILayout.Button("Click me as much as you can in " + this.startTime.ToString("0") + " seconds!")) { this.totalScore++; this.gs = gameState.running; } GUILayout.Label("Total Score: " + this.totalScore.ToString()); } if (this.gs == gameState.enterscore) { GUILayout.Label("Total Score: " + this.totalScore.ToString()); GUILayout.BeginHorizontal(); GUILayout.Label("Your Name: "); this.playerName = GUILayout.TextField(this.playerName, width200); if (GUILayout.Button("Save Score")) { // add the score... if (dl.publicCode == "") { Debug.LogError("You forgot to set the publicCode variable"); } if (dl.privateCode == "") { Debug.LogError("You forgot to set the privateCode variable"); } dl.AddScore(this.playerName, totalScore); this.gs = gameState.leaderboard; } GUILayout.EndHorizontal(); } if (this.gs == gameState.leaderboard) { GUILayout.Label("High Scores:"); List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow(); Debug.Log(scoreList.Count); if (scoreList == null) { GUILayout.Label("(loading...)"); } else { int maxToDisplay = 20; int count = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { count++; GUILayout.BeginHorizontal(); GUILayout.Label(currentScore.playerName, width200); GUILayout.Label(currentScore.score.ToString(), width200); GUILayout.EndHorizontal(); if (count >= maxToDisplay) { break; } } } } GUILayout.EndArea(); r.y = r.y + r.height + 20; GUILayout.BeginArea(r, new GUIStyle("box")); GUILayout.BeginHorizontal(); GUILayout.Label("Redeem Code: "); this.code = GUILayout.TextField(this.code, width200); if (GUILayout.Button("Redeem")) { this.pc.RedeemCode(this.code); } GUILayout.EndHorizontal(); GUILayout.Space(50); if (this.pc != null) { GUILayout.Label("State: " + this.pc.state.ToString()); GUILayout.Label("Error: " + this.pc.error); GUILayout.Label("Value: " + this.pc.value); } GUILayout.EndVertical(); GUILayout.EndArea(); }