本文整理汇总了C#中Light.Pushed方法的典型用法代码示例。如果您正苦于以下问题:C# Light.Pushed方法的具体用法?C# Light.Pushed怎么用?C# Light.Pushed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Light
的用法示例。
在下文中一共展示了Light.Pushed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateLight
HTTP.Request UpdateLight(Light l)
{
Color prevColor = l.LastColor();
float prevFade = l.LastFade();
if (!l.ShouldPush())
return null;
string apiCall = "/api/" + User + "/lights/" + l.id + "/state";
float fade = Mathf.Clamp01(l.fade);
HueHSBColor hsbColor = new HueHSBColor(l.color);
int transitionTime = (int)(l.transitionTime * 10.0f); //this is specified in hundreds of millisecs (i.e 10 = 1000 ms = 1s)
bool on = (l.on && (fade > 0.0f));
string body = "{\"on\": " + (on ? "true" : "false") +
" \"hue\": " + (int)(hsbColor.h * 65535.0f) +
" \"sat\": " + (int)(hsbColor.s * 255.0f) +
" \"bri\": " + (int)(hsbColor.b * fade * 255.0f) +
" \"transitiontime\": " + transitionTime +
//" \"effect\":\"colorloop\"" +
"}";
/* on = true;
string body = "{\"on\": " + (on ? "true" : "false") +
" \"effect\":\"colorloop\"" +
"}";*/
string url = "http://" + BridgeIP + apiCall;
//Debug.Log("URL: " + url + " body: " + body + " at Time: " + Time.time + " deltaSinceLastUpdate: " + l.TimeSinceLastUpdate() + "\n");
HTTP.Request request = new HTTP.Request("put", "http://" + BridgeIP + apiCall, JSON.JsonDecode(body) as Hashtable);
request.Send();
l.Pushed();
//notify anyone who cares
SendEvents(l, prevColor, prevFade);
return request;
}