private void Update() { if (PauseMenuManager.isGamePaused) { return; } if (isDead || CurrentRoad == null) { FadeOut(); return; } float step = speed * Time.deltaTime; transform.position = Vector3.MoveTowards(transform.position, CurrentRoad.Node.position, step); Quaternion rotateTo = (PreviousRoad == null) ? CurrentRoad.Node.rotation : PreviousRoad.Node.rotation; transform.rotation = Quaternion.RotateTowards(transform.rotation, rotateTo, 512.0f * Time.deltaTime); if (Vector3.Distance(transform.position, CurrentRoad.Node.position) < 0.001f) { Road tempRoad = CurrentRoad; if (CurrentRoad.Type == RoadType.Straight) { StraightRoad straightRoad = (StraightRoad)CurrentRoad; CurrentRoad = (PreviousRoad == straightRoad.RoadA) ? straightRoad.RoadB : straightRoad.RoadA; } else if (CurrentRoad.Type == RoadType.Curved) { CurvedRoad curvedRoad = (CurvedRoad)CurrentRoad; if (PreviousRoad == curvedRoad.RoadB1 || PreviousRoad == curvedRoad.RoadB2) { CurrentRoad = curvedRoad.RoadA; } else if (curvedRoad.IsToggable) { CurrentRoad = (curvedRoad.ToggleRotate) ? curvedRoad.RoadB1 : curvedRoad.RoadB2; } else { CurrentRoad = (PreviousRoad == curvedRoad.RoadA) ? ((curvedRoad.RoadB1 != null) ? curvedRoad.RoadB1 : curvedRoad.RoadB2) : curvedRoad.RoadA; } } else if (CurrentRoad.Type == RoadType.Merge) { MergeRoad mergeRoad = (MergeRoad)CurrentRoad; CurrentRoad = (PreviousRoad == mergeRoad.RoadA1 || PreviousRoad == mergeRoad.RoadA2) ? mergeRoad.RoadB : mergeRoad.RoadA1; } else if (CurrentRoad.Type == RoadType.Slip) { SlipRoad slipRoad = (SlipRoad)CurrentRoad; CurrentRoad = (slipRoad.ToggleRotate) ? slipRoad.RoadB1 : slipRoad.RoadB2; } PreviousRoad = tempRoad; } else { FadeIn(); } }
public static Road CreateCurvedRightDown(int x, int y) { CurvedRoad r = (CurvedRoad)CreateCurved(x, y, 0); r.right = true; r.down = true; return(r); }
public static Road CreateCurvedRightUp(int x, int y) { CurvedRoad r = (CurvedRoad)CreateCurved(x, y, 90); r.right = true; r.up = true; return(r); }
public static Road CreateCurvedLeftDown(int x, int y) { CurvedRoad r = (CurvedRoad)CreateCurved(x, y, 270); r.left = true; r.down = true; return(r); }
public static Road CreateCurvedLeftUp(int x, int y) { CurvedRoad r = (CurvedRoad)CreateCurved(x, y, 180); r.left = true; r.up = true; return(r); }
/** * Default is down-right * */ public static Road CreateCurved(int x, int y, float zRotation) { InitializePrefabs(); GameObject road = (GameObject)SpoofInstantiate(curvedPrefab); road.transform.position = new Vector3(x, y, 0); road.transform.Rotate(0, 0, zRotation); CurvedRoad r = road.GetComponent <CurvedRoad>(); r.xPos = x; r.yPos = y; r.neighbourRoads = new List <Road>(); return(r); }
void Start() { SR = this.GetComponent <StraightRoad>(); CR = this.GetComponent <CurvedRoad>(); currentPlacement = SR; map = new int[gridSizeX, gridSizeY]; for (int i = 0; i < map.GetLength(0); i++) { for (int j = 0; j < map.GetLength(1); j++) { map[i, j] = (int)cellVal.EMPTY; } } selectCell(); }
//not quite fully functional private static void PlaceCarOnCurvedRoad(Car c, CurvedRoad r) { FaceCarInDirection(c, new Vector2(0.5f, 0.5f)); RotateCarByAngle(c, r.transform.rotation.eulerAngles.z); }