public bool TurnOffLight(LightColour colour)
 {
     var modifiedColour = (short)colour * 0x100;
     var packet = new UsbSetupPacket(0x48, 0x12, (short)0x0c0a, (short)modifiedColour, (short)0x0000);
     int temp2;
     return MyUsbDevice.ControlTransfer(ref packet, new byte[0], 0, out temp2);
 }
 public void BlinkThenRevert(LightColour colour, int blinkInterval = 100)
 {
     var oldColour = CurrentColour;
     TurnOffLights();
     Thread.Sleep(blinkInterval);
     ChangeColor(colour);
     Thread.Sleep(blinkInterval);
     ChangeColor(oldColour);
 }
Exemple #3
0
        public void BlinkThenRevert(LightColour colour, int blinkInterval = 100)
        {
            var oldColour = CurrentColour;

            TurnOffLights();
            Thread.Sleep(blinkInterval);
            ChangeColor(colour);
            Thread.Sleep(blinkInterval);
            ChangeColor(oldColour);
        }
        public override string GetStepParameters()
        {
            var parameters = new List <string>();

            parameters.Add(Name != null ? Name.ToStepValue() : "$");
            parameters.Add(LightColour != null ? LightColour.ToStepValue() : "$");
            parameters.Add(AmbientIntensity != null ? AmbientIntensity.ToStepValue() : "$");
            parameters.Add(Intensity != null ? Intensity.ToStepValue() : "$");

            return(string.Join(", ", parameters.ToArray()));
        }
        public override string GetStepParameters()
        {
            var parameters = new List <string>();

            parameters.Add(Name != null ? Name.ToStepValue() : "$");
            parameters.Add(LightColour != null ? LightColour.ToStepValue() : "$");
            parameters.Add(AmbientIntensity != null ? AmbientIntensity.ToStepValue() : "$");
            parameters.Add(Intensity != null ? Intensity.ToStepValue() : "$");
            parameters.Add(Position != null ? Position.ToStepValue() : "$");
            parameters.Add(Radius != null ? Radius.ToStepValue() : "$");
            parameters.Add(ConstantAttenuation != null ? ConstantAttenuation.ToStepValue() : "$");
            parameters.Add(DistanceAttenuation != null ? DistanceAttenuation.ToStepValue() : "$");
            parameters.Add(QuadricAttenuation != null ? QuadricAttenuation.ToStepValue() : "$");

            return(string.Join(", ", parameters.ToArray()));
        }
Exemple #6
0
        public override string GetStepParameters()
        {
            var parameters = new List <string>();

            parameters.Add(Name != null ? Name.ToStepValue() : "$");
            parameters.Add(LightColour != null ? LightColour.ToStepValue() : "$");
            parameters.Add(AmbientIntensity != null ? AmbientIntensity.ToStepValue() : "$");
            parameters.Add(Intensity != null ? Intensity.ToStepValue() : "$");
            parameters.Add(Position != null ? Position.ToStepValue() : "$");
            parameters.Add(ColourAppearance != null ? ColourAppearance.ToStepValue() : "$");
            parameters.Add(ColourTemperature != null ? ColourTemperature.ToStepValue() : "$");
            parameters.Add(LuminousFlux != null ? LuminousFlux.ToStepValue() : "$");
            parameters.Add(LightEmissionSource.ToStepValue());
            parameters.Add(LightDistributionDataSource != null ? LightDistributionDataSource.ToStepValue() : "$");

            return(string.Join(", ", parameters.ToArray()));
        }
