public void UpdateTotals(Minigames from) { Dictionary <int, int> tmpTotals = new Dictionary <int, int>(globalRanking[Minigames.LB_TOTAL]); string aaa = ""; foreach (KeyValuePair <Minigames, Dictionary <int, int> > kvp in globalRanking) { aaa += "[" + kvp.Key + ":" + kvp.Value[0] + "]"; } print("GRIUTBFA : " + aaa); foreach (KeyValuePair <int, int> kvp in globalRanking[from]) { tmpTotals[kvp.Key] += globalRanking[from][kvp.Key]; } globalRanking[Minigames.LB_TOTAL] = tmpTotals; string tmpsc3 = ""; foreach (KeyValuePair <Minigames, Dictionary <int, int> > kvp in globalRanking) { tmpsc3 += "[" + kvp.Key + ":" + kvp.Value[0] + "]"; } print("GRIUTAA : " + tmpsc3); globalRanking = OrderScores(globalRanking); }
private void Button1_Click(object sender, RoutedEventArgs e) { if (textBox.Text != "") { GlobalRandom.rnd = new Random(Convert.ToInt32(textBox.Text)); } if (checkBox.IsChecked == true) { Courses.Shuffle(); } if (checkBox1.IsChecked == true) { Hubs.Shuffle(checkBox7.IsChecked ?? false); } if (checkBox2.IsChecked == true) { Rewards.Shuffle(); } if (checkBox3.IsChecked == true) { NPCCoords.Shuffle(); } if (checkBox4.IsChecked == true) { Minigames.Shuffle(); } if (checkBox5.IsChecked == true) { NPCMind.Shuffle(); } if (checkBox6.IsChecked == true) { Unlocks.Shuffle(); } string[] delete = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.new"); foreach (string file in delete) { File.Delete(file); } MessageBox.Show("Done!"); }
/// <summary> /// Converts an enum to its string equivalent e.g. Minigames.Civil -> "Civil" /// </summary> /// <param name="minigame">the minigame to get a string representation of</param> /// <returns>the text representation of that <paramref name="minigame"/></returns> /// <exception cref="ArgumentOutOfRangeException">if the minigame cannot be mapped to a string</exception> private string ToText(Minigames minigame) { switch (minigame) { case Minigames.Software: return("Software"); case Minigames.Civil: return("Civil"); case Minigames.Electrical: return("Electrical"); default: throw new ArgumentOutOfRangeException("minigame", minigame, null); } }
/// <summary> /// Get all the scores for the given <paramref name="minigame"/> /// </summary> /// <param name="minigame">the minigame to get all the scores for</param> /// <returns>the list of scores for that minigame</returns> /// <exception cref="ArgumentOutOfRangeException">if the minigame does not support scores</exception> public List <Score> Get(Minigames minigame) { switch (minigame) { case Minigames.Software: return(Software); case Minigames.Civil: return(Civil); case Minigames.Electrical: return(Electrical); default: throw new ArgumentOutOfRangeException(); } }
private void Awake() { DontDestroyOnLoad(gameObject); var parrent = GameObject.Find("Minigames"); if (parrent != null) { foreach (Transform item in parrent.transform) { var minigame = item.gameObject.GetComponent <Minigame>(); if (Minigames != null && item.gameObject.activeInHierarchy) { Minigames.Add(minigame); } } } foreach (var item in playerHats) { item.GetComponent <PlayerHat>().IsAvailable = true; } }
/// <summary> /// Requests the view to switch tab to the provided <paramref name="minigame"/> /// </summary> /// <param name="minigame">the minigame to show hiscores for</param> private void ChooseTab(Minigames minigame) { HiscoreController.Minigame = minigame; }
/// <summary> /// Display the scores for the given <paramref name="minigame"/> /// </summary> /// <param name="minigame">the minigame to show scores for</param> /// <returns>Co-routine to run</returns> private IEnumerator Display(Minigames minigame) { // Clear any existing children in the view while (transform.childCount != 0) { foreach (Transform child in transform) { Destroy(child.gameObject); } yield return(null); } var scores = Toolbox.Instance.Hiscores.Get(minigame); // Keep a track of the y position to place the new score - the initial value is the top padding var y = 32.0f; // Add each of the scores to the view foreach (var score in scores) { var view = Instantiate(ScorePrefab); view.transform.Find("Name").GetComponent <Text>().text = score.Minigame.ToString(); view.transform.Find("Date").GetComponent <Text>().text = score.CreatedAt.ToShortDateString(); var scoreText = view.transform.Find("Score").GetComponent <Text>(); scoreText.text = score.Value < 1 ? "Completed" : "Scored " + score.Value; view.transform.SetParent(transform); var rt = view.GetComponent <RectTransform>(); rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, y, rt.sizeDelta.y); var offsetMax = rt.offsetMax; offsetMax.x = 0; rt.offsetMax = offsetMax; var offsetMin = rt.offsetMin; offsetMin.x = 0; rt.offsetMin = offsetMin; y += rt.sizeDelta.y; yield return(null); } // Layout the parent & scroll view var rectTransform = transform.GetComponent <RectTransform>(); var sizeDelta = rectTransform.sizeDelta; sizeDelta.y = y; rectTransform.sizeDelta = sizeDelta; transform.parent.GetComponent <RectTransform>().sizeDelta = sizeDelta; // If there were no scores found then display the empty view - tell the user there are no scores if (scores.Count == 0) { var view = Instantiate(NoScoresTextPrefab); view.transform.SetParent(transform); view.transform.localPosition = new Vector3(0, 25, 0); var rectParent = transform.parent.GetComponent <RectTransform>(); rectParent.sizeDelta = new Vector2(rectParent.sizeDelta.x, 300); } }