示例#1
0
        public bool CanSee(GameActor actor)
        {
            Ray        ray = new Ray(this.transform.position, actor.transform.position);
            RaycastHit hit;

            if (Physics.Linecast(this.transform.position, actor.transform.position, out hit))
            {
                if (hit.transform.tag == "Obstacle")
                {
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Gets the less distant actor in range.
        /// </summary>
        /// <returns>The actor in range.</returns>
        /// <param name="range">Range.</param>
        /// <param name="type">Type.</param>
        public GameActor GetActorInRange(float range, EGameActorType type)
        {
            GameActor gameActor = null;
            var       distance  = Mathf.Infinity;
            var       colliders = Physics.OverlapSphere(this.transform.position, range);

            for (int i = 0; i < colliders.Length; i++)
            {
                var mActor = colliders[i].GetComponent <GameActor>();
                if (mActor != null && mActor.actorProps.Type == type)
                {
                    var dist = Vector3.Distance(this.transform.position, mActor.transform.position);
                    if (dist < distance)
                    {
                        distance  = dist;
                        gameActor = mActor;
                    }
                }
            }
            return(gameActor);
        }
示例#3
0
 public bool InRange(GameActor actor, float range)
 {
     return(Vector3.Distance(this.transform.position, actor.transform.position) > range ? false : true);
 }