Exemple #7
0
        protected override void ChangeColor(LightColour colour)
        {
            lock (_lockObject)
            {
                switch (colour)
                {
                case LightColour.Red:
                    CurrentColour = LightColour.Red;
                    SetColour("FF0D00");
                    break;

                case LightColour.Green:
                    CurrentColour = LightColour.Green;
                    SetColour("00FF00");
                    break;

                case LightColour.Blue:
                    CurrentColour = LightColour.Blue;
                    SetColour("0000FF");
                    break;

                case LightColour.Yellow:
                    CurrentColour = LightColour.Yellow;
                    SetColour("FFFF00");
                    break;

                case LightColour.White:
                    CurrentColour = LightColour.White;
                    SetColour("FFFFFF");
                    break;

                case LightColour.Purple:
                    CurrentColour = LightColour.Purple;
                    SetColour("8400FF");
                    break;

                case LightColour.Off:
                    CurrentColour = LightColour.Off;
                    var command = new LightCommand();
                    command.TurnOff();
                    command.Effect = Effect.None;
                    _hueClient.SendCommandAsync(command, _lights);
                    break;
                }
            }
        }
Exemple #8
0
        protected override void ChangeColor(LightColour colour)
        {
            {
                lock (_lockObject)
                {
                    switch (colour)
                    {
                    case LightColour.Red:
                        CurrentColour = LightColour.Red;
                        SetRGB(true, false, false);
                        break;

                    case LightColour.Green:
                        CurrentColour = LightColour.Green;
                        SetRGB(false, true, false);
                        break;

                    case LightColour.Blue:
                        CurrentColour = LightColour.Blue;
                        SetRGB(false, false, true);
                        break;

                    case LightColour.Yellow:
                        CurrentColour = LightColour.Yellow;
                        SetRGB(false, true, true);
                        break;

                    case LightColour.White:
                        CurrentColour = LightColour.White;
                        SetRGB(true, true, true);
                        break;

                    case LightColour.Purple:
                        CurrentColour = LightColour.Purple;
                        SetRGB(true, false, true);
                        break;

                    case LightColour.Off:
                        CurrentColour = LightColour.Off;
                        SetRGB(false, false, false);
                        break;
                    }
                }
            }
        }
Exemple #9
0
 /// <summary>
 /// Sets the current colour of the traffic light.
 /// </summary>
 /// <param name="lightColour">The traffic light colour as an enum.</param>
 public void SetColour(LightColour lightColour)
 {
     currentLightColour = lightColour;
     foreach (KeyValuePair <LightColour, GameObject> lightObjectEntry in lightObjects)
     {
         if (lightColour == lightObjectEntry.Key)
         {
             ChangeMaterial(lightObjectEntry.Value, lightMaterials[lightObjectEntry.Key]);
         }
         else
         {
             ChangeMaterial(lightObjectEntry.Value, blackMaterial);
         }
     }
     if (trafficLightChangeEvent != null)
     {
         trafficLightChangeEvent.Invoke(this, new TrafficLightChangeEventArgs(this, currentLightColour));
     }
 }
Exemple #10
0
        public override void EditorRender()
        {
            base.EditorRender();

            if (Selected)
            {
                SpriteRenderer.DrawRect(
                    ScreenX - (float)Width * MapRenderer.CameraScale * 8.0f,
                    ScreenY - (float)Height * MapRenderer.CameraScale * 8.0f,
                    (float)Width * MapRenderer.CameraScale * 16.0f,
                    (float)Height * MapRenderer.CameraScale * 16.0f,
                    new Color4(0, 255, 0, 63));
            }

            mySprite.X      = ScreenX;
            mySprite.Y      = ScreenY;
            mySprite.Colour = LightColour.ToColor4();

            mySprite.Render();
        }
