예제 #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++]);
            }
        }
예제 #3
0
        /// <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;
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #7
0
 public AmpSinePresenter(IAmpSineView pView, ILightState pState, LightGroup pGroup)
     : base(pView, pState)
 {
     mLightGroup = pGroup;
     Initialize(pView);
 }
 public LightModulePresenterBase(ILightState pLightState)
 {
     mLightState = pLightState;
 }
예제 #9
0
 public void SetState(ILightState s)
 {
     _lightState = s as LightState;
 }
예제 #10
0
 public Context(ILightState state)
 {
     this.state = state;
 }
 public LightSwitch(ILightState lightState)
 {
     this.lightState = lightState;
 }
예제 #12
0
 // Use this for initialization
 void Start()
 {
     rend         = GetComponent <Renderer>();
     currentState = redLight;
 }
예제 #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);
 }
예제 #14
0
파일: Context.cs 프로젝트: royms/State
 public void pressedFix()
 {
     this.state = state.Fix();
 }
예제 #15
0
 public LightControl(ILightState state)
 {
     State = state;
 }
예제 #16
0
 public LightGroup(List <LightViewPresenter> pLightViews, ILightState pState)
 {
     mLights = pLightViews;
     mState  = pState;
 }
예제 #17
0
 public void fixSwitch()
 {
     this.state = state.Fix();
 }
예제 #18
0
 public void PressedOn()
 {
     this.state = state.TurnOn();
 }
예제 #19
0
 /// <summary>
 /// Initialize TrafficLightState by initial state
 /// </summary>
 /// <param name="state"> State of traffic light </param>
 public TrafficLightState(ILightState state)
 {
     State = state;
 }
예제 #20
0
 public void Fix()
 {
     this.state = state.Fix();
 }
예제 #21
0
 public void Init(ILightState state)
 {
     this.State = state;
 }
 public void onPress()
 {
     this.lightState = this.lightState.toogleLight();
 }
예제 #23
0
 public LightModulePresenterBase(IModuleView pView, ILightState pLightState)
     : this(pLightState)
 {
     mModuleView = pView;
 }
예제 #24
0
 public void pressedOff()
 {
     this.state = state.TurnOff();
 }
예제 #25
0
 public LightGroup(List<LightViewPresenter> pLightViews, ILightState pState)
 {
     mLights = pLightViews;
     mState = pState;
 }
예제 #26
0
 public AmpSinePresenter(IAmpSineView pView, ILightState pState)
     : base(pView, pState)
 {
     Initialize(pView);
 }
예제 #27
0
 public AmpSinePresenter(IAmpSineView pView, ILightState pState, LightGroup pGroup)
     : base(pView, pState)
 {
     mLightGroup = pGroup;
     Initialize(pView);
 }
예제 #28
0
 public LightModulePresenterBase(ILightState pLightState)
 {
     mLightState = pLightState;
 }
예제 #29
0
 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;
 }