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)); } } }
public static Road CreateNarrowLeftRight(int x, int y) { NarrowRoad r = (NarrowRoad)CreateNarrow(x, y, 0); r.left = true; r.right = true; return(r); }
public static Road CreateNarrowUpDown(int x, int y) { NarrowRoad r = (NarrowRoad)CreateNarrow(x, y, 90); r.up = true; r.down = true; return(r); }
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); }