private void Start() { maxSpeed = 2f; maxSpeedTraffic = TrafficSettings.orangeSpeed; trafficColor = GameObject.Find("Ground (Traffic)").GetComponent <TrafficColor> (); trafficColor.SetColorGreen(); }
public void GetStatusTest(WorkMode workMode, TrafficColor color, int x) { _trafficLight.SetWorkMode(workMode); _trafficLight.SetCurrentLight(color); _trafficLight.GetStatus().Should().Be($" Color={color};" + $" Work mode = {workMode}" + $" Battery = {_mock.Object.Energy}%."); }
/// <summary> /// Set current color . /// WorkMode must be "Hand". /// </summary> public void SetCurrentLight(TrafficColor color) { if (_workMode != WorkMode.Hand) { throw new Exception("Wrong mode!"); } _currentLight = color; }
public void Next_Color_Yellow_Test(TrafficColor color) { _trafficLight.SetWorkMode(WorkMode.Hand); _trafficLight.SetCurrentLight(color); _trafficLight.SetWorkMode(WorkMode.Normal); _trafficLight.NextColor(); _trafficLight.GetStatus().Should().Contain("Yellow"); }
public virtual void SetColor(TrafficColor color) { switch (color) { case TrafficColor.Red: break; case TrafficColor.Yellow: break; case TrafficColor.Green: break; } }
protected void updateStoplight(Object o, ElapsedEventArgs e) { //algorithm to determine the light that is switched on switch (Light) { case TrafficColor.red: if (tickcounter < 4) { tickcounter++; } else { tickcounter = 0; Light = TrafficColor.yellow; } Invalidate(); break; case TrafficColor.yellow: if (tickcounter < 2) { tickcounter++; } else { tickcounter = 0; Light = TrafficColor.green; } Invalidate(); break; case TrafficColor.green: if (tickcounter < 3) { tickcounter++; } else { tickcounter = 0; Light = TrafficColor.red; } Invalidate(); break; } } //end of updateStoplight
/// <summary> /// Change current color from order "Red-Yellow-Green Green-Yellow-Red". /// WorkMode must be "Normal". /// </summary> public void NextColor() { if (_workMode != WorkMode.Normal) { throw new Exception("Wrong mode!"); } var tempColor = _currentLight; switch (_currentLight) { case TrafficColor.Red: case TrafficColor.Green: _currentLight = TrafficColor.Yellow; break; case TrafficColor.Yellow: _currentLight = _previousLight == TrafficColor.Green ? TrafficColor.Red : TrafficColor.Green; break; } _previousLight = tempColor; }
}//END private void ShowMessage(object sender, EventArgs e) protected void Signal(System.Object send, ElapsedEventArgs e) { tickCounter++; switch (light) { case TrafficColor.red: { if (tickCounter > 4) { tickCounter = 0; light = TrafficColor.green; Invalidate(); } } break; case TrafficColor.yellow: { if (tickCounter > 1) { tickCounter = 0; light = TrafficColor.red; Invalidate(); } } break; case TrafficColor.green: { if (tickCounter > 3) { tickCounter = 0; light = TrafficColor.yellow; Invalidate(); } } break; } //END switch(light) } //END protected void Signal(Object send, ElapsedEvenArgs e)
private void DecreaseCounter() { if (this.counter == this.timer) { EventManager.TriggerEvent(this.gameObject, EventManager.FormateEventName(this.gameObject, TrafficColor.Type.Car.ToString(), this.color.ToString())); EventManager.TriggerEvent(this.gameObject, EventManager.FormateEventName(this.gameObject, TrafficColor.Type.Human.ToString(), TrafficColor.getOppisit(this.color).ToString())); if (this.color.Equals(TrafficColor.Color.Green)) { this.wall.enabled = false; } else if (this.color.Equals(TrafficColor.Color.Red)) { this.wall.enabled = true; } } if (this.counter > 0) { this.counter = this.counter - 1; } else { TrafficColor.Color temp = this.color; this.color = TrafficColor.getNext(this.color, this.oldColor); this.oldColor = temp; if (TrafficColor.Color.Yellow.Equals(this.color)) { this.counter = this.switchTimer; } else { this.counter = this.timer; } } }
public override void ChangeState() { switch (StateColor) { case TrafficColor.Green: case TrafficColor.Red: StateColor = TrafficColor.Yellow; break; case TrafficColor.Yellow: { StateColor = PreviewColor == TrafficColor.Red ? TrafficColor.Green : TrafficColor.Red; PreviewColor = StateColor; break; } case TrafficColor.None: On(); break; default: throw new ArgumentOutOfRangeException(nameof(StateColor)); } }
}//End of stoprun protected void Start(Object sender, EventArgs events) { light = TrafficColor.yellow; Tclock.Enabled = true; }//End of Start
public virtual void Off() { StateColor = TrafficColor.None; }
public virtual void On() { StateColor = TrafficColor.Green; }
// Update is called once per frame void Update() { this.animator.SetInteger("State", TrafficColor.getValue(this.color)); }
public virtual void SetColor(TrafficColor color) { throw new System.NotImplementedException(); }
private void SetDefault() { _currentLight = TrafficColor.Yellow; _previousLight = TrafficColor.Green; _workMode = WorkMode.Normal; }
// Update is called once per frame void Update() { this.animator.SetInteger("number", number); this.animator.SetInteger("color", TrafficColor.getValue(this.color)); }
public void SetCorrentLightTest(TrafficColor trafficColor) { _trafficLight.SetWorkMode(WorkMode.Hand); _trafficLight.SetCurrentLight(trafficColor); _trafficLight.GetStatus().Should().Contain(trafficColor.ToString()); }