private void constructLane2Level3() { var lane = new Lane(this.backgroundWidth); lane.AddVehicle(this.vehicleFactory.ConstructTruckThatMovesRight(4)); lane.AddVehicle(this.vehicleFactory.ConstructTruckThatMovesRight(4)); lane.SetVehiclesToLane(this.calculateLanePosition(2)); this.lanes.Add(lane); }
private void constructLane1Level1() { var lane = new Lane(this.backgroundWidth); lane.AddVehicle(this.vehicleFactory.ConstructCarThatMovesLeft(1)); lane.AddVehicle(this.vehicleFactory.ConstructCarThatMovesLeft(1)); lane.SetVehiclesToLane(this.calculateLanePosition(1)); this.lanes.Add(lane); }
private bool GetNextLane() { if (_PathIdx == _Path.Count - 1) { Destroy(gameObject); _Destroy = true; return(false); } int idx = _CurrentLane._Nodes[1].connectedLanes.IndexOf(_Path[_PathIdx + 1]); if (idx == -1) { return(false); } ++_PathIdx; Lane current = _Path[_PathIdx]; if (_CurrentCrossroad && current.Parent != null && _CurrentLane.Parent == null) { _CurrentCrossroad.LeaveCrossRoad(_CurrentLane); _CurrentCrossroad = null; } current.AddVehicle(gameObject); return(true); }
public bool SpawnVehicle() { if (_LastVehicle && Vector2.Distance(_LastVehicle.transform.position, transform.position) < 2) { return(false); } List <Lane> path = Network.instance.CalculatePath(_ConnectedLane._Nodes[0]); if (path == null) { return(false); } GameObject vehicle = Instantiate(_VehicleBP); vehicle.transform.position = transform.position; _ConnectedLane.AddVehicle(vehicle); vehicle.GetComponent <Vehicle>().path = path; _LastVehicle = vehicle; return(true); }
/// <summary> /// Add the car to the lane. /// </summary> public override void OnEnter() { lane.AddVehicle(car); }
/// <summary> /// Add the car to the lane the car is merging into /// </summary> public override void OnEnter() { currentLane.AddVehicle(car); nextLane.AddVehicle(car); }