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, 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; } }