private void Simulate() { SpawnTimeGenerator.SetLambda(_lambdaState); for (int i = 0; i < 300; i++) { _simulationMaster.UpdateSimulation(SimulatedCycleTime); } _lambdaState += 0.0002f; if (_lambdaState >= 0.1) { _testState = TestState.CalculateResults; } }
/// <summary> /// Initializes the whole page. Called before the node is added to the tree by the lesson controller. /// </summary> public override void InitialiseWith(IMainNode mainNode, ILessonEntity openedLesson) { _topTrafficLight = GetNode <TrafficControlSystem>("Signalisation/TrafficControlSystemTop"); _topTrafficLight.SetToGreen(SimulationInput.PollBoolean(_topTrafficLightKey)); _botTrafficLight = GetNode <TrafficControlSystem>("Signalisation/TrafficControlSystemBot"); _botTrafficLight.SetToGreen(SimulationInput.PollBoolean(_botTrafficLightKey)); PathController topPath = GetNode <PathController>("DynamicCars/TopPath"); topPath.Setup(_topTrafficLight); PathController botPath = GetNode <PathController>("DynamicCars/BotPath"); botPath.Setup(_botTrafficLight); _trafficController = new TrafficController(topPath, botPath); SpawnTimeGenerator.ResetGenerator(); }
private int CheckNextSpawnTime(PathController referencePath, int time) { if (time <= 0) { time = SpawnTimeGenerator.GetNextSpawnTime(); if (referencePath.SpawnPossible()) { DynamicCar car = (DynamicCar)((PackedScene)GD.Load(CarReference)).Instance(); car.Initialise(); referencePath.AddChildAndStart(car); _activeCars.Add(car); } } return time; }
/// <summary> /// Initializes the whole twat viewer. Called before the node is added to the tree by the lesson controller. /// </summary> public override void InitialiseWith(IMainNode mainNode, ILessonEntity openedLesson) { _openedLesson = openedLesson; _simulation = GetNode <RoadConstructionSite>("PlantViewportContainer/PlantViewport/RoadConstructionSite"); _simulationMaster = DiagramSimulationLoader.LoadTemp(openedLesson, _simulation); if (_simulationMaster != null) { _simulation.InitialiseWith(mainNode, openedLesson); _isExecutable = _simulationMaster.IsProgramSimulationValid(); } if (_simulationMaster == null || !_isExecutable) { _isExecutable = false; _testState = TestState.Done; _openedLesson.SetAndSaveStars(0); } SpawnTimeGenerator.ResetGenerator(); }
public void Setup() { GetNode <Slider>("LambdaOption").Value = SpawnTimeGenerator.GetLambda(); GetNode <Slider>("LambdaOption").Connect("value_changed", this, nameof(OnValueChanged)); Visible = true; }
public void OnValueChanged(float value) { SpawnTimeGenerator.SetLambda(value); }