Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        timer -= Time.deltaTime;
        rayObjectDetect();
        if (shouldWeDrive() == true)
        {
            if (timer <= 0)
            {
                setNodesNearMeToUnwalkable();
            }
            if (reachedEndOfRoad == false)
            {
                moveToDirection(currentRoad.getTopOfRoad());
            }
            else
            {
                moveToDirection(myJunction.getJunctionPoint());
            }
            if (setEngine == false)
            {
                au.playSoundOnLoop(engine);
                setEngine = true;
            }
        }
        else
        {
            if (timer <= 0)
            {
                setNodesNearMeToUnwalkable();
            }

            if (reachedEndOfRoad == false)
            {
                moveToDirection(currentRoad.getTopOfRoad());
            }
            else
            {
                moveToDirection(myJunction.getJunctionPoint());
            }


            if (setEngine == true)
            {
                au.stopLoopingAudio(engine);
                //au.playSound (braking);
                setEngine = false;
            }
            brake();
        }
        junctionMoniter();
        directionMoniter();
    }
Exemple #2
0
    public void calculateJunctions()
    {
        if (myJunctions == null)
        {
            myJunctions = new List <RoadJunction> ();
        }

        foreach (Road r in roadsIIntersect)
        {
            RoadJunction j = this.gameObject.AddComponent <RoadJunction> ();
            j.roadOn      = this;
            j.roadGoingTo = r;
            if (Vector3.Distance(getTopOfRoad(), j.getJunctionPoint()) > Vector3.Distance(getBottomOfRoad(), j.getJunctionPoint()))
            {
                DestroyImmediate(j);
            }
            else
            {
                myJunctions.Add(j);
                EditorUtility.SetDirty(j);
            }
        }
    }