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); } }
public void SelectLevel(string selected) { ToggleTitle(); transform.position = orig_position; switch (selected) { case "Pyramids": current_level = 1; current_target = level1; babel_title.SetActive(false); pyramids_title.SetActive(true); stonehenge_title.SetActive(false); break; case "Stonehenge": current_level = 2; current_target = level2; pyramids_title.SetActive(false); stonehenge_title.SetActive(true); eiffel_title.SetActive(false); break; case "EiffelTower": current_level = 3; current_target = level3; stonehenge_title.SetActive(false); eiffel_title.SetActive(true); pisa_title.SetActive(false); break; case "Pisa": current_level = 4; current_target = level4; eiffel_title.SetActive(false); pisa_title.SetActive(true); needle_title.SetActive(false); break; case "SpaceNeedle": current_level = 5; current_target = level5; pisa_title.SetActive(false); needle_title.SetActive(true); taj_title.SetActive(false); break; case "Taj": current_level = 6; current_target = level6; needle_title.SetActive(false); taj_title.SetActive(true); golden_gate_title.SetActive(false); break; case "GoldenGate": current_level = 7; current_target = level7; taj_title.SetActive(false); golden_gate_title.SetActive(true); babel_title.SetActive(false); break; case "Babel": current_level = 8; current_target = level8; golden_gate_title.SetActive(false); babel_title.SetActive(true); pyramids_title.SetActive(false); break; } ClearLeaderboard(); LeaderboardDriver.FindScoresForLevel(current_level); }
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(); } } }