コード例 #1
0
 public static bool CheckMyEndPosition(Transform transform, StreetDirection direction, Vector3 endPosition)
 {
     if(CompareTwoPositionsWRTDirections(direction, transform.position, endPosition, 3)){
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: TrafficLight.cs プロジェクト: AmeraCSD/TrafficGame
 public TrafficLight(StreetDirection n, GameObject light, bool stopped)
 {
     _type = n;
     _light = light;
     _stopped = stopped;
     _onHold = false;
 }
コード例 #3
0
ファイル: DirtRoad.cs プロジェクト: lcfcosta/CityFuture
        // Add building Component to the gameObject
        public static DirtRoad CreateComponent(GameObject where, StreetDirection parameter1)
        {
            DirtRoad myC = where.AddComponent <DirtRoad>();

            myC.setStreetDirection(parameter1);

            return(myC);
        }
コード例 #4
0
        // Add building Component to the gameObject
        public static TwoLaneStreet CreateComponent(GameObject where, StreetDirection parameter1)
        {
            TwoLaneStreet myC = where.AddComponent <TwoLaneStreet>();

            myC.setStreetDirection(parameter1);

            return(myC);
        }
コード例 #5
0
        // Add building Component to the gameObject
        public static DenseAvenue CreateComponent(GameObject where,
                                                  StreetDirection parameter1)
        {
            DenseAvenue myC = where.AddComponent <DenseAvenue>();

            myC.setStreetDirection(parameter1);

            return(myC);
        }
コード例 #6
0
ファイル: Ramp.cs プロジェクト: lcfcosta/CityFuture
        // Add building Component to the gameObject
        public static Ramp CreateComponent(GameObject where,
                                           StreetDirection parameter1)
        {
            Ramp myC = where.AddComponent <Ramp>();

            myC.setStreetDirection(parameter1);

            return(myC);
        }
コード例 #7
0
        // Add building Component to the gameObject
        public static AvenuePlusTrain CreateComponent(GameObject where,
                                                      StreetDirection parameter1)
        {
            AvenuePlusTrain myC = where.AddComponent <AvenuePlusTrain>();

            myC.setStreetDirection(parameter1);

            return(myC);
        }
コード例 #8
0
        // Add building Component to the gameObject
        public static ParkWay CreateComponent(GameObject where,
                                              StreetDirection parameter1)
        {
            ParkWay myC = where.AddComponent <ParkWay>();

            myC.setStreetDirection(parameter1);

            return(myC);
        }
コード例 #9
0
        // Add building Component to the gameObject
        public static PreBuilt CreateComponent(GameObject where,
                                               StreetDirection parameter1)
        {
            PreBuilt myC = where.AddComponent <PreBuilt>();

            myC.setStreetDirection(parameter1);

            return(myC);
        }
コード例 #10
0
ファイル: HumanPath.cs プロジェクト: AmeraCSD/TrafficGame
 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;
 }
コード例 #11
0
ファイル: Vehicle.cs プロジェクト: AmeraCSD/TrafficGame
    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;
    }
コード例 #12
0
ファイル: MapProducer.cs プロジェクト: AmeraCSD/TrafficGame
 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;
     }
 }
コード例 #13
0
    /*
    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;
    }
コード例 #14
0
    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;
    }
コード例 #15
0
 public static bool IsLeavingTheStreet(Transform transform, StreetDirection direction,Vector3 endPosition, Street street)
 {
     if(CompareTwoPositionsWRTDirections(direction, transform.position, endPosition, 0)){
         return true;
     }
     return false;
 }
コード例 #16
0
    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;
        }
    }
コード例 #17
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);
        }
    }
コード例 #18
0
    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;
    }
コード例 #19
0
    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);
        }
    }
コード例 #20
0
ファイル: Street.cs プロジェクト: lcfcosta/CityFuture
 public void setStreetDirection(StreetDirection direction)
 {
     this.street_direction = direction;
 }
コード例 #21
0
    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;
    }
コード例 #22
0
    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;
    }
コード例 #23
0
    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;
    }