Ejemplo n.º 1
0
        void OnCollisionStay(Collision collision)
        {
            BumperCarAi bumperCarAi = collision.gameObject.GetComponent <BumperCarAi>();

            if (bumperCarAi != null)
            {
                if (Target == bumperCarAi) // op zoek naar hem
                {
                    _status = Status.SEEKING;
                }
                else
                {
                    FleeTarget = bumperCarAi;
                    _status    = Status.FLEEING;
                }
            }
            else if (collision.gameObject.name.StartsWith("Bound"))
            {
                _status = Status.SEEKING;
            }
            else if (collision.gameObject.name.StartsWith("Mouse") || collision.gameObject.name.StartsWith("Land"))
            {
                Physics.IgnoreCollision(GetComponent <Collider>(), collision.collider);
            }
        }
Ejemplo n.º 2
0
        private BumperCarAi FindTarget(BumperCarAi excluded)
        {
            Collider[] colliders = Physics.OverlapSphere(transform.position, 10);

            List <BumperCarAi> cars = new List <BumperCarAi>();

            foreach (Collider collider in colliders)
            {
                BumperCarAi bumperCarAi = collider.GetComponent <BumperCarAi>();
                if (bumperCarAi != null)
                {
                    if (bumperCarAi.gameObject == gameObject || bumperCarAi.gameObject == excluded.gameObject)
                    {
                        continue;
                    }

                    if (transform.TransformPoint(bumperCarAi.gameObject.transform.position).z < 0)
                    {
                        cars.Add(bumperCarAi);
                    }
                    else
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            cars.Add(bumperCarAi);
                        }
                    }
                }
            }

            return(cars[(int)(Random.value * cars.Count)]);
        }
Ejemplo n.º 3
0
        private IEnumerator Seeking()
        {
            yield return(new WaitForSeconds(Random.value * 0.3f + 0.2f));

            Target   = FindTarget(this);
            _status  = Status.Pursuiing;
            _seeking = false;
        }
Ejemplo n.º 4
0
 void OnCollisionStay(Collision collision)
 {
     BumperCarAi bumperCarAi = collision.gameObject.GetComponent<BumperCarAi>();
     if (bumperCarAi != null)
     {
         if (Target == bumperCarAi) // op zoek naar hem
         {
             _status = Status.SEEKING;
         }
         else
         {
             FleeTarget = bumperCarAi;
             _status = Status.FLEEING;
         }
     }
     else if (collision.gameObject.name.StartsWith("Bound"))
     {
         _status = Status.SEEKING;
     }
     else if (collision.gameObject.name.StartsWith("Mouse") || collision.gameObject.name.StartsWith("Land"))
     {
         Physics.IgnoreCollision(GetComponent<Collider>(), collision.collider);
     }
 }
Ejemplo n.º 5
0
        private BumperCarAi FindTarget(BumperCarAi excluded)
        {
            Collider[] colliders = Physics.OverlapSphere(transform.position, 10);

            List<BumperCarAi> cars = new List<BumperCarAi>();

            foreach (Collider collider in colliders)
            {
                BumperCarAi bumperCarAi = collider.GetComponent<BumperCarAi>();
                if (bumperCarAi != null)
                {
                    if (bumperCarAi.gameObject == gameObject || bumperCarAi.gameObject == excluded.gameObject)
                        continue;

                    if (transform.TransformPoint(bumperCarAi.gameObject.transform.position).z < 0)
                    {
                        cars.Add(bumperCarAi);
                    }
                    else
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            cars.Add(bumperCarAi);
                        }
                    }
                }
            }

            return cars[(int)(Random.value * cars.Count)];
        }
Ejemplo n.º 6
0
        private IEnumerator Seeking()
        {
            yield return new WaitForSeconds(Random.value * 0.3f + 0.2f);

            Target = FindTarget(this);
            _status = Status.Pursuiing;
            _seeking = false;
        }