Example #1
0
    // private bool checkForwardRoadChunk(roadChunk rChunk, Street _street)
    // {
    //     var hit = Physics2D.Raycast(rChunk.End.position, rChunk.transform.up);
    //     if (hit.distance > 0 /*.4 * roadUnit*/ && hit.distance < /*1.5 * */roadUnit)
    //     {
    //         if (hit.transform.tag == "road")
    //         {
    //             var rChunkLocal = roadChunks[1];
    //             rChunkLocal.transform.position = rChunk.End.position +
    //                                              (new Vector3(hit.point.x, hit.point.y, 0) - rChunk.End.position) / 2;
    //             rChunkLocal.transform.rotation = rChunk.transform.rotation;
    //             roadChunks[1].transform.localScale = new Vector3
    //             (rChunkLocal.transform.localScale.x,
    //                 (new Vector3(hit.point.x, hit.point.y, 0) - rChunk.End.position).magnitude * roadUnit,
    //                 rChunkLocal.transform.localScale.z);
    //             var rChunk2 = Instantiate(roadChunks[1], rChunkLocal.transform.position, rChunkLocal.transform.rotation,
    //                 Map.transform);
    //             _street.RoadChunks.Add(rChunk2);
    //         }
    //
    //         return false;
    //     }
    //
    //     return true;
    // }

    private bool checkForwardRoadChunk(roadChunk rChunk, Street _street)
    {
        var hit = Physics2D.Raycast(rChunk.transform.position, rChunk.transform.up);

        if (hit.distance > 0 && hit.distance < roadUnit)
        {
            return(false);
        }
        return(true);
    }
Example #2
0
    private bool checkLeftRoadChunk(roadChunk rChunk)
    {
        var hit = Physics2D.Raycast(rChunk.Left.position, rChunk.Left.up);

        if (hit.distance > 0 && hit.distance < 1.5 * roadUnit)
        {
            return(false);
        }
        // hit = Physics2D.Raycast(rChunk.Begin.position, rChunk.Left.up);
        // if (hit.distance > 0 && hit.distance < 1.5 * roadUnit) return false;
        // hit = Physics2D.Raycast(rChunk.End.position, rChunk.Left.up);
        // if (hit.distance > 0 && hit.distance < 1.5 * roadUnit) return false;
        return(true);
    }
Example #3
0
    private float CheckForwardRoadChunk(roadChunk _roadChunk, float _roadscale, Street _street = null)
    {
        var hit         = Physics2D.Raycast((_roadChunk.Begin.position), _roadChunk.End.up);
        var hitDistance = hit.distance;

        if (hit.distance < roadUnit / 2)
        {
            hit         = Physics2D.Raycast((_roadChunk.transform.position), _roadChunk.End.up);
            hitDistance = hit.distance;
        }
        else
        {
            hitDistance = (hit.distance - (roadUnit / 2));
        }
        if (hitDistance != 0 && (hitDistance / roadUnit) < _roadscale && hit.collider.gameObject.tag == "road")
        {
            //_roadChunk.ended = "";
            //hit.collider.gameObject.GetComponent<roadChunk>().ended = "";
            Vector3 pointOfHit = hit.point;
            _roadChunk.GeneratedStreets.Add(Tuple.Create(pointOfHit, spawnedStreets[hit.collider.gameObject.GetComponent <roadChunk>().streetNo]));
            hit.collider.gameObject.GetComponent <roadChunk>().GeneratedStreets.Add(Tuple.Create(pointOfHit, spawnedStreets[_roadChunk.streetNo]));
        }
        return(hitDistance / roadUnit);
    }
Example #4
0
 public void Insert0(roadChunk _road)
 {
     RoadChunks.Insert(0, _road);
     Length += (_road.End.position - _road.Begin.position).magnitude;
 }
Example #5
0
 public void Add(roadChunk _road)
 {
     RoadChunks.Add(_road);
     Length += (_road.End.position - _road.Begin.position).magnitude;
 }