Пример #1
0
    void OnTriggerStay(Collider collider)
    {
        GameObject collidedObject = collider.gameObject;

        if (collidedObject.name.Equals("PosX") ||
            collidedObject.name.Equals("NegX") ||
            collidedObject.name.Equals("PosY") ||
            collidedObject.name.Equals("NegY"))
        {
            CrossingColliderT crossT = null;
            CrossingColliderX crossX = null;

            float distance = getDistance(gameObject, collidedObject);
            if (collidedObject == firstCollider)
            {
                crossT = collidedObject.GetComponentInParent <CrossingColliderT>();
                if (crossT == null)
                {
                    crossX = collidedObject.GetComponentInParent <CrossingColliderX>();
                    if (crossX == null)
                    {
                        return;
                    }
                    RemoteObject.Enum.TrafficLightsStatus trafficLightStatus = crossX.actLightState;
                    carDecisionOnCrossing(trafficLightStatus, distance);
                }
                else
                {
                    RemoteObject.Enum.TrafficLightsStatus trafficLightStatus = crossT.actLightState;
                    carDecisionOnCrossing(trafficLightStatus, distance);
                }
            }
        }
    }
Пример #2
0
 public void decideWay(CrossingColliderT collider)
 {
     if (!isNewStreet)
     {
         System.Random random       = new System.Random();
         int           randomNumber = random.Next(0, 2);
         nextCrossingColliderT = collider;
         nextCrossingColliderX = null;
         collider.setDirection(randomNumber, this);
     }
 }
Пример #3
0
    public void setCollider(string id, CrossingColliderT coll)
    {
        crossingColliderT = coll;
        switch (id)
        {
        case "NegX":
            coll.setDirectionsIntern(getChildGameObject(gameObject, "PathPosX"), negY, posY, isControlledByTrafficLight, uuid);
            break;

        case "NegY":
            coll.setDirectionsIntern(getChildGameObject(gameObject, "PathPosY"), posY, posX, isControlledByTrafficLight, uuid);
            break;

        case "PosY":
            coll.setDirectionsIntern(getChildGameObject(gameObject, "PathNegY"), posX, negY, isControlledByTrafficLight, uuid);
            break;
        }
    }