public void NextScene() { string current_name = SceneManager.GetActiveScene().name; int next_ind = SceneIndices.GetIndex(current_name) + 1; string next_name = SceneIndices.GetName(next_ind); SceneManager.LoadScene(next_name); }
private void Start() { ghost_blocks = GameObject.FindGameObjectsWithTag("Ghost"); infinite_mode = GameObject.Find("UFO").GetComponent <UFO>().infinite_mode; if (infinite_mode) { ground_counter.text = "Allowed on Ground: " + (grounded_limit - 1).ToString(); } score_holder = leaderboard.transform.Find("Score Holder"); int scene_ind = SceneIndices.GetIndex(SceneManager.GetActiveScene().name); LeaderboardDriver.FindScoresForLevel(scene_ind); // If never seen level before, display intro text if (!SceneIndices.SeenLevel(scene_ind)) { SceneIndices.PlayingLevel(scene_ind); canvas.transform.Find("Intro Text").gameObject.SetActive(true); } }
private void Update() { // Send score if not sent yet and level is done if (IsLevelOver() && !score_sent) { int scene_ind = SceneIndices.GetIndex(SceneManager.GetActiveScene().name); LeaderboardDriver.PerformCreateOperation(scene_ind, score); score_sent = true; } // Read scoreboard scores as necessary if (LeaderboardDriver.Readable && IsLevelOver() && score_holder.childCount == 0) { leaderboard.transform.Find("Loading...").gameObject.SetActive(false); List <Dictionary <string, AttributeValue> > scores = LeaderboardDriver.Results; foreach (var item in scores) { if (score_holder.transform.childCount < 15) { string score_string = item["Score"].N; int score_int = int.Parse(score_string); if (score > score_int && !name_on_board) { name_on_board = true; GameObject user_score_object = Instantiate(score_prefab, score_holder); user_score_object.transform.Find("Name").GetComponent <Text>().text = LeaderboardDriver.Name; user_score_object.transform.Find("Score").GetComponent <Text>().text = score.ToString(); Color current_color = user_score_object.GetComponent <Image>().color; current_color.a = 1; user_score_object.GetComponent <Image>().color = current_color; } GameObject score_object = Instantiate(score_prefab, score_holder); score_object.transform.Find("Name").GetComponent <Text>().text = item["Name"].S; score_object.transform.Find("Score").GetComponent <Text>().text = score_string; // If we see the current user's score, check if the new one is higher if (item["Id"].S == LeaderboardDriver.Id) { if (name_on_board) { Destroy(score_object); } else { name_on_board = true; Color current_color = score_object.GetComponent <Image>().color; current_color.a = 1; score_object.GetComponent <Image>().color = current_color; } } } } if (scores.Count == 0 || (!name_on_board && scores.Count < 15)) { name_on_board = true; GameObject user_score_object = Instantiate(score_prefab, score_holder); user_score_object.transform.Find("Name").GetComponent <Text>().text = LeaderboardDriver.Name; user_score_object.transform.Find("Score").GetComponent <Text>().text = score.ToString(); Color current_color = user_score_object.GetComponent <Image>().color; current_color.a = 1; user_score_object.GetComponent <Image>().color = current_color; } } if (infinite_mode) { if (grounded_blocks >= grounded_limit) { level_done = true; fireworks.Play(); } } }