private void Update() { Time_Value.text = CalculateUnity.ChangeTotalTime(GameStart.Instance.TimeLeftSecond); Time_Bar.fillAmount = GameStart.Instance.TimeLeftSecond * 1f / HOGGameSettingGenerator.Instance.GameSetting.TrainTime;//GameStart.Instance.TrainTime; Score_Value.text = GameStart.Instance.CurrentGameRecorder.Score.ToString(); }
/// <summary> /// Add score to experience and calculate the level of player. /// </summary> /// <param name="givenScore"></param> void AddExp(int givenScore) { PlayerExp += givenScore; GameStart.Instance.CurrentGameRecorder.Score += givenScore; int tempLevel = PlayerLevel; if (CalculateUnity.LevelUpCalculator(ref tempLevel, PlayerExp, GameStart.Instance.NextLevelExp)) { GameStart.Instance.GetNextLevelExp(tempLevel); PlayerLevel = tempLevel; GameStart.Instance.OpenOrCloseMessagePage(true, HiddenObjectPage.HOGUILevelUp); } // Add number of movement MainCore.Instance.AddMovementCount(); }
/// <summary> /// This function add 1 to the number of found objects, and then checks if we found all the hidden objects to win the level. /// The function is called from the hidden object itself when you click it. The hidden object has a HOGHiddenObject script attached to it which detects the click. /// </summary> IEnumerator UpdateFoundObjects() { //Debug.Log("<color=orange>UpdateFoundObjects!!</color>"); //Remove one of the hidden object icons, if they exist if (showIconsOnTop == true) { //if ( topBar.Find("HiddenIcon" + (numberOfHiddenObjects - foundObjects - 1)) ) Destroy(topBar.Find("HiddenIcon" + (numberOfHiddenObjects - foundObjects - 1)).gameObject); if (topBar.Find("HiddenIcon" + (numberOfHiddenObjects - foundObjects - 1))) { //Play the object's find animation topBar.Find("HiddenIcon" + (numberOfHiddenObjects - foundObjects - 1)).SendMessage("ObjectIcon"); //Wait a default time of 0.1 second yield return(new WaitForSeconds(0.1f)); //Remove the object icon Destroy(topBar.Find("HiddenIcon" + (numberOfHiddenObjects - foundObjects - 1)).gameObject); } } //Increase the number of found objects foundObjects++; roundScore = CalculateUnity.FinalScore(GameStart.Instance.MinTargetScore, GameStart.Instance.MaxTargetScore); //Reset hint timer hintTimeCount = 0; //If we find all the hidden objects we win the level if (foundObjects < numberOfHiddenObjects) { if (GetComponent <AudioSource>()) { GetComponent <AudioSource>().PlayOneShot(audioFind); } } else { if (GetComponent <AudioSource>()) { GetComponent <AudioSource>().PlayOneShot(audioWin); } _timerWithoutFound = 0; Win(roundScore); } }
public void EnableProgressBar(bool isEnabled) { if (_progressBar == null) { return; } _canCount = isEnabled; if (isEnabled) { //Vector2 anchorePos = RectTransformUtility.WorldToScreenPoint(Camera.main, CenterAnchor.position); Vector3 anchorePos = CalculateUnity.WorldPositionToScreenPoint(_collisionObj[_enterNum - 1].transform.position); anchorePos.x -= _progressBar.GetComponent <RectTransform>().sizeDelta.x / 2; anchorePos.y += ProgressBarOffset; _progressBar.GetComponent <RectTransform>().anchoredPosition = anchorePos; } _progressBar.SetActive(isEnabled); }
/// <summary> /// This function wins a level. It pauses the game and applies the score based on the level we are at and the number of seconds left on the timer. Then it creates the next level. /// </summary> void Win(int scoreNum) { PauseTimer(); //Activate the score bar which contains the level score and totalScore scoreBar.gameObject.SetActive(true); //Play the score bar intro animation scoreBar.GetComponent <Animation>().Play(screenIntroAnimation.name); // Set multiple of score int multipleOfScore = 1; //If we have a top bar assigned, show the victory message and add bonus time to the timer if (topBar) { //If we assigned victory messages, choose one of them randomly and display it in the top bar if (victoryMessage.Length > 0) { if (scoreNum != 0) { topBar.Find("Base/FindObjectText").GetComponent <TextMesh>().text = topBar.Find("Base/FindObjectText/Shadow").GetComponent <TextMesh>().text = victoryMessage[Mathf.FloorToInt(Random.Range(0, victoryMessage.Length - 1))]; multipleOfScore = CalculateUnity.GetPreciousValue(); AddExp(scoreNum * multipleOfScore); } else { topBar.Find("Base/FindObjectText").GetComponent <TextMesh>().text = topBar.Find("Base/FindObjectText/Shadow").GetComponent <TextMesh>().text = victoryMessage[victoryMessage.Length - 1]; int leftNum = numberOfHiddenObjects - foundObjects; for (int i = leftNum; i > 0; i--) { //Remove the object icon Destroy(topBar.Find("HiddenIcon" + (i - 1)).gameObject); } } } ////Show the extra time we got on the timer //topBar.Find("Base/TimerText").GetComponent<TextMesh>().text = topBar.Find("Base/TimerText").Find("Shadow").GetComponent<TextMesh>().text = timeLeft.ToString("00");// + " +" + timeChange.ToString(); } //If we have a score bar, show the level score and the total score if (scoreBar) { //Show the level score //scoreBar.Find("Base/RoundScore").GetComponent<TextMesh>().text = scoreBar.Find("Base/RoundScore").Find("Shadow").GetComponent<TextMesh>().text = "+" + (timeBonus * Mathf.RoundToInt(timeLeft)).ToString(); string textShow = string.Empty; if (scoreNum == 0 || multipleOfScore == 1) { textShow = string.Format("+ {0}", scoreNum); } else { textShow = string.Format(GameStart.Instance.RewardString + scoreNum * multipleOfScore, multipleOfScore); } scoreBar.Find("Base/RoundScore").GetComponent <TextMesh>().text = scoreBar.Find("Base/RoundScore").Find("Shadow").GetComponent <TextMesh>().text = textShow; //Add the level score to the total score //totalScore += timeBonus * Mathf.RoundToInt(timeLeft); //totalScore += scoreNum; ////Show the total score //scoreBar.Find("Base/TotalScore").GetComponent<TextMesh>().text = scoreBar.Find("Base/TotalScore").Find("Shadow").GetComponent<TextMesh>().text = (scoreNum*multipleOfScore).ToString(); ////Increas the time bonus for the next level //timeBonus += timeBonusChange; } //Clear the objects from the area ClearObjects(false); Invoke("NextRound", nextRoundDelay); }