public void RetryPlatform() { foreach (Transform tile in this.transform) { if (tile.tag == "tile" || tile.tag == "bordertile") { tile.GetComponent <TileDragBehaviour> ().ResetTile(); //Enable tile drag tile.GetComponent <TileDragBehaviour> ().EnableDrag(); } } CameraManager.ZoomOutPlatform(); currentScoreCircle.GetComponent <SpriteRenderer> ().color = InProgressColour; currentScoreCircle.GetComponentInChildren <Text> ().color = InProgressColour; GetComponentInParent <TimeManager> ().ResetTimer(); timerStartCounter3 = timerStartCounter2 = timerStartCounter1 = 0; timerSlider.transform.localPosition = timerSliderInitPos; timerSlider.SetActive(false); PopulatePlatform(currTileString, puzzleNum); GameManager.RetryCurrentPlatform(); ShowNextButtonFlag = false; ShowStar1Flag = false; ShowStar2Flag = false; ShowStar3Flag = false; ShowRetryFlag = false; ShowStarsFlag = false; ShowLevelsFlag = false; Star1RotCompleteFlag = false; Star2RotCompleteFlag = false; Star3RotCompleteFlag = false; flipTilesFlag = false; TimeTakenShown = false; if (TimeTakenObj != null) { TimeTakenObj.GetComponentInChildren <Text> ().text = ""; } HintEnabled = true; RetryPlatformFlag = true; }
void Update() { if (showScoreCircles && CameraManager.cameraAdjusted) { if (ang < maxAng) { ang += Time.deltaTime * 300; } else { ang = maxAng; } levelSquare.transform.localRotation = Quaternion.AngleAxis(ang, Vector3.back); UpdatePlatformObjectProperties(currentScoreCircle, currentScoreCirclePos, 1f, true, true); UpdatePlatformObjectProperties(prevScoreCircleFar, prevScoreCircleFarPos, circleAlphaFar, true, true); UpdatePlatformObjectProperties(prevScoreCircleNear, prevScoreCircleNearPos, circleAlphaNear, true, true); UpdatePlatformObjectProperties(nextScoreCircleNear, nextScoreCircleNearPos, circleAlphaNear, true, true); UpdatePlatformObjectProperties(nextScoreCircleFar, nextScoreCircleFarPos, circleAlphaFar, true, true); UpdatePlatformObjectProperties(hintButton, hintButtonPos, 1f, true, false); UpdatePlatformObjectProperties(timerCircle3Star, timerCircle3Pos, 1f, false, false); UpdatePlatformObjectProperties(timerCircle2Star, timerCircle2Pos, 1f, false, false); UpdatePlatformObjectProperties(timerCircle1Star, timerCircle1Pos, 1f, false, false); if (prevScoreCircleFar.transform.localPosition == prevScoreCircleFarPos) { showScoreCircles = false; } } if (WaitForHintFlag && !waitingFlag) { if (score == 0 || score == 1) { StartCoroutine(WaitForHint(2.0f)); } else { StartCoroutine(WaitForHint(1.0f)); } } if (ShowHintScreenFlag) { hintScreen.transform.localScale = Vector3.Lerp(hintScreen.transform.localScale, hintScreenSize, circleSpeed * Time.deltaTime); } if (HideHintScreenFlag) { hintScreen.transform.localScale = Vector3.Lerp(hintScreen.transform.localScale, hintScreenCollapseSize, circleSpeed * Time.deltaTime); } if (StartTimerFlag && !PauseTimerFlag) { if (!timerSlider.activeSelf) { timerSlider.SetActive(true); homeButton.SetActive(false); pauseButton.SetActive(true); } float currTime = TimeManager.GetCurrentTime() - pauseDuration; if (currTime < TimeManager.time3star) { timerStartCounter3 += Time.deltaTime / TimeManager.time3star; timerSlider.transform.localPosition = Vector3.Lerp(timerSliderInitPos, timerCircle3Star.transform.localPosition, timerStartCounter3); timerSlider.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColour3Star"]; } else if (currTime < TimeManager.time2star) { timerStartCounter2 += Time.deltaTime / (TimeManager.time2star - TimeManager.time3star); timerSlider.transform.localPosition = Vector3.Lerp(timerCircle3Star.transform.localPosition, timerCircle2Star.transform.localPosition, timerStartCounter2); timerSlider.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColour2Star"]; timerCircle3Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColourOff"]; timerCircle3Star.GetComponentInChildren <Text> ().text = ""; } else if (currTime < TimeManager.time1star) { timerStartCounter1 += Time.deltaTime / (TimeManager.time1star - TimeManager.time2star); timerSlider.transform.localPosition = Vector3.Lerp(timerCircle2Star.transform.localPosition, timerCircle1Star.transform.localPosition, timerStartCounter1); timerSlider.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColour1Star"]; timerCircle2Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColourOff"]; timerCircle2Star.GetComponentInChildren <Text> ().text = ""; timerCircle3Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColourOff"]; timerCircle3Star.GetComponentInChildren <Text> ().text = ""; } else { timerCircle2Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColourOff"]; timerCircle2Star.GetComponentInChildren <Text> ().text = ""; timerCircle3Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColourOff"]; timerCircle3Star.GetComponentInChildren <Text> ().text = ""; } } if (ScoreCompleteFlag) { UpdatePlatformObjectProperties(prevScoreCircleFar, currentScoreCirclePos, 0f, true, true); UpdatePlatformObjectProperties(prevScoreCircleNear, currentScoreCirclePos, 0f, true, true); UpdatePlatformObjectProperties(nextScoreCircleNear, currentScoreCirclePos, 0f, true, true); UpdatePlatformObjectProperties(nextScoreCircleFar, currentScoreCirclePos, 0f, true, true); Color newColor = Color.Lerp(currentScoreCircle.GetComponent <SpriteRenderer> ().color, LevelColour, alphaSpeed * Time.deltaTime); currentScoreCircle.GetComponent <SpriteRenderer> ().color = newColor; currentScoreCircle.GetComponentInChildren <Text> ().color = newColor; if (prevScoreCircleFar.transform.localPosition == currentScoreCircle.transform.localPosition) { print("SCORE COMPLETED....."); //Flip tiles to show menu items flipTilesFlag = true; ScoreCompleteFlag = false; HintEnabled = false; CameraManager.ZoomInPlatform(); homeButton.SetActive(true); pauseButton.SetActive(false); } } //Flip tiles to show Menu if (flipTilesFlag) { FlipTilesAndShowMenu(); } //Show Menu Screen if (ShowStarsFlag) { if (!TimeTakenShown) { TimeTakenObj = Instantiate(TimeTakenText, transform); TimeTakenObj.transform.position = Star2.transform.position + new Vector3(0, 2, 0); TimeTakenObj.GetComponentInChildren <Text> ().text = "Completed in " + TimeManager.GetTimeTaken() + "s."; TimeTakenShown = true; } Quaternion _targetRotation = Quaternion.Euler(new Vector3(0, 0, 180)); if (myStar >= 1 && !Star1RotCompleteFlag) { Star1.GetComponent <SpriteRenderer>().color = Color.Lerp(Star1.GetComponent <SpriteRenderer> ().color, colourDict ["StarColour"], alphaSpeed * Time.deltaTime); Star1.transform.localRotation = Quaternion.Lerp(Star1.transform.localRotation, _targetRotation, 10 * Time.deltaTime); Star1.transform.localScale = Vector3.Lerp(Star1.transform.localScale, new Vector3(0.6f, 0.6f, 0.6f), 10 * Time.deltaTime); if (Star1.transform.localRotation == _targetRotation) { Star1RotCompleteFlag = true; } } if (myStar >= 2 && !Star2RotCompleteFlag && Star1RotCompleteFlag) { Star2.GetComponent <SpriteRenderer>().color = Color.Lerp(Star2.GetComponent <SpriteRenderer> ().color, colourDict ["StarColour"], alphaSpeed * Time.deltaTime); Star2.transform.localRotation = Quaternion.Lerp(Star2.transform.localRotation, _targetRotation, 10 * Time.deltaTime); Star2.transform.localScale = Vector3.Lerp(Star2.transform.localScale, new Vector3(0.6f, 0.6f, 0.6f), 10 * Time.deltaTime); if (Star2.transform.localRotation == _targetRotation) { Star2RotCompleteFlag = true; } } if (myStar >= 3 && !Star3RotCompleteFlag && Star2RotCompleteFlag) { Star3.GetComponent <SpriteRenderer>().color = Color.Lerp(Star3.GetComponent <SpriteRenderer> ().color, colourDict ["StarColour"], alphaSpeed * Time.deltaTime); _targetRotation = Quaternion.Euler(new Vector3(0, 0, 180)); Star3.transform.localRotation = Quaternion.Lerp(Star3.transform.localRotation, _targetRotation, 10 * Time.deltaTime); Star3.transform.localScale = Vector3.Lerp(Star3.transform.localScale, new Vector3(0.6f, 0.6f, 0.6f), 10 * Time.deltaTime); if (Star3.transform.localRotation == _targetRotation) { Star3RotCompleteFlag = true; } } if ((myStar == 1 && Star1RotCompleteFlag) || (myStar == 2 && Star2RotCompleteFlag) || (myStar == 3 && Star3RotCompleteFlag)) { ShowStarsFlag = false; } } //Retry enabled if (RetryPlatformFlag) { UpdatePlatformObjectProperties(prevScoreCircleFar, prevScoreCircleFarPos, circleAlphaFar, true, true); UpdatePlatformObjectProperties(prevScoreCircleNear, prevScoreCircleNearPos, circleAlphaNear, true, true); UpdatePlatformObjectProperties(nextScoreCircleNear, nextScoreCircleNearPos, circleAlphaNear, true, true); UpdatePlatformObjectProperties(nextScoreCircleFar, nextScoreCircleFarPos, circleAlphaFar, true, true); timerCircle3Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColour3Star"]; timerCircle2Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColour2Star"]; timerCircle1Star.GetComponent <SpriteRenderer> ().color = colourDict ["TimerColour1Star"]; timerCircle3Star.GetComponentInChildren <Text> ().text = transform.GetComponent <TimeManager> ().time3star.ToString() + " s"; timerCircle2Star.GetComponentInChildren <Text> ().text = transform.GetComponent <TimeManager> ().time2star.ToString() + " s"; timerCircle1Star.GetComponentInChildren <Text> ().text = transform.GetComponent <TimeManager> ().time1star.ToString() + " s"; if (prevScoreCircleFar.transform.localPosition == prevScoreCircleFarPos) { RetryPlatformFlag = false; } } }