예제 #1
0
    private static void PlaceCarOnNarrowRoad(Car c, NarrowRoad r)
    {
        //road orientation, car orientation
        float carZ = c.transform.rotation.eulerAngles.z;
        //road can only be left or up
        bool roadUp = r.up;

        if (roadUp)
        {
            if (carZ >= 90 && carZ <= 270)
            {
                //going down
                FaceCarInDirection(c, new Vector2(0, -1));
            }
            else
            {
                //going up
                FaceCarInDirection(c, new Vector2(0, +1));
            }
        }
        else
        {
            if (carZ >= 0 && carZ <= 180)
            {
                //going left
                FaceCarInDirection(c, new Vector2(-1, 0));
            }
            else
            {
                //going right
                FaceCarInDirection(c, new Vector2(+1, 0));
            }
        }
    }
예제 #2
0
    public static Road CreateNarrowLeftRight(int x, int y)
    {
        NarrowRoad r = (NarrowRoad)CreateNarrow(x, y, 0);

        r.left  = true;
        r.right = true;
        return(r);
    }
예제 #3
0
    public static Road CreateNarrowUpDown(int x, int y)
    {
        NarrowRoad r = (NarrowRoad)CreateNarrow(x, y, 90);

        r.up   = true;
        r.down = true;
        return(r);
    }
예제 #4
0
    public static Road CreateNarrow(int x, int y, float zRotation)
    {
        InitializePrefabs();
        GameObject road = (GameObject)SpoofInstantiate(narrowPrefab);

        road.transform.position = new Vector3(x, y, 0);
        NarrowRoad r = road.GetComponent <NarrowRoad>();

        r.transform.Rotate(0, 0, zRotation);
        r.xPos           = x;
        r.yPos           = y;
        r.neighbourRoads = new List <Road>();
        return(r);
    }