Ejemplo n.º 1
0
        public WorldAhead(Vector3 lookAheadVector, RaycastHit hit)
        {
            this.position = hit.point;
            this.normal   = hit.normal;
            this.other    = hit.collider;
            HaggisInteractable interactable = hit.collider.GetComponent <HaggisInteractable>();

            if (interactable)
            {
                switch (interactable.type)
                {
                case HaggisInteractable.InteractableType.Ground:
                    this.type = HaggisInteractable.InteractableType.Ground;
                    break;

                case HaggisInteractable.InteractableType.Wall:
                    this.type = HaggisInteractable.InteractableType.Wall;
                    break;

                case HaggisInteractable.InteractableType.Hop:
                    this.type = HaggisInteractable.InteractableType.Hop;
                    break;

                default:
                    this.type = HaggisInteractable.InteractableType.None;
                    break;
                }
            }
            else
            {
                this.type = HaggisInteractable.InteractableType.None;
            }
            this.isHit           = true;
            this.lookAheadVector = lookAheadVector;
        }
Ejemplo n.º 2
0
        public bool                                isHit;           // true if hit. note position, normal, other and type are not defined if isHit is false;

        public WorldAhead(Vector3 lookAheadVector)
        {
            this.isHit           = false;
            this.position        = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
            this.normal          = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
            this.other           = null;
            this.type            = HaggisInteractable.InteractableType.None;
            this.lookAheadVector = lookAheadVector;
        }
Ejemplo n.º 3
0
 public WorldAhead WhatAhead(HaggisInteractable.InteractableType type, int maxDist)
 {
     for (int i = 0; i < worldAhead.Count && i < maxDist; ++i)
     {
         WorldAhead ahead = worldAhead[i];
         if (ahead.isHit)
         {
             if (ahead.type == type)
             {
                 return(ahead);
             }
         }
     }
     return(new WorldAhead(new Vector3(0.0f, 0.0f, 0.0f)));
 }
Ejemplo n.º 4
0
 // returns Where the first location of obstacle type is detected ahead. Lots of infs if there is not obstacle of type  detected ahead.
 Vector3 WhereAhead(HaggisInteractable.InteractableType type, int maxDist)
 {
     for (int i = 0; i < worldAhead.Count && i < maxDist; ++i)
     {
         WorldAhead ahead = worldAhead[i];
         if (ahead.isHit)
         {
             if (ahead.type == type)
             {
                 return(ahead.position);
             }
         }
     }
     return(new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity));
 }
Ejemplo n.º 5
0
 // returns true if the obstacle type is detected ahead
 public bool IsAhead(HaggisInteractable.InteractableType type, int maxDist)
 {
     for (int i = 0; i < worldAhead.Count && i < maxDist; ++i)
     {
         WorldAhead ahead = worldAhead[i];
         if (ahead.isHit)
         {
             if (ahead.type == type)
             {
                 return(true);
             }
         }
         else if (type == HaggisInteractable.InteractableType.None)
         {
             return(true);
         }
     }
     return(false);
 }