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); } } } }
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); } }
public void setCollider(string id, CrossingColliderX coll) { crossingColliderX = coll; switch (id) { case "NegX": coll.setDirectionsIntern(getChildGameObject(gameObject, "PathPosX"), negY, posX, posY, isControlledByTrafficLight, uuid); break; case "PosX": coll.setDirectionsIntern(getChildGameObject(gameObject, "PathNegX"), posY, negX, negY, isControlledByTrafficLight, uuid); break; case "NegY": coll.setDirectionsIntern(getChildGameObject(gameObject, "PathPosY"), posX, posY, negX, isControlledByTrafficLight, uuid); break; case "PosY": coll.setDirectionsIntern(getChildGameObject(gameObject, "PathNegY"), negX, negY, posX, isControlledByTrafficLight, uuid); break; } }