Esempio n. 1
0
 void OnTriggerEnter(Collider col)
 {
     if (col.tag == "Player")
     {
         Vector3    Direction   = (col.transform.position - transform.position).normalized;
         Quaternion Rotation    = Quaternion.Inverse(transform.rotation) * Quaternion.LookRotation(Direction);
         int        enteringnum = 0;
         if (Rotation.eulerAngles.y > 315f || Rotation.eulerAngles.y < 45f)
         {
             enteringnum = 1;
         }
         else if (45f < Rotation.eulerAngles.y && Rotation.eulerAngles.y < 135f)
         {
             enteringnum = 2;
         }
         else if (135f < Rotation.eulerAngles.y && Rotation.eulerAngles.y < 225f)
         {
             enteringnum = 3;
         }
         else if (225f < Rotation.eulerAngles.y && Rotation.eulerAngles.y < 315f)
         {
             enteringnum = 4;
         }
         if ((currentCycle == 0 && enteringnum % 2 == 0) || (currentCycle == 1 && enteringnum % 2 != 0))
         {
             TrafficLaws laws = col.gameObject.GetComponentInParent <TrafficLaws>();
             Debug.Log(laws.status);
             laws.SetStatus(TrafficLaws.Status.RedLightViolation);
         }
     }
 }
    public IEnumerable <ICitation> IssueCitations(ITrafficState trafficState, ILegalEntity citee)
    {
        List <ICitation> citations;

        citations = TrafficLaws
                    .Where(x => x.ShouldIssueCitation(trafficState, citee))
                    .Select(x => x.CreateCitation(trafficState, citee, this))
                    .ToList();

        return(citations);
    }
Esempio n. 3
0
 void Start()
 {
     controller = gameObject.GetComponent <CarController> ();
     laws       = gameObject.GetComponent <TrafficLaws> ();
 }