public TrafficLight() { id = -1; //shows, that a valid id is missing position = null; state = LightStates.RED; crossroadId = -1; //shows, that a valid id is missing }
public void RestartCurrentLevel() { if (sv.sound) { AudioManager.PlaySound(AudioManager.Sounds.MenuClick); } arrow.GetComponent <rotateArrow>().ReCreate(); gameOverCanvas.enabled = false; PauseCanvas.enabled = false; CanvasLvlComplete.enabled = false; if (gameStateBerorePause == GameStates.survival) { gameManager.GetComponent <SurvivalMode>().SetStartValues(); gameState = GameStates.survival; totalRingsCounter = 0; EndPause(); } else { gameState = GameStates.game; levels.GetComponent <Levels>().Stoplvl(currentLvl); levels.GetComponent <Levels>().Startlvl(currentLvl); } LightState = LightStates.white; RingHandler.GetComponent <RingHandler>().DelateAllRings(); }
public static bool DelcomLEDAction(uint hUSB, LightColors color, LightStates action) { bool success = false; //lock here so multiple threads don't try to toggle LEDs at once //(though presently only one instance of the program works with the light at a time anyway) lock (DelcomLightWrapper.CurrentLEDStates) { LightStates dictVal; if (DelcomLightWrapper.CurrentLEDStates.TryGetValue(color, out dictVal) && dictVal == action) { //that LED is already in appropriate state success = true; } else { for (int i = 0; i < LEDMaxFailures; i++) { if (Delcom.DelcomLEDControl(hUSB, (byte)color, (byte)action) == 0) { DelcomLightWrapper.CurrentLEDStates[color] = action; success = true; break; } else { System.Threading.Thread.Sleep(LEDWaitTime); } } } } return(success); }
} // обрабатывает нажатие зеленой кнопки public void BlueMod_Click(GameObject button) { gameButtonsHandler.GetComponent <GameButtonsHandler>().SetActiveButton(button); if (sv.sound) { AudioManager.PlaySound(AudioManager.Sounds.ColourChange); } if (LightState == LightStates.red) { animator.SetTrigger("blue"); RingHandler.GetComponent <RingHandler>().RingsReachAbility("red rings"); } if (LightState == LightStates.green) { animator.SetTrigger("blue"); RingHandler.GetComponent <RingHandler>().RingsReachAbility("green rings"); } if (LightState != LightStates.blue) { animator.SetTrigger("blue"); LightState = LightStates.blue; } else { LightState = LightStates.white; animator.SetTrigger("white"); } light.GetComponent <Lighthandler>().Button_pressed("blue"); RingHandler.GetComponent <RingHandler>().RingsReachAbility("blue rings"); } // обрабатывает нажатие синей кнопки
public void PrepareLvl() { if (gameState == GameStates.levels) { HideLevels(); } if (gameState == GameStates.menu) { menuCanvas.enabled = false; } //lvlProgressDestination = -7.2f; gameButtonsHandler.GetComponent <GameButtonsHandler>().SetONOFF(true); gameButtonsHandler.GetComponent <GameButtonsHandler>().ResetAll(); Input.multiTouchEnabled = true; ResetLanterns(true); Time.timeScale = 1; light.GetComponent <Lighthandler>().ChangeLightBrightness("game active"); gameButtonsHandler.GetComponent <GameButtonsHandler>().StartAppearAnimation(); gameCanvas.gameObject.transform.GetChild(0).GetComponent <Button>().interactable = true; // делаем кнопку паузы активной gameOverCanvas.transform.GetChild(0).GetComponent <Animator>().SetTrigger("reset"); // ресет анимации проигранного уровня CanvasLvlComplete.transform.GetChild(0).GetComponent <Animator>().SetTrigger("reset"); CanvasLvlComplete.transform.GetChild(1).GetComponent <Animator>().SetTrigger("reset"); gameCanvas.enabled = true; LightState = LightStates.white; gameState = GameStates.game; }
public void AllOn() { LightState = LightStates.AllOn; WhiteOn(); BlackOn(); }
public void UpdateLight() { Count--; if (Count <= 0) { switch (State) { case LightStates.Green: Count = GlobalVariable.YellowDuration / GlobalVariable.TimerStep; State = LightStates.Yellow; break; case LightStates.Yellow: Count = GlobalVariable.RedDuration / GlobalVariable.TimerStep; State = LightStates.Red; break; case LightStates.Red: Count = GlobalVariable.GreenDuration / GlobalVariable.TimerStep; State = LightStates.Green; break; default: break; } } }
public TrafficLight(int id, Coordinate pos, LightStates state, int crossRoadId) { this.id = id; position = pos; this.state = state; this.crossroadId = crossRoadId; }
public void SetLightState(LightStates newLightState) { Debug.Log($"Changing <color={currentLightState.ToString().ToLower()}>{currentLightState.ToString()} Light</color> to <color={newLightState.ToString().ToLower()}>{newLightState.ToString()} Light</color>"); timer = 0f; currentLightState = newLightState; }
public WindowDispatchViewModel() { OkChannelOrderList = DbHelper.GetOrderListByChannel(EnumChannel.正常道口); channel = ChannelController.Instance; channel.OnOkUpdate += (o, c) => { ProgramCountArrived = channel.CountOkArrived.Software; ChannelCountArrived = channel.CountOkArrived.Hardware; ProgramCountTake = channel.CountOkTake.Software; ChannelCountTake = channel.CountOkTake.Hardware; CountSend = channel.CountSendOK; if (LightStates != null) { LightStates.Clear(); } LightStates = DbHelper.GetAllLightStates(); }; LightManagerErrList = new ObservableCollection <string>(); LightManager.Instance.OnError = new EventHandler <string>((o, e) => { LightManagerErrMsg = e; }); LightStates = DbHelper.GetAllLightStates(); }
public void SetLightState(LightStates newLightState) { Debug.Log($"Changing <color={currentLightState.ToString().ToLower()}>{currentLightState.ToString()} Light</color> to <color={newLightState.ToString().ToLower()}>{newLightState.ToString()} Light</color>"); TimerReset(); currentLightState = newLightState; PhysicalLightChange(); }
private void SetClose() { // Update current light state state = LightStates.CLOSE; // Reset time counter timeCounter = 0f; }
private void SetRange() { // Enable point light pointLight.enabled = true; // Update current light state state = LightStates.RANGE; }
private void SetFar() { // Disable point light pointLight.enabled = false; // Update current light state state = LightStates.FAR; }
public void WhiteOff() { Console.WriteLine("Turning off White Lights"); LightState = LightStates.Undefined; foreach (var light in WhiteLights) { light.isOn = false; } }
public void WhiteOn() { Console.WriteLine("Turning on White Lights"); LightState = LightStates.WhiteOn; foreach (var light in WhiteLights) { light.isOn = true; } }
/// <summary> /// инициализация всех полей /// </summary> private Envirmnt() { Cars = new List <Car>(); Humans = new List <Human>(); Time = 0; LightsState = LightStates.Green; Creators = new List <ObjectCreator>(); }
public void BlackOn() { Console.WriteLine("Turning on Black Lights"); LightState = LightStates.BlackOn; foreach (var light in BlackLights) { light.isOn = true; } }
public static bool DelcomLEDAllAction(uint hUSB, LightStates action) { bool success = false; List <LightColors> lightsRemaining = new List <LightColors>(); //lock here so multiple threads don't try to toggle LEDs at once //(though presently only one instance of the program works with the light at a time anyway) lock (DelcomLightWrapper.CurrentLEDStates) { foreach (KeyValuePair <LightColors, LightStates> lightAndState in DelcomLightWrapper.CurrentLEDStates) { if (lightAndState.Value != action) { lightsRemaining.Add(lightAndState.Key); } } if (lightsRemaining.Count == 0) { //all LEDs already in appropriate state success = true; } else { for (int i = 0; i < LEDMaxFailures; i++) { List <LightColors> lightsFailed = new List <LightColors>(); foreach (LightColors remainingLight in lightsRemaining) { if (Delcom.DelcomLEDControl(hUSB, (byte)remainingLight, (byte)action) == 0) { DelcomLightWrapper.CurrentLEDStates[remainingLight] = action; } else { lightsFailed.Add(remainingLight); } } if (lightsFailed.Count == 0) { success = true; break; } lightsRemaining = lightsFailed; System.Threading.Thread.Sleep(LEDWaitTime); } } } return(success); }
public NEEOLight(bool multiple, string[] device, string[] keys, string[] names) { _state = _initialState = new LightStates(); _multiple = multiple; for (int i = 0; i < keys.Length; i++) { string compName = keys[i].Replace(' ', '_'); _state.Add(compName, new LightState { Device = device[i], Key = keys[i], Name = names[i] }); } }
/// <summary> /// обработчик события изменения сигнала светофора /// </summary> /// <param name="LightState">новое состояние светофора</param> public void EventHandlerLightToggle(LightStates LightState) { //тут рисуем цвет светофора if (LightState == LightStates.Green) { PaintCell(Pictures.lightGreen, Envirmnt.Inst.CellMap[15][29]); } else if (LightState == LightStates.Red) { PaintCell(Pictures.lightRed, Envirmnt.Inst.CellMap[15][29]); } }
public void GoToLevelsFromLoseScreen() { gameOverCanvas.enabled = false; LevelsCanvas.enabled = true; LevelsCanvas.gameObject.transform.Find("Grid").gameObject.SetActive(true); RingHandler.GetComponent <RingHandler>().DelateAllRings(); //ResetLanterns(); light.GetComponent <Lighthandler>().ResetState("Reset"); LightState = LightStates.white; gameState = GameStates.levels; }
public void Off() { Console.WriteLine("Turning off All Lights"); LightState = LightStates.Off; foreach (var light in BlackLights) { light.isOn = false; } foreach (var light in WhiteLights) { light.isOn = false; } }
/// <summary> /// 灯循环方式 /// </summary> /// <param name="lightStates"></param> public void CycleTypeOnClick(LightStates lightStates) { switch (lightStates.cycleType) { case CycleType.stop: LightControl.Instance.Send(lightStates.light_port, lightStates.light_file, LigntType.OneStop); break; case CycleType.one: LightControl.Instance.Send(lightStates.light_port, lightStates.light_file, LigntType.OneCycle); break; } }
/// <summary> /// 灯播放 /// </summary> /// <param name="lightStates"></param> /// <returns></returns> public IEnumerator Play0nClick(LightStates lightStates) { CycleTypeOnClick(lightStates); yield return(new WaitForSeconds(0.2f)); if (lightStates.light_file == "000") { LightControl.Instance.Send(lightStates.light_port, lightStates.light_file, LigntType.Stop); } else { LightControl.Instance.Send(lightStates.light_port, lightStates.light_file, LigntType.Play); } }
/// <summary> /// Update the traffic light FSM. /// </summary> /// <param name="deltaTime">Time since the last update</param> /// <returns></returns> public IntersectionFlowState Update(float deltaTime) { // Update counter counter += deltaTime; if (currentLightState == LightStates.WAIT_FOR_EMPTY) { // Wait for the intersection to be empty before moving to next state if (ActiveLanesEmpty()) { return(nextIntersectionFlowState); } } else { // Check counter and transition to waiting for an empty intersection if // time's up if (counter > greenLightTime) { currentLightState = LightStates.WAIT_FOR_EMPTY; } } return(currentIntersectionFlowState); }
public void LowerDoor() { // This method will make the door go down if it is up and will check for an obstruction before going down; if (_doorState == DoorStates.Obstructed) { _doorState = DoorStates.Up; return; } if (_doorState == DoorStates.Down) { return; } if (_doorState == DoorStates.GoingDown) { _doorState = DoorStates.Down; _lightState = LightStates.Off; return; } _doorState = DoorStates.GoingDown; }
/// <summary> /// On Enter traffic light state. Reset the counter to zero and light to green /// </summary> public void OnEnter() { counter = 0; currentLightState = LightStates.GO; }
public override void OnFixedUpdate() { #if DEBUG if (!initOccurred) { Utils.log("OnFixedUpdate() called before OnStart() - wtf even?"); initEngineLights(); return; // I guess this might happen for a frame or two while a scene is still loading? should be harmless - we can wait } #endif try { // these _really_ shouldn't be happening - if one does we need to fix it, not ignore it. // the performance hit from throwing exceptions should encourage that. if (this.engineLightObject == null) { throw new Exception("Light Transform Object failed to initialise correctly"); } if (this.engineLight == null) { throw new Exception("Light failed to initialise correctly"); } if (this.engineModule == null) { throw new Exception("EngineModule failed to initialise correctly"); } ivaEnabled = Utils.isIVA(); if (MapView.MapIsEnabled || (ivaEnabled && multiplierOnIva < 0.1f) || engineLight.intensity < 0.1) { engineLight.enabled = false; } else { engineLight.enabled = true; } throttle = engineModule.getThrottle(); // cache this - don't trust KSPs properties lightOffset.y = 0; // reset the light offset // smooth the drop-off in intensity from sudden throttle decreases // the exhaust is still somewhat present, and that's what's supposed to be emitting the light if (lastFrameThrottle > 0 && (lastFrameThrottle - throttle / lastFrameThrottle) > (1 - lightFadeCoefficient)) { throttle = lastFrameThrottle * lightFadeCoefficient; } // d'awww, it's a wee finite state machine! lightState = LightStates.Disabled; if (throttle > 0) { lightState = lightState | LightStates.Exhaust; } if (enableEmissiveLight) { emissiveValue = engineModule.getEmissive(); // cache this if (emissiveValue > 0.1f) // don't glow when the emissive is too dull { lightState = lightState | LightStates.Emissive; } } switch (lightState) { case LightStates.Exhaust: engineLight.color = exhaustColor; // when restarting an engine setIntensityFromExhaust(); lightOffset.y -= exhaustOffsetZ; if (ivaEnabled) { engineLight.intensity *= multiplierOnIva; } break; case LightStates.Emissive: // emissive-only light needs these reset engineLight.intensity = 0; engineLight.range = minimumLightRange; lightOffset.y -= emissiveOffsetZ; if (!ivaEnabled) // can't see emissive from inside { setIntensityFromEmissive(); } break; case LightStates.Both: setIntensityFromExhaust(); setIntensityFromEmissive(); lightOffset.y -= emissiveOffsetZ; // move the light towards the exhaust plume (proportionally) as exhaust light dominates lightOffset.y -= (((engineLight.intensity - emissiveIntensity) / engineLight.intensity) * (exhaustOffsetZ - emissiveOffsetZ)); if (ivaEnabled) { engineLight.intensity *= multiplierOnIva; } break; case LightStates.Disabled: engineLight.enabled = false; break; } engineLightObject.transform.localPosition = lightOffset; #if DEBUG if (lastReportTime < Time.time) { if (engineModule.isEnabled) { Utils.log("part: " + part.name); Utils.log("fade rate: " + lightFadeCoefficient); Utils.log("lightstate: " + lightState); Utils.log("throttle: " + throttle); Utils.log("jittered throttle: " + jitteredThrottle); Utils.log("previous throttle: " + lastFrameThrottle); Utils.log("intensity: " + engineLight.intensity); Utils.log("color: " + engineLight.color); Utils.log("range: " + engineLight.range); if (enableEmissiveLight) { Utils.log("emissive: " + emissiveValue); Utils.log("emissive intensity: " + emissiveIntensity); } Utils.log("coords of engine: " + engineModule.transform.position); Utils.log("coords of thrust: " + averageThrustTransform); //Utils.log("coords of thrust offset: " + thrustOffset); Utils.log("coords of light: " + engineLightObject.transform.position); Utils.log(""); } lastReportTime = Time.time + 1; } #endif lastFrameThrottle = throttle; } catch (Exception exception) { Utils.log("Error in OnFixedUpdate(): " + exception.Message); } }
/// <summary> /// On Exit traffic light state. Reset light to green /// </summary> public void OnExit() { currentLightState = LightStates.GO; }