Exemple #1
0
        // Update is called once per frame
        void Update()
        {
            if (Input.GetKey(KeyCode.E))
            {
                Radius = Mathf.Clamp(Radius + 10 * Time.deltaTime, 1, 80);
            }

            if (Input.GetKey(KeyCode.Q))
            {
                Radius = Mathf.Clamp(Radius - 10 * Time.deltaTime, 1, 80);
            }

            currentPoints.Clear();

            var center0 = this.transform.position - Vector3.right * Radius;
            var center1 = this.transform.position + Vector3.right * Radius;
            var shape   = new VolumePlane(Vector3.Cross(this.transform.right - this.transform.up * 2, this.transform.forward), this.transform.position);

            stopwatch.Restart();
            currentPoints.AddRange(Point.AllPoints.ShapeCast(shape));
            stopwatch.Stop();

            CastTime = stopwatch.Elapsed.TotalMilliseconds / 1000.0;

            previousPoints.ExceptWith(currentPoints);

            foreach (var pp in previousPoints)
            {
                pp.SetActive(false);
            }

            previousPoints.Clear();

            foreach (var cp in currentPoints)
            {
                cp.SetActive(true);
                previousPoints.Add(cp);
            }

            if (Input.GetKeyDown(KeyCode.F))
            {
                foreach (var point in currentPoints)
                {
                    var rb = point.GetComponent <Rigidbody>();
                    if (rb != null)
                    {
                        rb.AddExplosionForce(10f, this.transform.position, Radius, 0, ForceMode.Impulse);
                    }
                }
            }
        }
 public VolumePlaneBuilder(VolumePlane plane)
 {
     this.plane = plane;
 }