private bool ShouldPressButton()
        {
            bool  lightSignalOn = SimulationInput.PollBoolean(LightsKey);
            float carUnitOffset = Subscene.Vehicle.CarUnitOffset;

            if (lightSignalOn)
            {
                if (carUnitOffset > VehicleAgentController.ExitsTunnel && !ForgetsToTurnLightsOff)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (carUnitOffset > VehicleAgentController.EntersTunnelSoon && carUnitOffset < VehicleAgentController.ExitsTunnel)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
 /// <summary>
 /// Calculates the next simulation step.
 /// It will read the SimulationInput values and stores in the end the new values to the SimulationOutput.
 /// </summary>
 protected override void CalculateNextStep(int timeMs)
 {
     _topTrafficLight.SetToGreen(SimulationInput.PollBoolean(_topTrafficLightKey));
     _botTrafficLight.SetToGreen(SimulationInput.PollBoolean(_botTrafficLightKey));
     _trafficController.CalculateNextStep(timeMs);
     SimulationOutput.SetValue(_topTrafficSensorKey, _topTrafficLight.IsCarInRange());
     SimulationOutput.SetValue(_botTrafficSensorKey, _botTrafficLight.IsCarInRange());
 }
 private void UpdateInputs()
 {
     FieldGeneratorInput = SimulationInput.PollBoolean(FieldGeneratorKey);
     LaserInput          = SimulationInput.PollBoolean(LaserKey);
     EmitterInput        = SimulationInput.PollBoolean(EmitterKey);
     FocusInput          = SimulationInput.PollBoolean(FocusKey);
     EmitterMotorInput   = SimulationInput.PollInteger(EmitterMotorKey);
     FocusMotorInput     = SimulationInput.PollInteger(FocusMotorKey);
 }
        /// <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();
        }
예제 #5
0
 private void UpdateInputs(int deltaTime)
 {
     SafeguardResetSignal = SimulationInput.PollBoolean(SafeguardResetKey);
     AlarmLightSignal     = SimulationInput.PollBoolean(AlarmLightKey);
     ChargingSignal       = SimulationInput.PollBoolean(ChargingKey);
     FillingSignal        = SimulationInput.PollBoolean(FillingKey);
     EmergencyActors.EmergencyLight.Update(AlarmLightSignal, deltaTime);
     if (SafeguardResetSignal)
     {
         if (BatterySignal < 40 || PressureSignal < 1900)
         {
             FailSystem();
         }
         else
         {
             SafeguardSignal = false;
         }
     }
     if (ChargingSignal)
     {
         BatterySignal += 0.1f;
         EmergencyActors.Battery.ShowAs(BubbleSprite.Bubble.Say, BubbleSprite.Expression.Waiting, 0.1f);
         if (BatterySignal > 50f)
         {
             BatterySignal = 0;
             FailSystem();
         }
     }
     if (FillingSignal)
     {
         PressureSignal += 2;
         EmergencyActors.Pressure.ShowAs(BubbleSprite.Bubble.Say, BubbleSprite.Expression.Waiting, 0.1f);
         if (PressureSignal > 2400)
         {
             PressureSignal = 0;
             FailSystem();
         }
     }
 }
 private void UpdateLights()
 {
     Subscene.TunnelLights.UpdateLightSignal(SimulationInput.PollBoolean(LightsKey));
 }