void SelectTank(TankSelect tankSelect) { tankSelect.Select(); selectedTank = tankSelect; tankIsSelected = true; }
public override void RunState() { if (selectedTank != null) { UIManager.Instance.proUGUI.text = selectedTank.GetUIText(); } if (isDrawingLine && Input.touchCount <= 0) { isDrawingLine = false; } if ((Input.touchCount > 0)) { Ray raycast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit raycastHit; if (isDrawingLine && tankIsSelected) { if (Physics.Raycast(raycast, out raycastHit)) { if (DistanceToLastPoint(raycastHit.point) > minDistanceBetweenPoints) { points.Add(raycastHit.point); lineRenderer.positionCount = points.Count; lineRenderer.SetPositions(points.ToArray()); } } else { OnNewPathCreated(points); lineRenderer.enabled = false; isDrawingLine = false; } } else if (tankIsSelected) { if (Input.GetTouch(0).phase == TouchPhase.Began) { if (Physics.Raycast(raycast, out raycastHit)) { if (raycastHit.collider.gameObject.GetComponent <TankSelect>() && raycastHit.collider.gameObject.GetComponent <TankSelect>().isActiveAndEnabled) { tankTouched = raycastHit.collider.gameObject.GetComponent <TankSelect>(); if (tankTouched == selectedTank) { lineRenderer.enabled = true; points.Clear(); lineRenderer.positionCount = points.Count; lineRenderer.SetPositions(points.ToArray()); points.Add(raycastHit.point); isDrawingLine = true; } else { UnselectAllTanks(); SelectTank(raycastHit.collider.gameObject.GetComponent <TankSelect>()); } } else { UnselectAllTanks(); tankIsSelected = false; } } } } else { if (Input.GetTouch(0).phase == TouchPhase.Began) { if (Physics.Raycast(raycast, out raycastHit)) { if (raycastHit.collider.gameObject.GetComponent <TankSelect>() && raycastHit.collider.gameObject.GetComponent <TankSelect>().isActiveAndEnabled) { Debug.Log("LogCat Something Hit " + raycastHit.collider.gameObject.name); UnselectAllTanks(); SelectTank(raycastHit.collider.gameObject.GetComponent <TankSelect>()); } } } } } // UIManager.Instance.proUGUI.text = uiManagerText; }