/// <summary> /// Draw the indicators on the screen and set thier position and rotation and other properties. /// </summary> void DrawIndicators() { foreach (Target target in targets) { Vector3 screenPosition = OffScreenIndicatorCore.GetScreenPosition(mainCamera, target.transform.position); bool isTargetVisible = OffScreenIndicatorCore.IsTargetVisible(screenPosition); float distanceFromCamera = target.NeedDistanceText ? target.GetDistanceFromCamera(mainCamera.transform.position) : float.MinValue;// Gets the target distance from the camera. Indicator indicator = null; if (target.NeedBoxIndicator && isTargetVisible) { screenPosition.z = 0; indicator = GetIndicator(ref target.indicator, IndicatorType.BOX); // Gets the box indicator from the pool. } else if (target.NeedArrowIndicator && !isTargetVisible) { float angle = float.MinValue; OffScreenIndicatorCore.GetArrowIndicatorPositionAndAngle(ref screenPosition, ref angle, screenCentre, screenBounds); indicator = GetIndicator(ref target.indicator, IndicatorType.ARROW); // Gets the arrow indicator from the pool. indicator.transform.rotation = Quaternion.Euler(0, 0, angle * Mathf.Rad2Deg); // Sets the rotation for the arrow indicator. } else { target.indicator?.Activate(false); target.indicator = null; } if (indicator) { indicator.SetImageColor(target.TargetColor); // Sets the image color of the indicator. indicator.SetDistanceText(distanceFromCamera); //Set the distance text for the indicator. indicator.transform.position = screenPosition; //Sets the position of the indicator on the screen. indicator.SetTextRotation(Quaternion.identity); // Sets the rotation of the distance text of the indicator. } } }
void DrawIndicators() { GameObject[] objects = GameObject.FindGameObjectsWithTag(targetTag); // Find all the objects with 'Target' tag in the scene. List <Target> targets = new List <Target>(); objects.ToList().ForEach(obj => { Target target = obj.GetComponent <Target>(); if (target) { targets.Add(target); } }); foreach (Target target in targets) { Vector3 screenPosition = OffScreenIndicatorCore.GetScreenPosition(mainCamera, target.transform.position); bool isTargetVisible = OffScreenIndicatorCore.IsTargetVisible(screenPosition); float distanceFromCamera = target.NeedDistanceText ? target.GetDistanceFromCamera(mainCamera.transform.position) : float.MinValue; // Gets the target distance from the camera. Indicator indicator = null; if (target.NeedBoxIndicator && isTargetVisible) { screenPosition.z = 0; indicator = BoxObjectPool.current.GetPooledObject(); // Gets the box indicator from the pool. } else if (target.NeedArrowIndicator && !isTargetVisible) { float angle = float.MinValue; OffScreenIndicatorCore.GetArrowIndicatorPositionAndAngle(ref screenPosition, ref angle, screenCentre, screenBounds); indicator = ArrowObjectPool.current.GetPooledObject(); // Gets the arrow indicator from the pool. indicator.transform.rotation = Quaternion.Euler(0, 0, angle * Mathf.Rad2Deg); // Sets the rotation for the arrow indicator. } if (indicator) { indicator.SetImageColor(target.TargetColor); // Sets the image color of the indicator. indicator.SetDistanceText(distanceFromCamera); //Set the distance text for the indicator. indicator.transform.position = screenPosition; //Sets the position of the indicator on the screen. indicator.SetTextRotation(Quaternion.identity); // Sets the rotation of the distance text of the indicator. indicator.Activate(true); // Sets the indicator as active. } //UI if (distanceFromCamera <= 100.0f) { timer.SetActive(true); if (makeUI == true) { makeUI = false; GameObject.Find("UIManager").SendMessage("getScore"); GameObject.Find("UIManager").SendMessage("gameEnd"); } } } }
/// <summary> /// Draw the indicators on the screen and set thier position and rotation and other properties. /// </summary> void DrawIndicators(Camera camera) { foreach (Target target in targets) { if (target.indicator != null) { //Debug.Log(target.gameObject); bool GOenabled = getObjective(target.gameObject); //Debug.Log(enabled); if (GOenabled) { target.indicator.Activate(true); } else { target.indicator.Activate(false); } if (!target.indicator.isActive()) { continue; } } else { //Debug.Log("Nothing"); } //Debug.Log(target.isCompleted); // SelectionUI select = GameObject.Find("UIManager").GetComponent<SelectionUI>(); // if (target.indicator != null && select.target != null) { // target.indicator.Activate(false); // } else clr = target.TargetColor; // if (select.target == null){ // target.indicator.Activate(false); // } else { // if (target.gameObject.Equals(select.target.gameObject )) { // // // // clr = Color.blue; // target.indicator.Activate(true); // }// else { // // target.indicator.Activate(false); // clr = target.TargetColor; // } // if (select.target == null) { // clr = target.TargetColor; // // //target.indicator.Activate(false); // } Vector3 screenPosition = OffScreenIndicatorCore.GetScreenPosition(camera, target.transform.position); bool isTargetVisible = OffScreenIndicatorCore.IsTargetVisible(screenPosition); float distanceFromCamera = target.NeedDistanceText ? target.GetDistanceFromCamera(camera.transform.position) : float.MinValue;// Gets the target distance from the camera. Indicator indicator = null; if (target.NeedBoxIndicator && isTargetVisible) { screenPosition.z = 0; indicator = GetIndicator(ref target.indicator, IndicatorType.BOX); // Gets the box indicator from the pool. } else if (target.NeedArrowIndicator && !isTargetVisible) { float angle = float.MinValue; OffScreenIndicatorCore.GetArrowIndicatorPositionAndAngle(ref screenPosition, ref angle, screenCentre, screenBounds); indicator = GetIndicator(ref target.indicator, IndicatorType.ARROW); // Gets the arrow indicator from the pool. indicator.transform.rotation = Quaternion.Euler(0, 0, angle * Mathf.Rad2Deg); // Sets the rotation for the arrow indicator. } else { target.indicator?.Activate(false); target.indicator = null; } if (indicator) { indicator.SetImageColor(clr); // Sets the image color of the indicator. indicator.SetDistanceText(distanceFromCamera); //Set the distance text for the indicator. indicator.transform.position = screenPosition; //Sets the position of the indicator on the screen. indicator.SetTextRotation(Quaternion.identity); // Sets the rotation of the distance text of the indicator. } // }else { // target.indicator?.Activate(false); // target.indicator = null; // } } }