Ejemplo n.º 1
0
        public async Task Setup()
        {
            string ip = await GetBridgeIp();

            hueClient = new LocalHueClient(ip, Secrets.HueUsername);

            var lights = await hueClient.GetLightsAsync();

            foreach (var light in lights)
            {
                lightToId.Add(light.Name, light.Id);
                Lights.Add(light.Name);
            }

            var groups = await hueClient.GetGroupsAsync();

            foreach (var group in groups)
            {
                var name = group.Name;
                if (name.Contains("Group for"))
                {
                    continue;
                }
                if (Lights.Contains(name))
                {
                    name = $"{name} (group)";
                }
                groupToId.Add(name, group.Id);
                Lights.Add(name);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Removes a light
 /// </summary>
 /// <param name="light">Handle</param>
 public void RemoveLight(Light light)
 {
     if (Lights.Contains(light))
     {
         Lights.Remove(light);
     }
 }
Ejemplo n.º 3
0
        public void UpdateDebugInput(Matrix worldMatrix, Keys toggleKey = Keys.L)
        {
            //if (!Input.GameIsActive) return;

            //if (Input.KeyPressed(toggleKey))
            //    EnableDebugLight = !EnableDebugLight;

            if (EnableDebugLight)
            {
                if (debugLight == null)
                {
                    debugLight = new Light2D();
                }

                if (!Lights.Contains(debugLight))
                {
                    Lights.Add(debugLight);
                }

                debugLight.Position = Q19.Q19Game.Instance.MousePosition;// Vector2.Transform(Game.Frames.Main.TransformScreenToViewport(Input.MousePos), Matrix.Invert(worldMatrix));  //TODO: Should use the current frame
            }
            else
            {
                if (Lights.Contains(debugLight))
                {
                    Lights.Remove(debugLight);
                }
                return;
            }

            //Ward.Watch("Lighting2D.lights", Lights.Count);
            //Ward.Watch("Lighting2D.objs", VertexObjs.Count);
            //Ward.Watch("Lighting2D.debuglight", debugLight.ToString());

            //var scrollDelta = Input.States.MouseScrollDelta;
            //if (scrollDelta != 0)
            //{
            //var hsl = new Color(debugLight.Color);
            //hsl.SetBrightness(0.5f);
            //if (Input.KeyDown(Keys.LeftAlt))
            //    hsl.SetSaturation(hsl.GetSaturation() + scrollDelta * 0.025f);
            //else if (Input.KeyDown(Keys.LeftShift))
            //    hsl.SetHue(hsl.GetHue() + scrollDelta * 0.025f);
            //else if (Input.KeyDown(Keys.LeftControl))
            //    debugLight.Falloff = debugLight.Falloff * (1 + scrollDelta * 0.1f);
            //else if (Input.KeyDown(Keys.Z))
            //    debugLight.AngleOuter += scrollDelta * 2f;
            //else if (Input.KeyDown(Keys.X))
            //    debugLight.AngleInner += scrollDelta * 2f;
            //else if (Input.KeyDown(Keys.C))
            //    debugLight.Direction += scrollDelta * 0.05f;
            //else
            //    debugLight.Size = debugLight.Size * (1 + scrollDelta * 0.1f);

            //    debugLight.Color = hsl.ToVector4();
            //}

            //if (Input.KeyPressed(Keys.K))
            //{
            //    if (Input.KeyPressed(Keys.D1)) debugLight.Type = Light2D.LightType.Omni;
            //    if (Input.KeyPressed(Keys.D2)) debugLight.Type = Light2D.LightType.Cone;
            //    if (Input.KeyPressed(Keys.D3)) debugLight.Type = Light2D.LightType.Directional;
            //}

            //if (Input.KeyPressed(MouseKeys.Left))
            //    Lights.Insert(0, debugLight.Clone());
            //if (lights.Count > 0)
            //    lights[0].Position = (Point2)Input.MousePos;
        }