// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { downX = Input.mousePosition.x; GameManager.Instance.frisbee.eulerAngles = Vector3.zero; GameManager.Instance.frisbee.SetParent(transform); GameManager.Instance.frisbee.localPosition = Vector3.zero; } if (Input.GetMouseButton(0)) { float angle = Wrj.Utils.Remap(Input.mousePosition.x - downX, -200f, 200f, -1f, 1f); Vector3 influence = Vector3.Lerp(shooter.position, target.position, .5f) + (Vector3.right * (angle * angleMultiplier)); curve = Wrj.Utils.QuadraticBezierCurve(shooter.position, influence, target.position, 512); line.SetPositions(curve); } else if (Input.GetMouseButtonUp(0)) { StartCoroutine(MovePath(curve)); line.SetPositions(new Vector3[0]); } }
void LaserBeam(Transform ee) { Vector3 rr = ee.TransformDirection(Vector3.forward); Ray ray = new Ray(ee.position, rr); RaycastHit nearHit; if (Physics.Raycast(ray, out nearHit)) { string RootName = nearHit.transform.root.name; if (RootName == "MyRobot") { return; } Instantiate(Effect, nearHit.point, Quaternion.identity); if ((nearHit.collider.tag == "Figure")) { Transform j = nearHit.collider.transform; while ((j.parent.tag == "Figure") && (j.parent.name != "Tower")) { j = j.parent; } Damaging(j.gameObject, 700, RootName); if (Robo.ContainsKey(RootName)) { if (Robo[RootName].Health <= 0) { nearHit.transform.root.gameObject.SetActive(false); Robo[RootName].HealthCoroutine = null; return; } //print(RootName + "=" + Robo[RootName].Health); if (Robo[RootName].HealthCoroutine != null) { StopCoroutine(Robo[RootName].HealthCoroutine); Robo[RootName].HealthCoroutine = null; } if (Robo[RootName].HealthCoroutine == null) { Robo[RootName].HealthCoroutine = StartCoroutine(HealthTimer(10, RootName)); } } } } GameObject lr = new GameObject("LaserRay"); GameObject Tm = new GameObject("Tm"); lr.transform.parent = ee; Tm.transform.parent = ee; lr.transform.localPosition = new Vector3(0, 0, 1.4f); lr.AddComponent <LaserLine>(); LaserLine ll = lr.GetComponent <LaserLine>(); ll.width = 0.7f; ll.innerFadeMaterial = Setup.innerFadeMaterial; ll.outerFadeMaterial = Setup.outerFadeMaterial; ll.SetPositions(new Vector3[] { lr.transform.position, nearHit.point }); ll.Visible = true; Destroy(lr, 0.1f); Destroy(Tm, 0.2f); lr.AddComponent <AudioSource>(); AudioSource audio = lr.GetComponent <AudioSource>(); audio.clip = Beam; audio.Play(); }