예제 #1
0
        public RayFanResult NextRay()
        {
            if (numRays > maxRays)
            {             // oh f**k go back
                return(new RayFanResult(null, null, RayFanResult.resultType.NoMoreRays));
            }

            float dir = parent.raySpacing * (numRays / 2);

            if (numRays % 2 == 0)
            {
                dir = -dir;
            }
            numRays++;
            Vector2      rayDir    = HelperClass.RotateAroundAxis(straightDirection, Vector2.zero, dir);
            Ray2D        ray       = new Ray2D(origin, rayDir);
            RaycastHit2D hit       = Physics2D.Raycast(ray.origin, ray.direction, 20f, rayMask);
            Ray2D        playerRay = new Ray2D(hit.point, HelperClass.V3toV2(parent.target.position) - hit.point);
            RaycastHit2D playerHit = Physics2D.Raycast(playerRay.origin, playerRay.direction, 200f, rayMask);

            parent.rayList.Add(ray);
            parent.rayList.Add(playerRay);

            List <Vector2> path = new List <Vector2>();

            pathYet.ForEach((x) => { path.Add(x); });
            path.Add(hit.point);

            NextRayFanData data = new NextRayFanData(depthLeft - 1, parent, origin, hit.normal, path, rayMask);

            RayFanResult.resultType hitPlayer = RayFanResult.resultType.NoHit;
            if (playerHit.collider.gameObject.tag == "Player")
            {
                hitPlayer = RayFanResult.resultType.Hit;
                path.Add(HelperClass.V3toV2(parent.target.position));
            }


            RayFanResult res = new RayFanResult(path, data, hitPlayer);

            return(null);
        }
예제 #2
0
 public RayFanResult(List <Vector2> pathSoFar, NextRayFanData next, resultType result)
 {
     this.pathSoFar = pathSoFar;
     this.next      = next;
     this.result    = result;
 }