// Use this for initialization void Start() { Player p = new Player(); p.timerManager = tmanager; Data = new BridgeData(p); bmanager = new BuffManager(Data); var b = new Protection(bmanager, 10); b.AddEffect(); b = new Protection(bmanager, 5); b.AddEffect(); It1 t1 = p as It1; p.Reset(); It2 t2 = p as It2; p.Reset(); AtlasManager.Cache(new string[] { "test", "dd" }); InvokeRepeating("t", 0, 1); // Invoke("tt",5); }
public AgentConfig(VehicleData vehicleData) // TODO refactor this { Name = vehicleData.Name; Connection = vehicleData.Bridge != null ? vehicleData.Bridge.ConnectionString : ""; AssetGuid = vehicleData.AssetGuid; #if UNITY_EDITOR if (vehicleData.Id.EndsWith(".prefab")) { AssetBundle = vehicleData.Id; AssetGuid = vehicleData.Id; } else #endif { AssetBundle = Web.WebUtilities.GenerateLocalPath(vehicleData.AssetGuid, BundleConfig.BundleTypes.Vehicle); } Sensors = vehicleData.Sensors; BridgeData = vehicleData.Bridge; //Load sensors from the configuration if no sensors are set if ((Sensors == null || Sensors.Length == 0) && vehicleData.SensorsConfigurations != null && vehicleData.SensorsConfigurations.Length > 0) { Sensors = vehicleData.SensorsConfigurations[0].Sensors; } }
public static WorldObjectData GetData(string name) { WorldObjectData data = null; switch (name) { case "Person": data = new PersonData(); break; case "Castle": data = new CastleData(); break; case "Tree": data = new TreeData(); break; case "Rock": data = new RockData(); break; case "Trap": data = new TrapData(); break; case "FakeTree": data = new FakeTreeData(); break; case "Cottage": data = new CottageData(); break; case "Candle": data = new CandleData(); break; case "Water": data = new WaterData(); break; case "Bridge": data = new BridgeData(); break; default: break; } return(data); }
void SocketReadThread() { Debug.Log("Read Thread Started"); while (runThread) { if (tcpClient.Connected) { string json = sr.ReadLine(); bool formattingSucceeded = false; if (!formattingSucceeded) { try { TraficLightData jsonObject = JsonUtility.FromJson <TraficLightData>(json); if (jsonObject != null) { // Debug.Log(json); try { foreach (LightInfo info in jsonObject.trafficLights) { try { //Debug.Log(info.id); //Debug.Log(info.lightStatus); if (info.id == "1.1") //testing { stop11 = info.lightStatus; } if (info.id == "1.2") //testing { stop12 = info.lightStatus; } if (info.id == "1.3") //testing { stop13 = info.lightStatus; } if (info.id == "1.4") //testing { stop14 = info.lightStatus; } if (info.id == "1.5") //testing { stop15 = info.lightStatus; } if (info.id == "1.6") //testing { stop16 = info.lightStatus; } if (info.id == "1.7") //testing { stop17 = info.lightStatus; } if (info.id == "1.8") //testing { stop18 = info.lightStatus; } if (info.id == "1.9") //testing { stop19 = info.lightStatus; } if (info.id == "1.10") //testing { stop110 = info.lightStatus; } if (info.id == "1.11") //testing { stop111 = info.lightStatus; } if (info.id == "1.12") //testing { stop112 = info.lightStatus; } if (info.id == "1.13") //testing { stop113 = info.lightStatus; } if (info.id == "2.1") //testing { stopB1 = info.lightStatus; } if (info.id == "2.2") //testing { stopB2 = info.lightStatus; } if (info.id == "2.3") //testing { stopB3 = info.lightStatus; } if (info.id == "2.4") //testing { stopB4 = info.lightStatus; } if (info.id == "4.1") //testing { stopBo1 = info.lightStatus; } if (info.id == "4.2") //testing { stopBo2 = info.lightStatus; } } catch { } } formattingSucceeded = true; } catch { } } } catch { } } if (!formattingSucceeded) { try { BridgeData bridgeData = JsonUtility.FromJson <BridgeData>(json); if (bridgeData != null && brugmoetopen != bridgeData.bridgeOpen) { brugmoetopen = bridgeData.bridgeOpen; } formattingSucceeded = true; } catch { } } } else { lock (clientMutex) { if (DateTime.Now > lastReconnectAttempt.AddSeconds(5)) { Debug.Log("Reconnecting"); Connect(); } } } } }
List <Buff> m_findedTmp = new List <Buff>();//用于查询优化 public BuffManager(BridgeData bData) { m_bridgeData = bData; m_bridgeData.Reset(); }
public IActionResult Action(string action, string value = "") { var message = "Unrecognized action"; var store = DreamData.GetStore(); Console.WriteLine($@"{action} fired."); if (action == "connectDreamScreen") { List <BaseDevice> dev; using (var ds = new DreamClient()) { dev = ds.FindDevices().Result; } store.Dispose(); return(new JsonResult(dev)); } if (action == "authorizeHue") { var doAuth = true; var bridges = store.GetItem <List <BridgeData> >("bridges"); BridgeData bd = null; var bridgeInt = -1; if (!string.IsNullOrEmpty(value)) { var bCount = 0; foreach (var b in bridges) { if (b.Ip == value) { bd = b; bridgeInt = bCount; doAuth = b.Key == null || b.User == null; } bCount++; } } if (doAuth) { var appKey = HueBridge.CheckAuth(value).Result; if (appKey != null && bd != null) { message = "Success: Bridge Linked."; bd.Key = appKey.StreamingClientKey; bd.User = appKey.Username; bridges[bridgeInt] = bd; store.ReplaceItem("bridges", bridges, true); } else { message = "Error: Press the link button"; } } else { message = "Success: Bridge Already Linked."; } } else if (action == "findHue") { var bridges = HueBridge.FindBridges(3); if (bridges != null) { store.ReplaceItem("bridges", bridges, true); } else { message = "Error: No bridge found."; } } Console.WriteLine(message); store.Dispose(); return(new JsonResult(message)); }
public IActionResult Action(string action, string value = "") { var message = "Unrecognized action"; LogUtil.Write($@"{action} called from Web API."); switch (action) { case "loadData": NotifyClients(); return(Content(DataUtil.GetStoreSerialized(), "application/json")); case "refreshDevices": // Just trigger dreamclient to refresh devices TriggerRefresh(); return(new JsonResult("OK")); case "authorizeHue": { LogUtil.Write("AuthHue called, for real."); var doAuth = true; BridgeData bd = null; if (!string.IsNullOrEmpty(value)) { _hubContext?.Clients.All.SendAsync("hueAuth", "start"); bd = DataUtil.GetCollectionItem <BridgeData>("Dev_Hue", value); LogUtil.Write("BD: " + JsonConvert.SerializeObject(bd)); if (bd == null) { LogUtil.Write("Null bridge retrieved."); return(new JsonResult(null)); } if (bd.Key != null && bd.User != null) { LogUtil.Write("Bridge is already authorized."); doAuth = false; } } else { LogUtil.Write("Null value.", "WARN"); doAuth = false; } if (!doAuth) { LogUtil.Write("No auth, returning existing data."); return(new JsonResult(bd)); } LogUtil.Write("Trying to retrieve appkey..."); var appKey = HueDiscovery.CheckAuth(bd.IpAddress).Result; if (appKey == null) { LogUtil.Write("Error retrieving app key."); return(new JsonResult(bd)); } bd.Key = appKey.StreamingClientKey; bd.User = appKey.Username; LogUtil.Write("We should be authorized, returning."); DataUtil.InsertCollection <BridgeData>("Dev_Hue", bd); return(new JsonResult(bd)); } case "authorizeNano": { var doAuth = true; var leaves = DataUtil.GetCollection <NanoData>("Dev_NanoLeaf"); NanoData bd = null; var nanoInt = -1; if (!string.IsNullOrEmpty(value)) { var nanoCount = 0; foreach (var n in leaves) { if (n.IpAddress == value) { bd = n; doAuth = n.Token == null; nanoInt = nanoCount; } nanoCount++; } } if (doAuth) { var panel = new NanoGroup(value); var appKey = panel.CheckAuth().Result; if (appKey != null && bd != null) { bd.Token = appKey.Token; bd.RefreshLeaf(); LogUtil.Write("Leaf refreshed and set..."); } panel.Dispose(); } LogUtil.Write("Returning."); return(new JsonResult(bd)); } } LogUtil.Write(message); return(new JsonResult(message)); }