Beispiel #1
0
        public static void Flash(ILightState pState, Light light, Color pFlashColor, int flashRate)
        {
            List <Light> lights = new List <Light>();

            lights.Add(light);
            Flash(pState, lights, pFlashColor, flashRate);
        }
        public void ChangeState(ILightState state, int changesCount, ColourOption[] colours)
        {
            var actual = TrafficManager.Start(state, changesCount);

            int i = 0;

            foreach (var element in actual)
            {
                Assert.AreEqual(element, colours[i++]);
            }
        }
        /// <summary>
        /// Run cycle of change states for traffic light
        /// </summary>
        /// <param name="initState"> Initial state </param>
        /// <param name="shiftsNumber"> Number of changes states </param>
        /// <returns> Collection of colours </returns>
        /// <exception cref="ArgumentNullException"> If initState is null </exception>
        public static IEnumerable <ColourOption> Start(ILightState initState, int shiftsNumber)
        {
            var trafficLight = new TrafficLightState(initState);

            for (int i = 0; i < shiftsNumber; i++)
            {
                yield return(trafficLight.Colour);

                trafficLight.Change();
            }
        }
 public void TouchButton()
 {
     if (_current.IsLightOn)
     {
         _current = _offLight;
     }
     else
     {
         _current = _onLight;
     }
 }
Beispiel #5
0
 public static void Flash(ILightState pState,
     List<Light> pLightRange, Color pFlashColor, 
     int flashRate)
 {
     foreach (Light l in pLightRange)
     {
         l.Color = pFlashColor;
         pState.Update();
         Thread.Sleep(flashRate);
     }
 }
Beispiel #6
0
 public static void Flash(ILightState pState,
                          List <Light> pLightRange, Color pFlashColor,
                          int flashRate)
 {
     foreach (Light l in pLightRange)
     {
         l.Color = pFlashColor;
         pState.Update();
         Thread.Sleep(flashRate);
     }
 }
 public AmpSinePresenter(IAmpSineView pView, ILightState pState, LightGroup pGroup)
     : base(pView, pState)
 {
     mLightGroup = pGroup;
     Initialize(pView);
 }
 public LightModulePresenterBase(ILightState pLightState)
 {
     mLightState = pLightState;
 }
Beispiel #9
0
 public void SetState(ILightState s)
 {
     _lightState = s as LightState;
 }
Beispiel #10
0
 public Context(ILightState state)
 {
     this.state = state;
 }
 public LightSwitch(ILightState lightState)
 {
     this.lightState = lightState;
 }
Beispiel #12
0
 // Use this for initialization
 void Start()
 {
     rend         = GetComponent <Renderer>();
     currentState = redLight;
 }
Beispiel #13
0
 public static void Flash(ILightState pState, Light light, Color pFlashColor, int flashRate)
 {
     List<Light> lights = new List<Light>();
     lights.Add(light);
     Flash(pState, lights, pFlashColor, flashRate);
 }
Beispiel #14
0
 public void pressedFix()
 {
     this.state = state.Fix();
 }
Beispiel #15
0
 public LightControl(ILightState state)
 {
     State = state;
 }
Beispiel #16
0
 public LightGroup(List <LightViewPresenter> pLightViews, ILightState pState)
 {
     mLights = pLightViews;
     mState  = pState;
 }
Beispiel #17
0
 public void fixSwitch()
 {
     this.state = state.Fix();
 }
Beispiel #18
0
 public void PressedOn()
 {
     this.state = state.TurnOn();
 }
Beispiel #19
0
 /// <summary>
 /// Initialize TrafficLightState by initial state
 /// </summary>
 /// <param name="state"> State of traffic light </param>
 public TrafficLightState(ILightState state)
 {
     State = state;
 }
Beispiel #20
0
 public void Fix()
 {
     this.state = state.Fix();
 }
Beispiel #21
0
 public void Init(ILightState state)
 {
     this.State = state;
 }
 public void onPress()
 {
     this.lightState = this.lightState.toogleLight();
 }
Beispiel #23
0
 public LightModulePresenterBase(IModuleView pView, ILightState pLightState)
     : this(pLightState)
 {
     mModuleView = pView;
 }
Beispiel #24
0
 public void pressedOff()
 {
     this.state = state.TurnOff();
 }
Beispiel #25
0
 public LightGroup(List<LightViewPresenter> pLightViews, ILightState pState)
 {
     mLights = pLightViews;
     mState = pState;
 }
Beispiel #26
0
 public AmpSinePresenter(IAmpSineView pView, ILightState pState)
     : base(pView, pState)
 {
     Initialize(pView);
 }
Beispiel #27
0
 public AmpSinePresenter(IAmpSineView pView, ILightState pState, LightGroup pGroup)
     : base(pView, pState)
 {
     mLightGroup = pGroup;
     Initialize(pView);
 }
Beispiel #28
0
 public LightModulePresenterBase(ILightState pLightState)
 {
     mLightState = pLightState;
 }
 public AmpSinePresenter(IAmpSineView pView, ILightState pState)
     : base(pView, pState)
 {
     Initialize(pView);
 }
 public StateManager2()
 {
     _onLight  = new LightStateOn(this);
     _offLight = new LightStateOff(this);
     _current  = null;
 }
 public LightModulePresenterBase(IModuleView pView, ILightState pLightState)
     : this(pLightState)
 {
     mModuleView = pView;
 }