// Selected player may do dribbling while closest player try to catch the ball. private IEnumerator closestPlayerFollowTheBall(float duration) { // Call the function every frame till duration time float startTime = Time.time; while (Time.time - startTime < duration) { dribblingTime.text = LocalizeBase.GetLocalizedString("time_left") + Mathf.Round(startTime - Time.time + 5); Vector3 middlePoint = (selectedPlayer.transform.position + targetPlayer.transform.position) / 2; closest.GetComponent <PlayerAI>().catchTheBall(middlePoint); yield return(new WaitForFixedUpdate()); } GetReadyForQuestion(); button2D.gameObject.SetActive(true); // Tutorial if (watchTutorial) { Time.timeScale = 0f; showTutorial(3); watchTutorial = false; watchTutorial2 = true; } }
private string monthName(int i) { if (i == 1) { return(LocalizeBase.GetLocalizedString("january")); } else if (i == 2) { return(LocalizeBase.GetLocalizedString("febuary")); } else if (i == 3) { return(LocalizeBase.GetLocalizedString("march")); } else if (i == 4) { return(LocalizeBase.GetLocalizedString("april")); } else if (i == 5) { return(LocalizeBase.GetLocalizedString("may")); } else if (i == 6) { return(LocalizeBase.GetLocalizedString("june")); } else if (i == 7) { return(LocalizeBase.GetLocalizedString("july")); } else if (i == 8) { return(LocalizeBase.GetLocalizedString("august")); } else if (i == 9) { return(LocalizeBase.GetLocalizedString("september")); } else if (i == 10) { return(LocalizeBase.GetLocalizedString("october")); } else if (i == 11) { return(LocalizeBase.GetLocalizedString("november")); } else { return(LocalizeBase.GetLocalizedString("december")); } }
public void RenewQuestion() { if (renewQuestionCount > 0) { renewQuestionCount--; AskQuestion(false); } else { popupPanel.SetActive(true); popupPanel.GetComponentInChildren <Text>().text = LocalizeBase.GetLocalizedString("change_question_exhausted"); } }
private void loadGraphs() { // Assign text Text dateText = screens[0].transform.GetChild(1).GetComponent <Text>(); Text succesfulText = screens[0].transform.GetChild(3).GetComponent <Text>(); Text failText = screens[0].transform.GetChild(4).GetComponent <Text>(); // Assign Graphs Image succesful = screens[0].transform.GetChild(2).GetChild(1).GetComponent <Image>(); GameObject chart = screens[0].transform.GetChild(5).GetChild(0).gameObject; // Find true and false answers string[] answers = lastDate[1].Split(';'); // Set last record values dateText.text = LocalizeBase.GetLocalizedString("stats_todays_data") + lastDate[0]; succesfulText.text = LocalizeBase.GetLocalizedString("stats_correct_answers") + answers[0]; failText.text = LocalizeBase.GetLocalizedString("stats_incorrect_answers") + answers[1]; // Set circle graph // Find percentage float value = float.Parse(answers[0]) * 100 / (float.Parse(answers[0]) + float.Parse(answers[1])); // Set to graph succesful.fillAmount = value / 100; // Set chart graph // Get bar object from prefabs folder GameObject barObject = Resources.Load("Prefabs/barObject") as GameObject; // Get This month string today = System.DateTime.Now.ToString("dd/MM/yyyy"); string[] thisMonth = today.Split(delimeter); chart.transform.parent.GetChild(4).GetComponent <Text>().text = monthName(int.Parse(thisMonth[1])) + " " + LocalizeBase.GetLocalizedString("stats_months_data"); for (int i = 0; i < getWhole.Length; i++) { string[] getMonth = getWhole[i].Split(delimeter); string[] getAnswers = getWhole[i].Split('-'); string[] findAnswer = getAnswers[1].Split(';'); if (thisMonth[1] == getMonth[1]) { barObject.transform.GetChild(0).GetComponent <RectTransform>().sizeDelta = new Vector2(10f, (float.Parse(findAnswer[0]) * 5) >= 173f ? 173f : (float.Parse(findAnswer[0]) * 5)); barObject.transform.GetChild(1).GetComponent <RectTransform>().sizeDelta = new Vector2(10f, (float.Parse(findAnswer[1]) * 5) >= 173f ? 173f : (float.Parse(findAnswer[1]) * 5)); barObject.transform.GetChild(2).GetComponent <Text>().text = getMonth[0]; Instantiate(barObject, chart.transform); } } }
private string GetQuestionText() { switch (currentQuestionType) { case QuestionType.Speed_AngleToMaxH: return(String.Format(LocalizeBase.GetLocalizedString("Speed_AngleToMaxH"), currentQuestion.speed, currentQuestion.angle)); case QuestionType.Speed_AngleToMaxX: return(String.Format(LocalizeBase.GetLocalizedString("Speed_AngleToMaxX"), currentQuestion.speed, currentQuestion.angle)); case QuestionType.Speed_AngleToFlightTime: return(String.Format(LocalizeBase.GetLocalizedString("Speed_AngleToFlightTime"), currentQuestion.speed, currentQuestion.angle)); case QuestionType.MaxH_AngleToMaxX: return(String.Format(LocalizeBase.GetLocalizedString("MaxH_AngleToMaxX"), currentQuestion.maxH, currentQuestion.angle)); case QuestionType.MaxH_AngleToSpeed: return(String.Format(LocalizeBase.GetLocalizedString("MaxH_AngleToSpeed"), currentQuestion.maxH, currentQuestion.angle)); case QuestionType.MaxHToFlightTime: return(String.Format(LocalizeBase.GetLocalizedString("MaxHToFlightTime"), currentQuestion.maxH)); case QuestionType.SpeedX_FlightTimeToSpeed: return(String.Format(LocalizeBase.GetLocalizedString("SpeedX_FlightTimeToSpeed"), currentQuestion.speedX, currentQuestion.flightTime)); case QuestionType.Angle_Time_DistanceToSpeed: return(String.Format(LocalizeBase.GetLocalizedString("Angle_Time_DistanceToSpeed"), currentQuestion.angle, currentQuestion.timePassed, currentQuestion.distance)); case QuestionType.Speed_AngleToTc: return(String.Format(LocalizeBase.GetLocalizedString("Speed_AngleToTc"), currentQuestion.speed, currentQuestion.angle)); case QuestionType.Speed_Time_AngleToHeight: return(String.Format(LocalizeBase.GetLocalizedString("Speed_Time_AngleToHeight"), currentQuestion.speed, currentQuestion.angle, currentQuestion.timePassed)); case QuestionType.Speed_Time_AngleToDistance: return(String.Format(LocalizeBase.GetLocalizedString("Speed_Time_AngleToDistance"), currentQuestion.speed, currentQuestion.angle, currentQuestion.timePassed)); case QuestionType.SpeedYToMaxH: return(String.Format(LocalizeBase.GetLocalizedString("SpeedYToMaxH"), currentQuestion.speedY)); case QuestionType.SpeedX_FlightTimeToDistance: return(String.Format(LocalizeBase.GetLocalizedString("SpeedX_FlightTimeToDistance"), currentQuestion.speedX, currentQuestion.flightTime)); case QuestionType.SpeedYToFlightTime: return(String.Format(LocalizeBase.GetLocalizedString("SpeedYToFlightTime"), currentQuestion.speedY)); } return("An error occured."); }
public void DisplayInfoSprites(int angle, int distance) { // Put 2D Sprites // Distance Transform distanceS = distanceSprite.transform.GetChild(0); distanceSprite.transform.position = (selectedPlayer.transform.position + targetPlayer.transform.position) / 2; distanceS.LookAt(targetPlayer.transform); distanceS.localEulerAngles = new Vector3(0, distanceS.localEulerAngles.y + 90f, 0);; distanceS.GetComponent <SpriteRenderer>().size = new Vector2(Vector3.Distance(selectedPlayer.transform.position, targetPlayer.transform.position), 0.2f); distanceSprite.transform.GetChild(1).GetComponent <TextMesh>().text = LocalizeBase.GetLocalizedString("distance"); distanceSprite.transform.localPosition = new Vector3(distanceSprite.transform.localPosition.x + 0.55f, -11.02f, distanceSprite.transform.localPosition.z - 5f); // Angle angleSprite.transform.position = ball.transform.position; angleSprite.transform.GetChild(1).GetComponent <TextMesh>().text = LocalizeBase.GetLocalizedString("angle") + ((angle == 0)?"a":angle.ToString()) + "°"; angleSprite.transform.GetChild(0).localEulerAngles = new Vector3(0, 0, (angle == 0) ? 60 : angle); }
public void AskQuestion(bool repeatLastQuestion) { if (!repeatLastQuestion) { // Switch to question UI gamePanel.SetActive(false); questionPanel.SetActive(true); incorrectAnswerCount = 0; // Get a random question type currentQuestionType = questionTypes[random.Next(questionTypes.Length)]; // Get a random question of that type currentQuestion = questions[currentQuestionType][random.Next(questions[currentQuestionType].Length)]; levelManager.DisplayInfoSprites(currentQuestion.angle, currentQuestion.distance); questionTitle.text = LocalizeBase.GetLocalizedString("question_title"); questionText.text = GetQuestionText(); help.GetComponent <Image>().sprite = Resources.Load <Sprite>("Textures/" + LocalizeBase.GetLocalizedString("help")); answerText.text = currentQuestion.result.ToString(); Debug.Log("Answer: " + currentQuestion.result); } else { // when the incorrectAnswerCount hits 4, show the correct answer, other wise show wrong answer message if (incorrectAnswerCount > 3) { popupPanel.GetComponentInChildren <Text>().text = String.Format(LocalizeBase.GetLocalizedString("reveal_correct_answer"), currentQuestion.result); popupPanel.SetActive(true); } else { // Show the wrong indication trueOrFalse.GetComponent <Text>().color = Color.red; trueOrFalse.GetComponent <Text>().text = LocalizeBase.GetLocalizedString("incorrect"); trueOrFalse.GetComponent <Animator>().SetTrigger("setAnim"); ClosePopup(); } } }
private void GetReadyForQuestion() { // Reset text dribblingTime.text = LocalizeBase.GetLocalizedString("time_left") + 5; // Look at the selected. closest.transform.LookAt(selectedPlayer.transform); // Trigger head animation if (selectedPlayer.name != "bluePlayer6") { StartCoroutine(closest.GetComponent <PlayerAI>().head(ball)); } // After time finishes // Movement disabled and ready for shoot // Disable him to move selectedPlayer.GetComponent <PlayerControl>().canMove = false; //Turn the player towards his next passing mate selectedPlayer.transform.LookAt(targetPlayer.transform); // Ready for shoot selectedPlayer.GetComponent <Animator>().SetBool("readyForShoot", true); // Make invisible the Text dribblingTime.gameObject.SetActive(false); // Put ball in front of player putBallInfrontOfPlayer(); // Hide joystick joystick.gameObject.SetActive(false); // Brings up the question UI and holds the control until player answeres correctly questionManager.AskQuestion(false); Sprites2D.SetActive(false); }
public void playerGotTheBall() { // This function is called from PlayerAI.OnCollisionEnter button2D.gameObject.SetActive(false); // Show the true indication questionManager.trueOrFalse.GetComponent <Text>().color = Color.green; questionManager.trueOrFalse.GetComponent <Text>().text = LocalizeBase.GetLocalizedString("correct"); questionManager.trueOrFalse.GetComponent <Animator>().SetTrigger("setAnim"); //Remove the ball collider from the ball so that when the player is dribbling the ball, the collider on ball doesn't get triggered Destroy(ball.GetComponent("BallCollider")); Time.timeScale = 1f; Mode2D(false); Sprites2D.SetActive(false); // Hide ball target object ballTarget.transform.position = Vector3.zero; // Remove the PlayerControl script from current shooting player Destroy(selectedPlayer.GetComponent <PlayerControl>()); // Destroy closes component if (closest != null) { Destroy(closest.GetComponent <PlayerAI>()); } // New selected Player is target Player selectedPlayer = targetPlayer; selectedPlayer.AddComponent <PlayerControl>(); // Give ball and Joystick Reference selectedPlayer.GetComponent <PlayerControl>().joystick = joystick; selectedPlayer.GetComponent <PlayerControl>().ball = ball; // Makes timer visible dribblingTime.gameObject.SetActive(true); // Close Joystick joystick.gameObject.SetActive(false); // Reset bounce ball.GetComponent <SphereCollider>().material = null; // Disable him to move selectedPlayer.GetComponent <PlayerControl>().canMove = false; // Enable him to select target targetSelect = true; // Put ball in front of player putBallInfrontOfPlayer(); // Show indication signs for targets. showIndicationforTargets(); // Close indication from selected && add selected indication selectedPlayer.transform.GetChild(2).gameObject.SetActive(false); selectedPlayer.transform.GetChild(3).gameObject.SetActive(true); mainCamera.gameObject.SetActive(true); camera2D.gameObject.SetActive(false); if (selectedPlayer.name == "bluePlayer6") { selectedPlayer.transform.LookAt(redPlayers.transform.GetChild(0)); // Put ball in front of player putBallInfrontOfPlayer(); mainCamera.GetComponent <CameraController>().player = selectedPlayer; goalTargets.SetActive(true); // Tutorial if (watchTutorial2) { showTutorial(7); } } }