protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); tvAppName = FindViewById <TextView>(Resource.Id.tvAppName); tvAppName.Text = "THE FABULOUS CRYING PHONE !"; tvInfo = FindViewById <TextView>(Resource.Id.tvInfo); tvInfo.Text = "La voie 1 est sélectionnée par défaut, Bouger le téléphone pour commencer. Une partie dure minimum 20 sec, a la fin d'une partie, secoué le téléphone pour rejouer"; btnVoice01 = FindViewById <Button>(Resource.Id.btnVoice01); btnVoice01.Click += BtnVoice01_Click; btnVoice02 = FindViewById <Button>(Resource.Id.btnVoice02); btnVoice02.Click += BtnVoice02_Click; btnVoiceOff = FindViewById <Button>(Resource.Id.btnVoiceOff); btnVoiceOff.Click += BtnVoiceOff_Click; if (!gameAlreadyLaunch) { InitVoice(); accelerometerReader.ToggleAccelerometer(); orientationReader.ToggleOrientationSensor(); gyroscopeReader.ToggleGyroscope(); //Delay3s(); CreateStateMachine(); MainLoop(); } }
private void Lancement() { MainThread.BeginInvokeOnMainThread(() => { if (accelerometerReader.isStarted == false) { accelerometerReader.ToggleAccelerometer(); } if (orientationReader.isStarted == false) { orientationReader.ToggleOrientationSensor(); } if (gyroscopeReader.isStarted == false) { gyroscopeReader.ToggleGyroscope(); } }); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); nbShock = 0; rollListening = false; tvAppName = FindViewById <TextView>(Resource.Id.tvAppName); tvAppName.Text = "Génial ça marche !"; tvAccX = FindViewById <TextView>(Resource.Id.tvAccX); tvAccY = FindViewById <TextView>(Resource.Id.tvAccY); tvAccZ = FindViewById <TextView>(Resource.Id.tvAccZ); quaw = FindViewById <TextView>(Resource.Id.quaw); quax = FindViewById <TextView>(Resource.Id.quax); quay = FindViewById <TextView>(Resource.Id.quay); quaz = FindViewById <TextView>(Resource.Id.quaz); pitch = FindViewById <TextView>(Resource.Id.pitch); roll = FindViewById <TextView>(Resource.Id.roll); gyroX = FindViewById <TextView>(Resource.Id.gyroX); gyroY = FindViewById <TextView>(Resource.Id.gyroY); gyroZ = FindViewById <TextView>(Resource.Id.gyroZ); accelerometerReader.ToggleAccelerometer(); orientationReader.ToggleOrientationSensor(); gyroscopeReader.ToggleGyroscope(); Delay5s(); tvAccX.Text = accelerometerReader.accX.ToString(); tvAccY.Text = accelerometerReader.accY.ToString(); tvAccZ.Text = accelerometerReader.accZ.ToString(); CalculPitchAndRoll(); //accelerometerReader.ToggleAccelerometer(); quaw.Text = orientationReader.oriW.ToString(); quax.Text = orientationReader.oriX.ToString(); quay.Text = orientationReader.oriY.ToString(); quaz.Text = orientationReader.oriZ.ToString(); gyroX.Text = gyroscopeReader.gyroX.ToString(); gyroY.Text = gyroscopeReader.gyroY.ToString(); gyroZ.Text = gyroscopeReader.gyroZ.ToString(); mediaPlayer = MediaPlayer.Create(this, Resource.Raw.Voice01_01); btPlaySound = FindViewById <Button>(Resource.Id.btPlaySound); btPlaySound.Click += BtPlaySound_Click; btPlayStream = FindViewById <Button>(Resource.Id.btPlayStream); btPlayStream.Click += BtPlayStream_Click; startTimer(); }