public bool Equals(Device other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(DeviceName.ToLower() == other.DeviceName.ToLower()); }
public void Shoot(SpheroWeaponType type, float direction) { //Get the ProjectileControl object associated with the shooting player String playerName = DeviceName.ToLower().Contains("boo") ? "player1" : "player2"; ProjectileControl playerProjectile = GameObject.Find(playerName).GetComponent <ProjectileControl>(); //Put the direction into the correct range direction += (float)Math.PI; //Covert the direction into a vector Vector3 directionVector = new Vector3((float)Math.Cos(direction), (float)Math.Sin(direction), 0.0f); //Tell the sphero to shoot playerProjectile.Shoot(directionVector); }
public bool IsPass(object data = null) { var eventData = (BluetoothEventDataStruct)data; if (string.IsNullOrEmpty(DeviceName)) { return(true); } if (Caseinsensitive) { DeviceName = DeviceName.ToLower(); eventData.DeviceName = eventData.DeviceName.ToLower(); } if (FuzzyMatch) { return(eventData.DeviceName.Contains(DeviceName)); } return(DeviceName == eventData.DeviceName); }
private async void OnSelectionChanged(object obj) { if (obj != null) { var wifi = (Wifi)obj; SelectedWifi = wifi; SelectedItem = wifi; if (wifi != null) { DeviceConnectStatus = "Connecting..."; OnPropertyChanged("DeviceConnectStatus"); await Task.Delay(500); SelectedItem.LabelTextColor = Color.FromHex("#EF4736"); SelectedItem.Image = "terra_spray_orange_device_03"; if (LastSelectedItem != null) { LastSelectedItem.LabelTextColor = Color.FromHex("#989da0"); LastSelectedItem.Image = "terra_spray_device_03"; } DeviceName = wifi.name; string pwd = string.Empty; foreach (var item in wifiPwdList) { if (DeviceName.ToLower().Contains(item.Key.ToLower())) { pwd = item.Value; break; } } await ConnectNetwork(wifi.ssid, pwd); } } else { SelectedItem = null; } LastSelectedItem = SelectedItem; }
/// <summary> /// Find a variable by a certain type and/or name /// It will only return the first found variable /// </summary> /// <param name="type">The declaration type</param> /// <param name="name">The name of the variable</param> /// <returns></returns> public string GetVariable(string type, string name = @"\w+") { // The variables called are typically stored in the [name].c file string content = null; Regex variable = new Regex(type + @"\s+" + name + @"(\[\])?\s+\=[^;]+;"); string filename = Path.Combine(Folder, DeviceName.ToLower() + ".c"); if (File.Exists(filename)) { using (StreamReader sr = new StreamReader(filename)) content = sr.ReadToEnd(); var m = variable.Match(content); if (m.Success) { return(ApplyDefined(m.Value)); } } // We can't find it by the file, try the other files in the folder... foreach (string f in Directory.GetFiles(Folder)) { // Already checked... if (f == filename) { continue; } // Read the file using (StreamReader sr = new StreamReader(f)) content = sr.ReadToEnd(); var m = variable.Match(content); if (m.Success) { return(ApplyDefined(m.Value)); } } throw new Exception($"Could not find variable '{type} {name}'"); }