private void WatchLeftTL() { if (leftTL != null) { if (!car.GetCoupledLeft()) { distLeft = GetDistanceToSignal(leftTL); if (distLeft <= 0) { GetTrafficLights(); return; } if (distLeft < 1500 && distLeft > 1100) { if (engine.InstructionsHandler < -5) { engine.InstructionsHandler = -5; } } else if (distLeft < 1100 && distLeft > 800) { if (engine.InstructionsHandler < -4) { engine.InstructionsHandler = -4; } } else if (distLeft <= 800 && distLeft > 300) { if (engine.InstructionsHandler < -3) { engine.InstructionsHandler = -3; } } else if (distLeft <= 300 && distLeft > 150) { if (engine.InstructionsHandler < -2) { engine.InstructionsHandler = -2; } } else if (distLeft <= 150 && distLeft > 5) { if (engine.InstructionsHandler < -1) { engine.InstructionsHandler = -1; } } else if (distLeft <= 5 && distLeft > 0) { if (engine.InstructionsHandler < 0) { engine.HandlerZero(); } } } } }
public void GetOwnListRS() { if (rsComposition.CarComposition.IsOutside) { return; } ClearOwnListRS(); count = 0; for (int i = 0; i < listComps.Length; i++) { tempComp = listComps [i]; if (tempComp == null) { continue; } if (!tempComp.IsActive) { continue; } if (tempComp.IsOutside) { continue; } if (tempComp == rsComposition.CarComposition) { continue; } for (int j = engineRS.FirstTrackIndex; j <= engineRS.LastTrackIndex; j++) { if (engineRS.OwnPath[j] == tempComp.MainCar.OwnTrack) { ownListComps [count] = tempComp; count++; } } } leftCar = null; rightCar = null; tempDistLeft = 100000; tempDistRight = 100000; tempLeftRS = null; tempRightRS = null; for (int i = 0; i < ownListComps.Length; i++) { tempComp = ownListComps [i]; if (tempComp == null) { return; } tempLeftRS = tempComp.RightCar; tempRightRS = tempComp.LeftCar; // look for left car if (!engineRS.GetCoupledLeft() && engineT.position.x > tempLeftRS.GetPositionX()) { if (GetDistanceToCar(tempLeftRS) < tempDistLeft) { tempDistLeft = GetDistanceToCar(tempLeftRS); leftCar = tempLeftRS; } } else if (!engineRS.GetCoupledRight() && engineT.position.x < tempRightRS.GetPositionX()) { if (GetDistanceToCar(tempRightRS) < tempDistRight) { tempDistRight = GetDistanceToCar(tempRightRS); rightCar = tempRightRS; } } } }