Exemple #11
0
 protected override void ChangeColor(LightColour colour)
 {
     lock (_lockObject)
     {
         switch (colour)
         {
             case LightColour.Red:
                 CurrentColour = LightColour.Red;
                 SetColour("FF0D00");
                 break;
             case LightColour.Green:
                 CurrentColour = LightColour.Green;
                 SetColour("00FF00");
                 break;
             case LightColour.Blue:
                 CurrentColour = LightColour.Blue;
                 SetColour("0000FF");
                 break;
             case LightColour.Yellow:
                 CurrentColour = LightColour.Yellow;
                 SetColour("FFFF00");
                 break;
             case LightColour.White:
                 CurrentColour = LightColour.White;
                 SetColour("FFFFFF");
                 break;
             case LightColour.Purple:
                 CurrentColour = LightColour.Purple;
                 SetColour("8400FF");
                 break;
             case LightColour.Off:
                 CurrentColour = LightColour.Off;
                 var command = new LightCommand();
                 command.TurnOff();
                 command.Effect = Effect.None;
                 _hueClient.SendCommandAsync(command, _lights);
                 break;
         }
     }
 }
 protected override void ChangeColor(LightColour colour)
 {
     {
         lock (_lockObject)
         {
             switch (colour)
             {
                 case LightColour.Red:
                     CurrentColour = LightColour.Red;
                     SetRGB(true, false, false);
                     break;
                 case LightColour.Green:
                     CurrentColour = LightColour.Green;
                     SetRGB(false, true, false);
                     break;
                 case LightColour.Blue:
                     CurrentColour = LightColour.Blue;
                     SetRGB(false, false, true);
                     break;
                 case LightColour.Yellow:
                     CurrentColour = LightColour.Yellow;
                     SetRGB(false, true, true);
                     break;
                 case LightColour.White:
                     CurrentColour = LightColour.White;
                     SetRGB(true, true, true);
                     break;
                 case LightColour.Purple:
                     CurrentColour = LightColour.Purple;
                     SetRGB(true, false, true);
                     break;
                 case LightColour.Off:
                     CurrentColour = LightColour.Off;
                     SetRGB(false, false, false);
                     break;
             }
         }
     }
 }
Exemple #13
0
        private void UpdateSkin(bool updateLight = true)
        {
            if (stTextures != null)
            {
                mySprite = new AnimatedSprite(stTextures[mySkinID], 16, 16, 8.0, MapRenderer.CameraScale)
                {
                    UseCentreAsOrigin = true
                }
            }
            ;

            if (updateLight)
            {
                if (mySkinID < 2)
                {
                    LightColour = new LightColour(0.75f, 0.5f, 0.25f);
                }
                else
                {
                    LightColour = new LightColour(0.67f, 0.93f, 1.0f);
                }
                Range = 4.0;
            }
        }
Exemple #14
0
 protected abstract void ChangeColor(LightColour colour);
 /// <summary>
 /// Randomly sets a new light colour
 /// </summary>
 private void RandomiseLight()
 {
     m_lightColour = (LightColour)Random.Range(0, 3);
 }
Exemple #16
0
 protected abstract void ChangeColor(LightColour colour);
Exemple #17
0
 private static void ChangeColour(IUSBController controller, byte[] controlBytes, LightColour colour)
 {
     controlBytes[2] = (byte)colour;
     controller.HidSetFeature(controlBytes);
 }
Exemple #18
0
        public Light()
        {
            LightColour = new LightColour(1.0f, 1.0f, 1.0f);

            SetBoundingBox(12.0 / 16.0, 16.0 / 16.0);
        }
Exemple #19
0
 public TrafficLightChangeEventArgs(TrafficLight trafficLight, LightColour lightColour)
 {
     this.trafficLight = trafficLight;
     this.lightColour  = lightColour;
 }
Exemple #20
0
 public Light(System.IO.BinaryReader reader, bool sentFromServer)
     : base(reader, sentFromServer)
 {
     LightColour = new LightColour(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
     myRange     = reader.ReadDouble();
 }
 public Light(LightColour colour)
 {
     this.colour = colour;
 }
 public Stage(LightColour colour, int time) : this()
 {
     this.lights.Add(new Light(colour));
     this.time = time;
 }
Exemple #23
0
 private static void ChangeColour(IUSBController controller, byte[] controlBytes, LightColour colour)
 {
     controlBytes[2] = (byte)colour;
     controller.HidSetFeature(controlBytes);
 }
Exemple #24
0
 /// <summary>
 /// Checks to see if the inputted light colour is the current light colour.
 /// </summary>
 /// <param name="lightColour">The light colour to compare.</param>
 /// <returns>True if the inputted light colour is the current light colour.</returns>
 public bool IsCurrentLightColour(LightColour lightColour)
 {
     return(currentLightColour == lightColour);
 }