// Tap down event public void OnTapDown(int id, Vector2 position) { // Collision check via raycast Ray ray = Camera.main.ScreenPointToRay(position); RaycastHit hit; // If hit if (Physics.Raycast(ray, out hit)) { // Check tag GameObject hitObject = hit.collider.gameObject; // TEST //Debug.LogError(hitObject.name); if (hitObject.tag == Tags.FEEDBACK_STAR) { FeedbackStarScript star = hitObject.GetComponent <FeedbackStarScript>(); int row = star.row; int column = star.column; //Debug.LogError(string.Format("star ({0},{1})", row, column)); ratings[row] = column + 1; for (int j = 0; j < COUNT_STARS; j++) { if (j <= column) { stars[row, j].PlaySelectAnim(); } else { stars[row, j].PlayDeselectAnim(); } } if (!submitButtonActive) { submitButtonActive = true; for (int i = 0; i < COUNT_CATEGORY; i++) { if (ratings[i] == 0) { submitButtonActive = false; break; } } if (submitButtonActive) { // Selectable now Color color = new Color(1, 1, 1, 1); submitButton.color = color; submitLabel.topColor = color; submitLabel.botColor = color; } } } else if (submitButtonActive && hitObject.name == "SubmitButton") { SendTrackerData(); } } }
// Call this after game over public void Show() { // Re-enable the submit button submitButton.gameObject.active = true; // Re-enable rendering of all child items foreach (Component component in this.GetComponentsInChildren <Component>()) { if (component.gameObject.renderer != null) { component.gameObject.renderer.enabled = true; } } // Init stars stars = new FeedbackStarScript[COUNT_CATEGORY, COUNT_STARS]; for (int i = 0; i < COUNT_CATEGORY; i++) { for (int j = 0; j < COUNT_STARS; j++) { GameObject starObject = (GameObject)Instantiate(feedbackStarPrefab); FeedbackStarScript star = starObject.GetComponent <FeedbackStarScript>(); star.row = i; // Category star.column = j; // Star # stars[i, j] = star; Vector3 position = starInitPosition + i * starRowOffset + j * starColumnOffset; starObject.transform.position = position; } } ratings = new int[COUNT_CATEGORY]; // Start off not appeared Color faded = new Color(1, 1, 1, 0); foreach (exSprite sprite in this.GetComponentsInChildren <exSprite>()) { sprite.color = faded; } foreach (exSpriteFont text in this.GetComponentsInChildren <exSpriteFont>()) { text.topColor = faded; text.botColor = faded; } foreach (GameObject gameObj in GameObject.FindGameObjectsWithTag(Tags.FEEDBACK_STAR)) { gameObj.GetComponent <exSprite>().color = faded; } // Start fading fadeDone = false; fadeTimerStart = Time.time; }