public static Task <bool> InsertNotificationAsync( GattCharacteristic characteristic, UserNotification userNotification, ApplicationPreference application) { if (userNotification?.AppInfo == null) { return(Task.FromResult(false)); } if (application != null && application.Muted) { return(Task.FromResult(true)); } var xmlNotification = AsteroidHelper.CreateInsertNotificationCommandXml( packageName: userNotification.AppInfo.PackageFamilyName, id: userNotification.Id.ToString(), applicationName: userNotification.AppInfo.DisplayInfo.DisplayName, applicationIcon: (application?.Icon ?? default(ApplicationIcon)).GetId(), summary: userNotification.GetTitle(), body: userNotification.GetBody(), vibrationLevel: application?.Vibration ?? VibrationLevel.None); if (string.IsNullOrWhiteSpace(xmlNotification)) { return(Task.FromResult(false)); } return(characteristic.WriteByteArrayToCharacteristicAsync(Encoding.UTF8.GetBytes(xmlNotification))); }
public async Task <List <Asteroid> > GetAsteroids(string startDate, string endDate) { HttpResponseMessage httpResponseMessage = await this.client.GetAsync(baseUrl + $"neo/rest/v1/feed?start_date={startDate}&end_date={endDate}&api_key={apiKey}"); List <Asteroid> asteroids = new List <Asteroid>(); if (httpResponseMessage.IsSuccessStatusCode) { var responseMessageContent = await httpResponseMessage.Content.ReadAsStringAsync(); var data = (JObject)JsonConvert.DeserializeObject(responseMessageContent); var nearEarthObjectsData = data["near_earth_objects"]; foreach (var child in nearEarthObjectsData.Children()) { List <JToken> jArray = child.Values().ToList(); foreach (var jToken in jArray) { Asteroid asteroidObject = JsonConvert.DeserializeObject <Asteroid>(jToken.ToString()); AsteroidHelper.GetDiameter(asteroidObject, jToken); AsteroidHelper.GetVelocity(asteroidObject, jToken); asteroids.Add(asteroidObject); } } } return(asteroids); }
public static async Task <bool> RemoveNotificationAsync(string notificationId) { var xmlNotification = AsteroidHelper.CreateRemoveNotificationCommandXml(notificationId); var characteristic = await BluetoothDevice.GetGattCharacteristicAsync(Asteroid.NotificationUpdateCharacteristicUuid); return(await characteristic.WriteByteArrayToCharacteristicAsync(Encoding.UTF8.GetBytes(xmlNotification))); }
public void Start() { //add teleportable behaviour _tb = new TeleportableBehaviour(transform, imageWidth, imageHeight); _eb = gameObject.AddComponent <ExplodableBehaviour>(); _eb.Transform = transform; _eb.Bounty = AsteroidHelper.GetBounty(stage); //add random forces Vector2 velocity = new Vector2(Random.Range(minVelocity, maxVelocity) * SceneHelper.GetRandomMultiplier(), Random.Range(minVelocity, maxVelocity) * SceneHelper.GetRandomMultiplier()); float torque = Random.Range(-maxTorque, maxTorque); rb.AddForce(velocity); rb.AddTorque(torque); //link to the particles _explosion = ResourcesLoader.GetExplosion(); }