public void ActivateHaptic() { VibrationEffect effect = VibrationEffect.CreateOneShot(100, VibrationEffect.DefaultAmplitude); Vibrator vibrator = (Vibrator)global::Android.App.Application.Context.GetSystemService(Context.VibratorService); vibrator.Vibrate(effect); }
public void ReceiveDetections(Detections detections) { if (this.ViewModel.State == RegisterDeviceViewModel.RegistrationState.New) { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { try { Vibrator vibrator = (Vibrator)GetSystemService(Context.VibratorService); vibrator.Vibrate(VibrationEffect.CreateOneShot(1000, 1)); } catch { } var value = ((Barcode)qrcodes.ValueAt(0)).RawValue; string networkSSID = value; if (!string.IsNullOrEmpty(networkSSID)) { Task.Run(async() => await this.ViewModel.ProvisionDevice(new Common.WiFi.WifiNetwork() { SSID = networkSSID })); } } } }
private void Vibrate() { Vibrator vibrator = (Vibrator)GetSystemService(VibratorService); long[] pattern = { 0, 400, 600, 800 }; vibrator.Vibrate(pattern, -1); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); _gestureDetector = new GestureDetector(this); SetContentView(Resource.Layout.Main); Button btn_next = FindViewById <Button>(Resource.Id.btn_next); Button btn_prev = FindViewById <Button>(Resource.Id.btn_previous); btn_next.Click += (object sender, EventArgs e) => { NextSlide(); }; btn_prev.Click += (object sender, EventArgs e) => { PrevSlide(); }; ImageView imageview = FindViewById <ImageView>(Resource.Id.imageView1); StatusTextView = FindViewById <TextView>(Resource.Id.status); client = new Client(this, imageview, StatusTextView); vibrator = (Vibrator)GetSystemService(VibratorService); BTAdapter = BluetoothAdapter.DefaultAdapter; // If BT is not on, request that it be enabled. if (!BTAdapter.IsEnabled) { Intent enableIntent = new Intent(BluetoothAdapter.ActionRequestEnable); StartActivityForResult(enableIntent, REQUEST_ENABLE_BT); } else { ShowDeviceList(); } }
public void timeSucccess() { casovac.Stop(); foreach (ButtonItem bt in ButtonItem.seznamVisibleButtons) { bt.killThis(); } if (gameInterval >= 100 && gameInterval < 130) { RunOnUiThread(() => obrazekSmile.SetImageResource(Resource.Drawable.smile)); } if (gameInterval < 100) { RunOnUiThread(() => obrazekSmile.SetImageResource(Resource.Drawable.lol)); } if (OptionsHodnoty.Vibrace) { mvibrator = (Vibrator)this.GetSystemService(Context.VibratorService); mvibrator.Vibrate(10); } //System.Threading.Thread.Sleep (malaPausa); gameIntervalBase--; gameInterval = gameIntervalBase; casovac.Start(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build(); StrictMode.SetThreadPolicy(policy); var wifi = (WifiManager)GetSystemService(WifiService); var ConnectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService); wifilock = wifi.CreateWifiLock(WifiMode.FullHighPerf, "WifiLock"); wifilock.Acquire(); game = new Game1( CreateUdpService(wifi, ConnectivityManager) , RuningOnAndroid: true ); if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { Vibrator vibrator = (Vibrator)GetSystemService(VibratorService); Game1.AndroidVibrate = f => vibrator.Vibrate(VibrationEffect.CreateOneShot(f, VibrationEffect.DefaultAmplitude)); } else { //TODO: } SetViewFullScreen(); //PowerManager pm = (PowerManager)GetSystemService(PowerService); //this.mWakeLock = pm.NewWakeLock(WakeLockFlags.ScreenDim, "My Tag"); //this.mWakeLock.Acquire(); game.Run(); }
public override void OnReceive(Context context, Intent intent) { if (Build.VERSION.SdkInt >= BuildVersionCodes.M) { PowerManager pm = (PowerManager)context.GetSystemService("power"); PowerManager.WakeLock wakeLock = pm.NewWakeLock(WakeLockFlags.Partial, "LocationManagerService"); if (pm.IsDeviceIdleMode) { // the device is now in doze mode Vibrator vibrator = (Vibrator)context.GetSystemService("vibrator"); vibrator.Vibrate(100); if (wakeLock.IsHeld == false) { wakeLock.Acquire(); } } else { Vibrator vibrator = (Vibrator)context.GetSystemService("vibrator"); vibrator.Vibrate(1000); if (wakeLock.IsHeld) { wakeLock.Release(); } // the device just woke up from doze mode } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); FrameLayout _frameLayout = FindViewById <FrameLayout>(Resource.Id.frameLayout1); _textureView = FindViewById <TextureView>(Resource.Id.textureView1); _textureView.SurfaceTextureListener = this; _accelerometer_textview_x = FindViewById <TextView>(Resource.Id.textView1); _accelerometer_textview_y = FindViewById <TextView>(Resource.Id.textView2); _accelerometer_textview_z = FindViewById <TextView>(Resource.Id.textView3); _light_textview = FindViewById <TextView>(Resource.Id.textView4); _accelerometer_X = FindViewById <ProgressBar>(Resource.Id.progressBar1); _accelerometer_Y = FindViewById <ProgressBar>(Resource.Id.progressBar2); _accelerometer_Z = FindViewById <ProgressBar>(Resource.Id.progressBar3); _accelerometer_X_reverse = FindViewById <ProgressBar>(Resource.Id.progressBar4); _accelerometer_Y_reverse = FindViewById <ProgressBar>(Resource.Id.progressBar5); _accelerometer_Z_reverse = FindViewById <ProgressBar>(Resource.Id.progressBar6); _image_strelka = FindViewById <ImageView>(Resource.Id.ImageView2); vibrator = (Vibrator)this.ApplicationContext.GetSystemService(ContextThemeWrapper.VibratorService); _sensorManager = (SensorManager)GetSystemService(SensorService); //------------------------------------ accelerometer ------------------------------------------------------ _accelerometerSensor = _sensorManager.GetDefaultSensor(SensorType.Accelerometer); if (_accelerometerSensor == null) { _accelerometer_textview_x.Text = string.Format("Nie je accelerometer!"); } else { _sensorManager.RegisterListener(this, _accelerometerSensor, Android.Hardware.SensorDelay.Game); } //------------------------------------ proximity ------------------------------------------------------ _proximitySensor = _sensorManager.GetDefaultSensor(SensorType.Proximity); if (_proximitySensor == null) { _accelerometer_textview_y.Text = string.Format("Nie je proximeter!"); } else { _sensorManager.RegisterListener(this, _proximitySensor, Android.Hardware.SensorDelay.Game); } //----------------------------------------- light ---------------------------------------------------- _lightSensor = _sensorManager.GetDefaultSensor(SensorType.Light); if (_lightSensor == null) { _accelerometer_textview_z.Text = string.Format("Nie je light sensor!"); } else { _sensorManager.RegisterListener(this, _lightSensor, Android.Hardware.SensorDelay.Game); } }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); Button btnServerSetting = FindViewById <Button>(Resource.Id.btnServerSetting); btnServerSetting.Click += BtnServerSetting_Click; txtScanCase = FindViewById <EditText>(Resource.Id.txtScanCase); txtScanCase.KeyPress += TxtScanCase_KeyPress; txtScanCount = FindViewById <TextView>(Resource.Id.txtScanCount); listViewScanCase = FindViewById <ListView>(Resource.Id.listViewScanCase); _listScanCase = new List <ScanCaseModel>(); vibrator = this.GetSystemService(VibratorService) as Vibrator; listViewScanCase.Adapter = new CaseItemAdapter(this, _listScanCase); //if (ReadSettingFile() == false) // OpenActivity(typeof(SettingActivity)); ReadCaseFile(); txtScanCase.RequestFocus(); } catch (Exception ex) { clsGLB.ShowMessage(ex.Message, this, MessageTitle.ERROR); } }
public void vibrar(int milisegundo) { Context context = Android.App.Application.Context; Vibrator vibrator = (Vibrator)context.GetSystemService(Context.VibratorService); vibrator.Vibrate(milisegundo); }
public void PlayVibrate() { var obj = Forms.Context.GetSystemService(Context.VibratorService); Vibrator vibrator = (Vibrator)obj; vibrator.Vibrate(500); }
private void Vibrate() { if (TimeUtil.CheckInterval("Vibrate", CT.table.vibrateInterval)) { Vibrator.Vibrate(CT.table.vibrateDuration); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); myVib = (Vibrator)GetSystemService(VibratorService); StartMainLayout(); }
public void ReceiveDetections(Detector.Detections detections) { var qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { if (Configuration.IsScanning) { Configuration.IsScanning = false; if (_vibrationOnDetected) { Vibrator vib = (Vibrator)_context.GetSystemService(Context.VibratorService); vib.Vibrate(200); } List <BarcodeResult> barcodeResults = new List <BarcodeResult>(); for (int i = 0; i < qrcodes.Size(); i++) { Barcode barcode = qrcodes.ValueAt(i) as Barcode; if (barcode == null) { continue; } var type = Methods.ConvertBarcodeResultTypes(barcode.ValueFormat); var value = barcode.DisplayValue; barcodeResults.Add(new BarcodeResult { BarcodeType = type, DisplayValue = value, Points = barcode.CornerPoints.Select(p => (p.X / (double)detections.FrameMetadata.Width, p.Y / (double)detections.FrameMetadata.Height)).ToList() });
public void CheckAccion(string accion, TLClient client, Contact contact) { try { if (accion == "B") { contactService.BlockKnownContact(client, contacto, contactRepository); textToSpeak = "Contacto bloqueado. "; } else if (accion == "D") { contactService.UnblockKnownContact(client, contacto, contactRepository); textToSpeak = "Contacto desbloqueado. "; } Vibrator vibrator = (Vibrator)this.GetSystemService(Context.VibratorService); vibrator.Vibrate(1000); count = 0; textToSpeak += "¿Quiere bloquear un contacto, desbloquear un contacto, no hacer nada o volver atrás?"; } catch (Exception ex) { count = 0; textToSpeak = "Ha ocurrido un problema bloquear o desbloquear el contacto. Por favor, inténtelo más tarde. " + "¿Quiere bloquear un contacto, desbloquear un contacto, no hacer nada o volver atrás?"; toSpeech = new TextToSpeech(this, this); } toSpeech = new TextToSpeech(this, this); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { vibrator = (Vibrator)Context.GetSystemService(Context.VibratorService); base.OnCreateView(inflater, container, savedInstanceState); var view = this.BindingInflate(Resource.Layout.SelectTimeFragment, null); controlButtons = view.FindViewById <LinearLayout>(Resource.Id.SelectTimeFragmentControlButtons); pager = view.FindViewById <ViewPager>(Resource.Id.SelectTimeFragmentPager); tabLayout = view.FindViewById <TabLayout>(Resource.Id.SelectTimeTabView); pager.OffscreenPageLimit = 2; pager.Adapter = new SelectTimePagerAdapter(BindingContext); tabLayout.AddOnTabSelectedListener(this); ViewModel.IsCalendarViewObservable .ObserveOn(SynchronizationContext.Current) .Subscribe(onIsCalendarViewChanged) .DisposedBy(disposableBag); subscribeAndAddToDisposableBag(nameof(ViewModel.StopTime), onStopTimeChanged); subscribeAndAddToDisposableBag(nameof(ViewModel.StartTime), onStartTimeChanged); subscribeAndAddToDisposableBag(nameof(ViewModel.IsEditingDuration), onDurationEditingStateChanged); ViewModel.TemporalInconsistencyDetected .Subscribe(onTemporalInconsistency) .DisposedBy(disposableBag); var startPageView = this.BindingInflate(Resource.Layout.SelectDateTimeStartTimeTabHeader, null); var stopPageView = this.BindingInflate(Resource.Layout.SelectDateTimeStopTimeTabHeader, null); var durationPageView = this.BindingInflate(Resource.Layout.SelectDateTimeDurationTabHeader, null); tabLayout.Post(() => { tabLayout.SetupWithViewPager(pager, true); tabLayout.GetTabAt(StartTimeTab).SetCustomView(startPageView); tabLayout.GetTabAt(StopTimeTab).SetCustomView(stopPageView); tabLayout.GetTabAt(DurationTab).SetCustomView(durationPageView); pager.SetCurrentItem(ViewModel.StartingTabIndex, false); startTimePickerContainer = view.FindViewById <FrameLayout>(Resource.Id.SelectStartTimeClockViewContainer); stopTimePickerContainer = view.FindViewById <FrameLayout>(Resource.Id.SelectStopTimeClockViewContainer); startDatePicker = view.FindViewById <TogglDroidDatePicker>(Resource.Id.SelectStartTimeCalendarView); stopDatePicker = view.FindViewById <TogglDroidDatePicker>(Resource.Id.SelectStopTimeCalendarView); stopDatePicker.BeginningOfWeek = ViewModel.BeginningOfWeek; startDatePicker.BeginningOfWeek = ViewModel.BeginningOfWeek; on24HoursModeChangeDisposable = ViewModel.Is24HoursModeObservable .ObserveOn(SynchronizationContext.Current) .Subscribe(on24HourModeSet); }); setupDialogWindowPosition(); return(view); }
private void notificationSound(string AlertTone) { try { Vibrator vibrator = (Vibrator)Android.App.Application.Context.GetSystemService(Context.VibratorService); if (vibrator.HasVibrator) { vibrator.Vibrate(500); } if (AlertTone == Notification) { player = MediaPlayer.Create(Android.App.Application.Context, RingtoneManager.GetDefaultUri(RingtoneType.Notification)); } else if (AlertTone == Alarm) { player = MediaPlayer.Create(Android.App.Application.Context, RingtoneManager.GetDefaultUri(RingtoneType.Alarm)); } else { player = MediaPlayer.Create(Android.App.Application.Context, RingtoneManager.GetDefaultUri(RingtoneType.Ringtone)); } player.Start(); } catch (System.Exception e) { ExceptioHandler(e.Message, "notificationSound"); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetTheme(Android.Resource.Style.ThemeMaterialLight); ActionBar.SetBackgroundDrawable(new ColorDrawable(Color.OrangeRed)); SetContentView(Resource.Layout.Main); //hardware lcmgr = GetSystemService(LocationService) as LocationManager; vibrator = GetSystemService(VibratorService) as Vibrator; // BtnLocation = FindViewById <Button>(Resource.Id.button1); BtnSpeed = FindViewById <Button>(Resource.Id.button2); BtnInfoGps = FindViewById <Button>(Resource.Id.button3); TxtViewMain = FindViewById <TextView>(Resource.Id.textView1); TxtTimer = FindViewById <TextView>(Resource.Id.textView2timer); BtnInfoGps.Background.SetColorFilter(blue, PorterDuff.Mode.Multiply); BtnLocation.Background.SetColorFilter(blue, PorterDuff.Mode.Multiply); BtnSpeed.Background.SetColorFilter(blue, PorterDuff.Mode.Multiply); BtnInfoGps.SetTextColor(Color.WhiteSmoke); BtnLocation.SetTextColor(Color.WhiteSmoke); BtnSpeed.SetTextColor(Color.WhiteSmoke); BtnInfoGps.Click += BtnInfoGps_Click; BtnLocation.Click += BtnLocation_Click; BtnSpeed.Click += BtnSpeed_Click; ActionBar.Title = "Speedometer"; }
public void OnPlayerChangedColor(PlayerChangedColorSignal signal) { if (signal.oldColor != GameColor.NONE) { Vibrator.Vibrate(50); } }
public void Announce(string message) { Notification.Builder builder = new Notification.Builder(parentActivity) .SetLocalOnly(true) .SetAutoCancel(true) .SetContentTitle("Chat (Xamarin)") .SetContentText(message) .SetSmallIcon(Resource.Drawable.ic_stat_icon); // Build the notification: Notification notification = builder.Build(); // Get the notification manager: NotificationManager notificationManager = parentActivity.GetSystemService(Context.NotificationService) as NotificationManager; // Publish the notification: const int notificationId = 0; if (notificationManager != null) { notificationManager.Notify(notificationId, notification); Vibrator vibrator = (Vibrator)parentActivity.GetSystemService(Context.VibratorService); vibrator.Vibrate(1000); CancelNotification(notificationManager).ConfigureAwait(false); } }
// Detecting The User Presses. private void Detect_LongPress(object sender, ElapsedEventArgs Event) { // Checking If The User 'Longged Pressed' A ImageView. ( To Change It To A Flag ) ImageView[,] Grid_Views = Minesweeper.Get_Grid_Views(); RelativeLayout Grid_Layout = FindViewById <RelativeLayout>(Resource.Id.Grid); // Checking If This View Still Being Pressed. if (Grid_Views[Pressed_Block_Location / Grid_Views.GetLength(1), Pressed_Block_Location % Grid_Views.GetLength(1)].GetY() + (int)(Block_Size / 2) < Press_Location.GetY() - Grid_Layout.GetY() && Grid_Views[Pressed_Block_Location / Grid_Views.GetLength(1), Pressed_Block_Location % Grid_Views.GetLength(1)].GetY() + (int)(Block_Size / 2) + Grid_Views[Pressed_Block_Location / Grid_Views.GetLength(1), Pressed_Block_Location % Grid_Views.GetLength(1)].Height > Press_Location.GetY() - Grid_Layout.GetY() && Grid_Views[Pressed_Block_Location / Grid_Views.GetLength(1), Pressed_Block_Location % Grid_Views.GetLength(1)].GetX() < (Press_Location.GetX() + (Grid_Layout.Width - Screen_Width)) + (Grid_Layout.Right - (Grid_Layout.GetX() + Grid_Layout.Width)) && Grid_Views[Pressed_Block_Location / Grid_Views.GetLength(1), Pressed_Block_Location % Grid_Views.GetLength(1)].GetX() + Grid_Views[Pressed_Block_Location / Grid_Views.GetLength(1), Pressed_Block_Location % Grid_Views.GetLength(1)].Width > (Press_Location.GetX() + (Grid_Layout.Width - Screen_Width)) + (Grid_Layout.Right - (Grid_Layout.GetX() + Grid_Layout.Width))) { Flag_Created = true; // Creating A Flag On That Location. if (Minesweeper.Change_Flag_State((Pressed_Block_Location / Grid_Views.GetLength(1)) + 1, (Pressed_Block_Location % Grid_Views.GetLength(1)) + 1)) { // Vibrating The Phone When Creating A Flag. Vibrator Vibrator = (Vibrator)Application.Context.GetSystemService(VibratorService); Vibrator.Vibrate(100); } } Timer_Detect_LongPress.Stop(); throw new NotImplementedException(); }
public static bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor) { Vibrator vibrator = (Vibrator)Game.contextInstance.GetSystemService(Context.VibratorService); vibrator.Vibrate(500); return(true); }
private SimpleMessageDialog LogErrorInternal(Exception ex, bool silent = false) { if (ex is LocalizedException) { WriteLine((ex as LocalizedException).InnerException, LogPriority.Error); } else { WriteLine(ex, LogPriority.Error); } if (silent) { return(null); } Vibrator vibrator = (Vibrator)_context.GetSystemService(Context.VibratorService); vibrator.Vibrate(VibrationEffect.CreateOneShot(100, VibrationEffect.DefaultAmplitude)); var simpleMessageDialog = new SimpleMessageDialog(_context) { ButtonTextId = Resource.String.mettarin_ok, MessageTextId = (ex is LocalizedException) ? (ex as LocalizedException).ResourceId : Resource.String.mettarin_error_text, TitleTextId = Resource.String.mettarin_error }; return(simpleMessageDialog); }
public void ReceiveDetections(Detector.Detections detections) { var qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { if (Configuration.IsScanning) { Configuration.IsScanning = false; if (_vibrationOnDetected) { Vibrator vib = (Vibrator)_context.GetSystemService(Context.VibratorService); vib.Vibrate(200); } List <BarcodeResult> barcodeResults = new List <BarcodeResult>(); for (int i = 0; i < qrcodes.Size(); i++) { Barcode barcode = qrcodes.ValueAt(i) as Barcode; if (barcode == null) { continue; } var type = Methods.ConvertBarcodeResultTypes(barcode.ValueFormat); var value = barcode.DisplayValue; barcodeResults.Add(new BarcodeResult { BarcodeType = type, DisplayValue = value }); } OnDetected?.Invoke(barcodeResults); } } }
public void MensajeEnviado(TLAbsUpdates updates, string fromPhone, string mensaje) { if (updates != null) { Chat m = new Chat { FromTo = fromPhone, Mensaje = mensaje, Send = true, Created = DateTime.Now, Seen = true }; messageRepository.InsertMessage(m); Vibrator vibrator = (Vibrator)this.GetSystemService(Context.VibratorService); vibrator.Vibrate(1000); _adapter = new MyAdapterSingle(this, Resource.Layout.SingleChatItem, GetChats()); _lv.Adapter = _adapter; count = 0; textToSpeak = "Mensaje enviado. ¿Quiere leer desde una fecha, buscar por un mensaje, no hacer nada o volver atrás?"; toSpeech = new TextToSpeech(this, this); } else { count = 0; textToSpeak = "No se ha podido enviar el mensaje. Inténtelo más tarde. ¿Quiere leer desde una fecha, buscar por un mensaje, no hacer nada o volver atrás?"; toSpeech = new TextToSpeech(this, this); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.GirviDailyReportlayout); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.app_bar); SetSupportActionBar(toolbar); SupportActionBar.SetTitle(Resource.String.app_name); SupportActionBar.SetDisplayHomeAsUpEnabled(true); //SupportActionBar.SetDisplayShowHomeEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); myVib = (Vibrator)this.GetSystemService(VibratorService); txtSurvatichiTarikh = FindViewById <TextView>(Resource.Id.txtSurwatichiTarikh); txtShewatchiTarikh = FindViewById <TextView>(Resource.Id.txtShewatchiTarikh); mListView = FindViewById <ListView>(Resource.Id.listViewGirviDailyReport); txtSurvatichiTarikh.Text = DateTime.Now.ToString("dd/MM/yyyy"); txtShewatchiTarikh.Text = DateTime.Now.ToString("dd/MM/yyyy"); txtShewatchiTarikh.Click += TxtShewatchiTarikh_Click; txtSurvatichiTarikh.Click += TxtSurvatichiTarikh_Click; LoadData(); txtShewatchiTarikh.AfterTextChanged += TxtShewatchiTarikh_AfterTextChanged; txtSurvatichiTarikh.AfterTextChanged += TxtSurvatichiTarikh_AfterTextChanged; mListView.ItemClick += MListView_ItemClick; mListView.ItemLongClick += MListView_ItemLongClick; }
private void StartListening() { PowerLock.RequestScreenLock(10); SetLabelText(string.Empty); Task.Run(() => Parallel.Invoke( () => { if (Pref.GetSoundFeedback()) { _player.Start(); } }, () => { if (Pref.GetVibrateFeedback()) { Vibrator vibrator = Vibrator.Vibrators[0]; vibrator.Vibrate(200, 100); } } )); AudioRecorder.StartRecording(Pref.GetHtmlResponse()); (ProgressPopup ?? (ProgressPopup = new ProgressPopup())).Show(); SetActionButtonIsEnabled(false); SetButtonImage("listen_disabled_allgreyedout.png"); }
void Game_Mechanics_Player_Colision() { /* * This Section Manages The Player Colision With The Asteroids. */ // Looping Thru The Asteroids List. for (int Asteroid_Index = 0; Asteroid_Index < Asteroids.Count(); Asteroid_Index++) { Asteroid Asteroid = Asteroids[Asteroid_Index]; // Creating A Reference To The Asteroid. if (Player.Collision_Detection(Asteroid.Get_Layout())) { // If The Asteroid Hit The Player. // Vibrating The Phone When User Hit Asteroid. Vibrator Vibrator = (Vibrator)Application.Context.GetSystemService(VibratorService); Vibrator.Vibrate(100); // Updating The Health Of The Player, And Checking If It's Health Is Depleted Below 0. if (Player.Update_Health(Asteroid.GetHealth()) <= 0) { // Saving The Game And Exiting To Main Screen. Save_And_Exit(); } Health_TextView.Text = Player.GetPlayer_Health().ToString(); // Update The Health TextView. Remove_Asteroid(Asteroid); } } }
/// <summary> /// User performed an action using single <paramref name="touch"/> /// </summary> /// <param name="touch"></param> private void SingleTouchLogic(Touch touch) { switch (touch.phase) { case TouchPhase.Stationary: stationaryTouchTime += Time.deltaTime; if (!GameManager.Instance.IsInputBlocked && stationaryTouchTime > TRANSLATE_TIMEOUT) { GameManager.Instance.IsInputBlocked = true; Vibrator.Vibrate(100); } break; case TouchPhase.Moved: if (stationaryTouchTime > TRANSLATE_TIMEOUT) { var ray = Camera.main.ScreenPointToRay(touch.position); Vector3 endPoint = ray.origin + (ray.direction * Vector3.Distance(Camera.main.transform.position, Board.transform.position)); ray = Camera.main.ScreenPointToRay(touch.position - touch.deltaPosition); Vector3 start = ray.origin + (ray.direction * Vector3.Distance(Camera.main.transform.position, Board.transform.position)); TranslateBoard(endPoint - start); } break; case TouchPhase.Canceled: case TouchPhase.Ended: GameManager.Instance.IsInputBlocked = false; stationaryTouchTime = 0; break; } }
public void MensajeEnviado(TLAbsUpdates updates, string fromPhone, string mensaje) { record = false; if (updates != null) { try { Chat m = new Chat { FromTo = fromPhone, Mensaje = mensaje, Send = true, Created = DateTime.Now, Seen = true }; messageRepository.InsertChat(m); Vibrator vibrator = (Vibrator)this.GetSystemService(Context.VibratorService); vibrator.Vibrate(1000); textToSpeak = "Mensaje enviado"; toSpeech = new TextToSpeech(this, this); } catch (Exception ex) { textToSpeak = "Ha ocurrido un error al acceder a la base de datos. Por favor, inténtelo más tarde."; toSpeech = new TextToSpeech(this, this); } } else { textToSpeak = "No se ha podido enviar el mensaje. Inténtelo más tarde"; toSpeech = new TextToSpeech(this, this); } }
partial void Initialize() { var context = Android.ContextHelper.CurrentContext; _vibrator = context.GetSystemService(Context.VibratorService) as Vibrator; }