// Update is called once per frame void Update() { // Wait for all responses if (gameLogic.GetComponent <GameStats>().allTeamsReady() && !showOptions) { showOptions = true; GameObject.FindGameObjectWithTag("ScreenText").GetComponent <TextMeshProUGUI>().text = "<b> Vind de echte titel tussen de verzonnen titels van de andere teams. Je verdient bonuspunten als jullie titel geraden wordt door een van de teams! </b>"; GameObject.FindGameObjectWithTag("ScreenText").GetComponent <TextMeshProUGUI>().fontSize = 32; // reset readiness foreach (var team in gameLogic.GetComponent <GameStats>().getTeams()) { gameLogic.GetComponent <GameStats>().getTeam(team.getTeamDeviceID()).setTeamReady(false); } // Create list of all headlines // Shuffle answers indices = Enumerable.Range(0, gameLogic.GetComponent <GameStats>().amountOfTeams() + 1).ToList(); Shuffle(indices); headlineScores = new List <HeadlineScores>(); int i = 0; foreach (var team in gameLogic.GetComponent <GameStats>().getTeams()) { int idx = indices[i]; headlineScores.Add(new HeadlineScores(team.getTeamDeviceID(), team.getStringAnswer(), 0, options[idx], idx)); buttons[idx].SetActive(true); string buttonText = "<b>" + options[idx] + "</b>: " + team.getStringAnswer(); string tempString = ""; foreach (char c in buttonText) { char newC = c; if (char.GetUnicodeCategory(c) == UnicodeCategory.SpaceSeparator) { tempString += " "; } else { tempString += newC; } } buttons[idx].GetComponent <Button>().GetComponentInChildren <TextMeshProUGUI>().text = tempString; print("device" + team.getTeamDeviceID() + " idx" + idx + " headline " + team.getStringAnswer()); i++; } // Set true headline trueAnswer = options[indices[i]]; buttons[indices[i]].SetActive(true); buttons[indices[i]].GetComponent <Button>().GetComponentInChildren <TextMeshProUGUI>().text = "<b>" + options[indices[i]] + "</b>: " + trueHeadline; print("set view to 4"); // Send instructions to controller to change to Input layout gameLogic.GetComponent <AIComponent>().SetView("view-4"); transition = true; } else if (gameLogic.GetComponent <GameStats>().halfTeamsReady() && transition) { foreach (string t in gameLogic.GetComponent <GameStats>().NotReadyTeams()) { if (hurryUpData["hurryup"] == null) { hurryUpData.Add("hurryup", "headlines_choose"); } else { hurryUpData["hurryup"] = "headlines_choose"; } AirConsole.instance.Message(int.Parse(t), hurryUpData); } transition = false; } else if (gameLogic.GetComponent <GameStats>().allTeamsReady() && onlyDoOnce) { AIComponent ai = GameObject.FindGameObjectWithTag("GameLogic").GetComponent <AIComponent>(); string feedback = "false"; // go through all teams foreach (var team in gameLogic.GetComponent <GameStats>().getTeams()) { // Check if the team voted for the true headline string answer = team.getStringAnswer(); if (answer.Equals(trueAnswer)) { ai.addAIData(0.8f, 0.2f, true); team.addScore(100); foreach (HeadlineScores h in headlineScores) { if (h.DeviceId == team.getTeamDeviceID()) { h.Score += 100; } } } // when the team did not pick the true headline, they can still get points if other teams voted for their headline else { ai.addAIData(0.8f, 0.2f, false); foreach (HeadlineScores h in headlineScores) { if (h.DeviceId == team.getTeamDeviceID()) { h.TrueAnswer = false; } if (h.Option.Equals(answer) && h.DeviceId != team.getTeamDeviceID()) { h.FooledTeams += 1; gameLogic.GetComponent <GameStats>().getTeam(h.DeviceId).addScore(100); h.Score += 100; } } } } // Send special feedback if people fooled other teams foreach (HeadlineScores h in headlineScores) { feedback = ""; System.Random rnd = new System.Random(); if (h.TrueAnswer) { feedback += "Jullie antwoord was goed! ✅ \r\n " + h_pf[rnd.Next(0, h_pf.Count - 1)] + " \r\n \r\n"; } else { feedback += "Jullie antwoord was helaas fout 😥 \r\n \r\n" + h_nf[rnd.Next(0, h_pf.Count - 1)] + " \r\n \r\n "; } if (h.FooledTeams > 0) { feedback += "Je team heeft een aantal andere teams voor de gek gehouden, goed gedaan! ✅ \r\n \r\n"; } if (h.Score == 100) { feedback += "Je hebt 💯 nieuwe volgers 😍"; } else if (h.Score != 0) { feedback += "Je hebt " + h.Score + " nieuwe volgers 😍"; } if (feedbackData["headlines"] == null) { feedbackData.Add("headlines", feedback); } else { feedbackData["headlines"] = feedback; } print(feedback); AirConsole.instance.Message(h.DeviceId, feedbackData); } // Show only true headline --> Get buttons and set them to inactive for (int i = 0; i < buttons.Count; i++) { if (i != indices[indices.Count - 1]) { buttons[i].SetActive(false); } } GameObject.FindGameObjectWithTag("ScreenText").GetComponent <TextMeshProUGUI>().text = "<b> Dit is de echte! </b>"; GameObject.FindGameObjectWithTag("ScreenText").GetComponent <TextMeshProUGUI>().fontSize = 72; // Wait for X seconds and go to next screen onlyDoOnce = false; AirConsole.instance.onMessage -= OnMessage; StartCoroutine(WaitForSecondsThenSwitchScene(waitTime)); } else if (gameLogic.GetComponent <GameStats>().halfTeamsReady() && Once) { foreach (string t in gameLogic.GetComponent <GameStats>().NotReadyTeams()) { if (hurryUpData["hurryup"] == null) { hurryUpData.Add("hurryup", "headlines"); } else { hurryUpData["hurryup"] = "headlines"; } AirConsole.instance.Message(int.Parse(t), hurryUpData); } Once = false; } }
void Update() { // Wait for all responses if (gameLogic.GetComponent <GameStats>().allTeamsReady() && onlyDoOnce) { // Show answer stampObject.GetComponent <StampScript>().showStamp(trueAnswer); AIComponent ai = GameObject.FindGameObjectWithTag("GameLogic").GetComponent <AIComponent>(); //Gather answers and give points foreach (Team t in GameObject.FindGameObjectWithTag("GameLogic").GetComponent <GameStats>().getTeams()) { string feedback = "false"; bool answer = t.getBoolAnswer(); if (answer == trueAnswer) { //When the team gave a correct answer ai.addAIData(0.0f, 1.0f, true); t.addScore(100); feedback = "true"; if (feedbackData["realfake"] == null) { feedbackData.Add("realfake", feedback); } else { feedbackData["realfake"] = feedback; } AirConsole.instance.Message(t.getTeamDeviceID(), feedbackData); } else { //When the team gave a wrong answer ai.addAIData(0.0f, 1.0f, false); if (feedbackData["realfake"] == null) { feedbackData.Add("realfake", feedback); } else { feedbackData["realfake"] = feedback; } AirConsole.instance.Message(t.getTeamDeviceID(), feedbackData); } } // Wait for X seconds and go to next screen onlyDoOnce = false; AirConsole.instance.onMessage -= OnMessage; StartCoroutine(WaitForSecondsThenSwitchScene(waitTime)); } else if (gameLogic.GetComponent <GameStats>().halfTeamsReady() && Once) { foreach (string t in gameLogic.GetComponent <GameStats>().NotReadyTeams()) { if (hurryUpData["hurryup"] == null) { hurryUpData.Add("hurryup", "realfake"); } else { hurryUpData["hurryup"] = "realfake"; } AirConsole.instance.Message(int.Parse(t), hurryUpData); } Once = false; } }
// Update is called once per frame void Update() { // Wait for all responses if (gameLogic.GetComponent <GameStats>().allTeamsReady() && onlyDoOnce) { // Show correct order of matching GameObject.FindGameObjectWithTag("ScreenText").GetComponent <TextMeshProUGUI>().text = "<b> Dat is de juiste match! </b>"; Dictionary <int, string> intToLetter = new Dictionary <int, string>() { { 0, "A" }, { 1, "B" }, { 2, "C" }, { 3, "D" } }; IEnumerator <string> matchesEnumerator = dict.Values.GetEnumerator(); matchesEnumerator.MoveNext(); int idx = purposes.IndexOf(matchesEnumerator.Current); GameObject.FindGameObjectWithTag("Source A").GetComponent <Button>().GetComponentInChildren <TextMeshProUGUI>().text = "<b> " + intToLetter[idx] + " </b>: " + matchesEnumerator.Current; matchesEnumerator.MoveNext(); idx = purposes.IndexOf(matchesEnumerator.Current); GameObject.FindGameObjectWithTag("Source B").GetComponent <Button>().GetComponentInChildren <TextMeshProUGUI>().text = "<b> " + intToLetter[idx] + " </b>: " + matchesEnumerator.Current; matchesEnumerator.MoveNext(); idx = purposes.IndexOf(matchesEnumerator.Current); GameObject.FindGameObjectWithTag("Source C").GetComponent <Button>().GetComponentInChildren <TextMeshProUGUI>().text = "<b> " + intToLetter[idx] + " </b>: " + matchesEnumerator.Current; matchesEnumerator.MoveNext(); idx = purposes.IndexOf(matchesEnumerator.Current); GameObject.FindGameObjectWithTag("Source D").GetComponent <Button>().GetComponentInChildren <TextMeshProUGUI>().text = "<b> " + intToLetter[idx] + " </b>: " + matchesEnumerator.Current; AIComponent ai = GameObject.FindGameObjectWithTag("GameLogic").GetComponent <AIComponent>(); //Gather answers and give points foreach (Team t in GameObject.FindGameObjectWithTag("GameLogic").GetComponent <GameStats>().getTeams()) { string feedback = "false"; List <int> matches = t.getMatches(); List <string> m = new List <string>() { purposes[matches[0]], purposes[matches[1]], purposes[matches[2]], purposes[matches[3]] }; print("answers: "); foreach (string i in m) { print(i); } print("values:"); foreach (string j in dict.Values.ToList()) { print(j); } if (dict.Values.ToList().SequenceEqual(m)) { //When the team gave a correct answer ai.addAIData(1.0f, 0.0f, true); t.addScore(100); feedback = "true"; if (feedbackData["matching"] == null) { feedbackData.Add("matching", feedback); } else { feedbackData["matching"] = feedback; } AirConsole.instance.Message(t.getTeamDeviceID(), feedbackData); } else { //When the team gave a wrong answer ai.addAIData(1.0f, 0.0f, false); if (feedbackData["matching"] == null) { feedbackData.Add("matching", feedback); } else { feedbackData["matching"] = feedback; } AirConsole.instance.Message(t.getTeamDeviceID(), feedbackData); } } // Wait for X seconds and go to next screen foreach (Team t in GameObject.FindGameObjectWithTag("GameLogic").GetComponent <GameStats>().getTeams()) { GameObject.FindGameObjectWithTag("GameLogic").GetComponent <GameStats>().getTeam(t.getTeamDeviceID()).clearMatches(); } onlyDoOnce = false; AirConsole.instance.onMessage -= OnMessage; StartCoroutine(WaitForSecondsThenSwitchScene(waitTime)); } else if (gameLogic.GetComponent <GameStats>().halfTeamsReady() && Once) { foreach (string t in gameLogic.GetComponent <GameStats>().NotReadyTeams()) { if (hurryUpData["hurryup"] == null) { hurryUpData.Add("hurryup", "matching"); } else { hurryUpData["hurryup"] = "matching"; } AirConsole.instance.Message(int.Parse(t), hurryUpData); } Once = false; } }