private void WatchRightTL() { if (rightTL != null) { if (!car.GetCoupledRight()) { distRight = GetDistanceToSignal(rightTL); if (distRight <= 0) { GetTrafficLights(); return; } if (distRight < 1500 && distRight > 800) { if (engine.InstructionsHandler > 5) { engine.InstructionsHandler = 5; } } else if (distRight < 1100 && distRight > 800) { if (engine.InstructionsHandler > 4) { engine.InstructionsHandler = 4; } } else if (distRight <= 800 && distRight > 300) { if (engine.InstructionsHandler > 3) { engine.InstructionsHandler = 3; } } else if (distRight <= 300 && distRight > 150) { if (engine.InstructionsHandler > 2) { engine.InstructionsHandler = 2; } } else if (distRight <= 150 && distRight > 5) { if (engine.InstructionsHandler > 1) { engine.InstructionsHandler = 1; } } else if (distRight <= 5 && distRight > 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; } } } }