public static bool CheckMyEndPosition(Transform transform, StreetDirection direction, Vector3 endPosition) { if(CompareTwoPositionsWRTDirections(direction, transform.position, endPosition, 3)){ return true; } return false; }
public TrafficLight(StreetDirection n, GameObject light, bool stopped) { _type = n; _light = light; _stopped = stopped; _onHold = false; }
// Add building Component to the gameObject public static DirtRoad CreateComponent(GameObject where, StreetDirection parameter1) { DirtRoad myC = where.AddComponent <DirtRoad>(); myC.setStreetDirection(parameter1); return(myC); }
// Add building Component to the gameObject public static TwoLaneStreet CreateComponent(GameObject where, StreetDirection parameter1) { TwoLaneStreet myC = where.AddComponent <TwoLaneStreet>(); myC.setStreetDirection(parameter1); return(myC); }
// Add building Component to the gameObject public static DenseAvenue CreateComponent(GameObject where, StreetDirection parameter1) { DenseAvenue myC = where.AddComponent <DenseAvenue>(); myC.setStreetDirection(parameter1); return(myC); }
// Add building Component to the gameObject public static Ramp CreateComponent(GameObject where, StreetDirection parameter1) { Ramp myC = where.AddComponent <Ramp>(); myC.setStreetDirection(parameter1); return(myC); }
// Add building Component to the gameObject public static AvenuePlusTrain CreateComponent(GameObject where, StreetDirection parameter1) { AvenuePlusTrain myC = where.AddComponent <AvenuePlusTrain>(); myC.setStreetDirection(parameter1); return(myC); }
// Add building Component to the gameObject public static ParkWay CreateComponent(GameObject where, StreetDirection parameter1) { ParkWay myC = where.AddComponent <ParkWay>(); myC.setStreetDirection(parameter1); return(myC); }
// Add building Component to the gameObject public static PreBuilt CreateComponent(GameObject where, StreetDirection parameter1) { PreBuilt myC = where.AddComponent <PreBuilt>(); myC.setStreetDirection(parameter1); return(myC); }
public HumanPath(Vector3 generationPos, string walkAnimationName, string passAnimationName, List<Street> toBePassedStreets, StreetDirection directionAxis, float walkEndPos, float passEndPos, bool locked) { _generationPos = generationPos; _walkAnimationName = walkAnimationName; _passAnimationName = passAnimationName; _toBePassedStreets = toBePassedStreets; _directionAxis = directionAxis; _walkEndPos = walkEndPos; _passEndPos = passEndPos; _isLocked = locked; }
private VehicleType _type; //the vehicle type #endregion Fields #region Constructors //the constructor public Vehicle(VehicleType type,float speed,float size, StreetDirection curDir, Street curStreet, Street nextStreet,int curStrNum, GamePath path, AudioClip theHorn) { _type = type; _speed = speed; _size = size; _currentDirection = curDir; _currentStreet = curStreet; _nextStreet = nextStreet; _curStreetNumber = curStrNum; _myPath = path; _horn = theHorn; }
private void SetTheDirection() { if(startPoint.x < endPoint.x){ direction = StreetDirection.Right; } if(startPoint.x > endPoint.x){ direction = StreetDirection.Left; } if(startPoint.z < endPoint.z){ direction = StreetDirection.Up; } if(startPoint.z < endPoint.z){ direction = StreetDirection.Down; } }
/* public static int CheckStoppingPosition(StreetDirection direction, Vector3 vehiclePos, float stopPos){ if(direction == StreetDirection.Right && vehiclePos.x > stopPos - 15) return 1; else if(direction == StreetDirection.Left && vehiclePos.x < stopPos + 15) return 2; else if(direction == StreetDirection.Down && vehiclePos.z < stopPos + 15) return 3; else if(direction == StreetDirection.Up && vehiclePos.z > stopPos - 15) return 4; else return -1; } */ public static bool CheckStoppingPosition(StreetDirection direction, Vector3 vehiclePos, float stopPos) { int offset = 15; if(direction == StreetDirection.Right && vehiclePos.x > stopPos - offset) return true; else if(direction == StreetDirection.Left && vehiclePos.x < stopPos + offset) return true; else if(direction == StreetDirection.Down && vehiclePos.z < stopPos + offset) return true; else if(direction == StreetDirection.Up && vehiclePos.z > stopPos - offset) return true; else return false; }
public static bool CompareTwoPositionsWRTDirections(StreetDirection direction, Vector3 firstPos, Vector3 secondPos, float offset) { if(direction == StreetDirection.Left){ if(firstPos.x < secondPos.x - offset){ return true; } } if(direction == StreetDirection.Right){ if(firstPos.x > secondPos.x + offset) return true; } if(direction == StreetDirection.Up ){ if(firstPos.z > secondPos.z + offset){ return true; } } if(direction == StreetDirection.Down ){ if(firstPos.z < secondPos.z - offset) return true; } return false; }
public static bool IsLeavingTheStreet(Transform transform, StreetDirection direction,Vector3 endPosition, Street street) { if(CompareTwoPositionsWRTDirections(direction, transform.position, endPosition, 0)){ return true; } return false; }
private void ResetVehicleAttributes() { if(myVehicle.NextStreet != null){ myVehicle.CurrentStreet = myVehicle.NextStreet; myVehicle.CurrentDirection = myVehicle.CurrentStreet.StreetLight.Type; myVehicle.CurrentStreetNumber ++; //Debug.Log(myVehicle.CurrentStreetNumber); if(myVehicle.CurrentStreetNumber+1 != _path.PathStreets.Count ){ myVehicle.NextStreet =_path.PathStreets[myVehicle.CurrentStreetNumber+1]; _nextDirection = myVehicle.NextStreet.StreetLight.Type; } else{ myVehicle.NextStreet = null; // Debug.Log("next street is null " ); } _street = myVehicle.CurrentStreet; _direction = myVehicle.CurrentDirection; _street.VehiclesNumber++; _light = _street.StreetLight; _stopPosition = _street.StopPosition; _endPosition = _street.EndPoint; _myQueue = _street.StrQueue; dequeued = false; enqueued = false; passed = false; stoppingTimerforAnger = 0; stoppingTimerforAngerSet = false; satisfyAdjustedOnTime = false; angerMount = 0.5f; dist = 0; } }
public void InitStreetAndVehicleAttributes() { _path = myVehicle.MyPath; _street = myVehicle.CurrentStreet; _direction = myVehicle.CurrentDirection; speed = myVehicle.Speed; _size = myVehicle.Size; vehType = myVehicle.Type; _light = _street.StreetLight; _stopPosition = _street.StopPosition; _endPosition = _street.EndPoint; _myQueue = _street.StrQueue; _nextDirection = myVehicle.NextStreet.StreetLight.Type; myRayCastRange = Globals.RAY_CAST_RANGE + _size; if(vehType == VehicleType.Taxi){ taxiStops = Taxi.SetGetTaxiRandomStops(gameMasterScript.gameTime -5, gameMasterScript.gameTime-10); } }
public static bool EndAccelerationOnArrival(StreetDirection direction, Vector3 vehiclePos, float stopPos) { if(direction == StreetDirection.Right && vehiclePos.x > stopPos ) return true; else if(direction == StreetDirection.Left && vehiclePos.x < stopPos) return true; else if(direction == StreetDirection.Down && vehiclePos.z < stopPos ) return true; else if(direction == StreetDirection.Up && vehiclePos.z > stopPos) return true; else return false; }
public static float GetDistanceBetweenVehicleAndOtherPosition(Vector3 vehiclePos, Vector3 pos, StreetDirection direction) { if(direction == StreetDirection.Right || direction == StreetDirection.Left){ return Mathf.Abs(pos.x - vehiclePos.x); } else { return Mathf.Abs(pos.z - vehiclePos.z); } }
public void setStreetDirection(StreetDirection direction) { this.street_direction = direction; }
public static bool HasFinishedRotation(Vector3 transformForward, bool rotateNow, StreetDirection direction, StreetDirection nextDirection, VehicleController vehScript) { //Debug.Log("direc is >> " + direction); if(direction != nextDirection){ // Debug.Log("transformForward ... " + -1*transformForward.x ); if(direction == StreetDirection.Left && -1*transformForward.x > -0.01 && rotateNow && nextDirection == StreetDirection.Up){ vehScript.gameObject.transform.forward = -1*Vector3.forward; vehScript.speed = vehScript.myVehicle.Speed; return true; } if(direction == StreetDirection.Right && -1*transformForward.x < 0.01 && rotateNow && nextDirection == StreetDirection.Up){ vehScript.gameObject.transform.forward = -1*Vector3.forward; vehScript.speed = vehScript.myVehicle.Speed; // Debug.Log("safwattttttttttttt"); return true; } if(direction == StreetDirection.Up && -1*transformForward.z < 0.01 && rotateNow && nextDirection == StreetDirection.Left){ vehScript.gameObject.transform.forward = Vector3.right; vehScript.speed = vehScript.myVehicle.Speed; return true; } if(direction == StreetDirection.Down && -1*transformForward.z > -0.01 && rotateNow && nextDirection == StreetDirection.Left){ vehScript.gameObject.transform.forward = Vector3.right; vehScript.speed = vehScript.myVehicle.Speed; return true; } /////////////////////////////////////////////////// if(direction == StreetDirection.Left && -1*transformForward.x > -0.01 && rotateNow && nextDirection == StreetDirection.Down){ vehScript.gameObject.transform.forward = Vector3.forward; vehScript.speed = vehScript.myVehicle.Speed; return true; } if(direction == StreetDirection.Right && -1*transformForward.x < 0.01 && rotateNow && nextDirection == StreetDirection.Down){ vehScript.gameObject.transform.forward = Vector3.forward; vehScript.speed = vehScript.myVehicle.Speed; return true; } if(direction == StreetDirection.Down && -1*transformForward.z > -0.01 && rotateNow && nextDirection == StreetDirection.Right){ vehScript.gameObject.transform.forward = -1*Vector3.right; vehScript.speed = vehScript.myVehicle.Speed; return true; } if(direction == StreetDirection.Up && -1*transformForward.z < 0.01 && rotateNow && nextDirection == StreetDirection.Right){ vehScript.gameObject.transform.forward = -1*Vector3.right; vehScript.speed = vehScript.myVehicle.Speed; return true; } else return false; } return true; }
public static bool IsLeavingTheStreet_Rotate(GameObject [] corners, Transform transform, StreetDirection direction,Vector3 endPosition, Street street, StreetDirection nextDirection, VehicleController vehScript) { Vector3 obPos = transform.position; if(CompareTwoPositionsWRTDirections(direction, transform.position, endPosition, -5)){ if(vehScript.rotateAroundPosition == Vector3.zero){ // vehScript.speed = 10; // vehScript.haveToReduceMySpeed = true; vehScript.rotateAroundPosition = MathsCalculatios.GetNearestCorner(corners, transform.position); // Debug.Log(vehScript.rotateAroundPosition); // Debug.Log("the center " + vehScript.rotateAroundPosition); } return true; } else { vehScript.rotateAroundPosition = Vector3.zero; } return false; }
public static bool HaveToAccelerate(Transform transform, StreetDirection direction,Vector3 endPosition, Street street, VehicleController vehScript) { float rate = 2; //Debug.Log("da5al hena "); if(CompareTwoPositionsWRTDirections(direction, transform.position, endPosition, -15)){ // if(!vehScript._light.Stopped && vehScript.speed > 0){ // vehScript.speed -= rate ; // } // Debug.Log("hello I'm here"); if(!vehScript._light.Stopped) vehScript.speed = 18 ; vehScript.haveToReduceMySpeed = true; return true; } return false; }