Ejemplo n.º 1
0
 public static void check(Transform transform)
 {
     isWrongWay(transform);
     intersection = transform.GetComponentInParent <IntersectionWrongWay>();
     if (intersection.flag1)
     {
         if (transform.name == "ColliderIntersection4")
         {
             Debug.Log("Krivi smjer");
         }
     }
     if (intersection.flag2)
     {
         if (transform.name == "ColliderIntersection3")
         {
             Debug.Log("Krivi smjer");
         }
     }
     if (intersection.flag3)
     {
         if (transform.name == "ColliderIntersection2")
         {
             Debug.Log("Krivi smjer");
         }
     }
     if (intersection.flag4)
     {
         if (transform.name == "ColliderIntersection1")
         {
             Debug.Log("Krivi smjer");
         }
     }
 }
Ejemplo n.º 2
0
 public static void checkIsRight(Transform transform)
 {
     if (transform.GetComponentInParent <IntersectionWrongWay>() != null)
     {
         intersection = transform.GetComponentInParent <IntersectionWrongWay>();
         if (transform.name == "ColliderIntersection" && intersection.flag1 && last != "ColliderIntersection2")
         {
             Debug.Log("Krivi smjer");
         }
         else if (transform.name == "ColliderIntersection" && intersection.flag2 && last != "ColliderIntersection4")
         {
             Debug.Log("Krivi smjer");
         }
         else if (transform.name == "ColliderIntersection" && intersection.flag3 && last != "ColliderIntersection1")
         {
             Debug.Log("Krivi smjer");
         }
         else if (transform.name == "ColliderIntersection" && intersection.flag4 && last != "ColliderIntersection3")
         {
             Debug.Log("Krivi smjer");
         }
         last = transform.name;
     }
 }
Ejemplo n.º 3
0
    public static void isWrongWay(Transform transform)
    {
        IntersectionWrongWay intersection = transform.GetComponentInParent <IntersectionWrongWay>();

        if (intersection.flag1)
        {
            if (transform.name == "ColliderIntersection3")
            {
                Debug.Log("Krivi smjer");
            }
        }
        if (intersection.flag2)
        {
            if (transform.name == "ColliderIntersection1")
            {
                Debug.Log("Krivi smjer");
            }
        }
        if (intersection.flag3)
        {
            if (transform.name == "ColliderIntersection4")
            {
                Debug.Log("Krivi smjer");
            }
        }
        if (intersection.flag4)
        {
            if (transform.name == "ColliderIntersection2")
            {
                Debug.Log("Krivi smjer");
            }
        }
        if (!intersection.flag1 && !intersection.flag2 && !intersection.flag3 && !intersection.flag4)
        {
            if (transform.name == "ColliderIntersection1")
            {
                //Debug.Log("Usao uz " + transform.name);
                intersection.flag1 = true;

                //   transform.root.Search("ColliderIntersection2").GetComponent<BoxCollider>().enabled = false;
                //   transform.root.Search("ColliderIntersection4").GetComponent<BoxCollider>().enabled = false;
                // transform.root.Search("ColliderIntersection2").GetComponent<BoxCollider>().enabled = false;
                //  transform.root.Search("ColliderIntersection4").GetComponent<BoxCollider>().enabled = false;
                // BoxCollider col = GameObject.Find(transform.parent.parent.name + "/" + transform.parent.name + "/ColliderIntersection3").GetComponent<BoxCollider>();
                //  GameObject root = transform.root.gameObject;
                // BoxCollider col = transform.Find("ColliderIntersection3").GetComponent<BoxCollider>();
            }
            else if (transform.name == "ColliderIntersection2")
            {
                // Debug.Log("Usao uz " + transform.name);
                intersection.flag2 = true;
            }
            else if (transform.name == "ColliderIntersection3")
            {
                //Debug.Log("Usao uz " + transform.name);
                intersection.flag3 = true;
                //  transform.root.Search("ColliderIntersection1").GetComponent<BoxCollider>().enabled = false;
                //  transform.root.Search("ColliderIntersection4").GetComponent<BoxCollider>().enabled = false;
            }
            else if (transform.name == "ColliderIntersection4")
            {
                // Debug.Log("Usao uz " + transform.name);
                intersection.flag4 = true;
            }
        }
    }
Ejemplo n.º 4
0
    private void OnTriggerExit(Collider other)
    {
        if (transform.name == "ColliderFirst")
        {
            var.x.flag2 = false;
        }

        if (transform.name == "ColliderSecond")
        {
            var.x.flag1 = false;
        }
        //ako je lijevi znak aktivan primjeni njegova pravila
        if (LeftSign.isActive)
        {
            LeftSign.checkIsRight(transform);
        }
        if (LeftUp.isActive)
        {
            LeftUp.checkIsRight(transform);
        }
        if (LeftRight.isActive)
        {
            LeftRight.checkIsRight(transform);
        }
        if (UP.isActive)
        {
            UP.checkIsRight(transform);
        }
        //ako je desni znak aktivan primjeni njegova pravila

        /* if (RightSign.isActive)
         * {
         *   LeftSign.checkIsRight(transform);
         * }*/

        if (transform.GetComponentInParent <IntersectionWrongWay>() != null)
        {
            intersection = transform.GetComponentInParent <IntersectionWrongWay>();

            if (transform.name == "ColliderIntersection")
            {
                intersection.setAllFalse();
                UP.isActive        = false;
                LeftSign.isActive  = false;
                RightSign.isActive = false;
                RightUp.isActive   = false;
                LeftUp.isActive    = false;
                LeftRight.isActive = false;
                UP.isActive        = false;
            }
        }

        if (transform.name == "ColliderStop")
        {
            if (!StopSign.timerDone)
            {
                Debug.Log("NISI STAO NA STOP");
            }
            StopSign.stopSignActive = false;
        }
    }