Ejemplo n.º 1
0
        public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
        {
            if (keyCode == Keycode.VolumeDown || keyCode == Keycode.VolumeUp)
            {
                lock (SelectedGestureClass)
                {
                    if (!_collectingData)
                    {
                        RelayToast("Listening...");
                        _collectingData = true;

                        ResetStage("Melee stage");
                        //CuePrompter?.MarkGestureStart();
                        Stopwatch.Stop();
                        SingleClickWatch.Restart();
                        Delay = Stopwatch.Elapsed;
                        CurrentStage.Activate();
                        return(true);
                    }
                }
                if (_collectingData)
                {
                    return(true);
                }
            }
            return(base.OnKeyDown(keyCode, e));
        }
Ejemplo n.º 2
0
            protected override async Task nextStageActionAsync()
            {
                if (Current.setFormNameButton.Text == RetrainEnGardeText)
                {
                    Current.setFormNameButton.Text = "Random";                                                       // Undoes our little textual flag that lets us retrain the en garde using this button instead of its usual function.
                }
                var oldOrientation = Blade.EnGardeOrientation.Average;

                Blade.EnGardeOrientation.Update(AttitudeProvider.Quaternion); // Subtle trick: we keep averaging the En Garde orientation so it "tracks" the player's shifts in taking it, over time.
                Log.Debug("EnGarde Stage", $"Updating the prior en garde ({oldOrientation}), using the new one ({AttitudeProvider.Quaternion}," +
                          $" {AttitudeProvider.Quaternion.AngleTo(oldOrientation)} degrees away), producing a new one ({Blade.EnGardeOrientation.Average}," +
                          $" {Blade.EnGardeOrientation.Average.AngleTo(oldOrientation)} degrees away from the prior one).");

                //// In order to *pass along* a provider, to an arbitrary Gesture Stage which has already been created and passed to us
                //// (and which might or might not want to use our provider at all), we use this trick.  Activate it in here, and during
                //// activation, a specific STATIC provider is made available.  We lock so that (in theory) two EnGarde Stages which were
                //// running in separate threads wouldn't end up accessing the static value at the wrong times.
                //using (await _asyncLock.LockAsync())
                //{
                //    //EngardeProvider = AttitudeProvider; // Can be referenced from inside the prestartAction of the provided stage, if desired. (Not during the ctor... that's already gone by!)
                //    EngardeProvider = new FrameShiftedOrientationProvider(Android.Hardware.SensorType.GameRotationVector);
                //    await Task.WhenAll(EngardeProvider.SetFrameShiftFromCurrent(), Speech.Say(NextStageCue));
                //    CurrentStage = NextStage;
                //    CurrentStage.Activate();
                //    EngardeProvider = null;
                //}

                // Different approach to solving the above problem.
                var EngardeProvider = new FrameShiftedOrientationProvider(Android.Hardware.SensorType.GameRotationVector);
                await Task.WhenAll(EngardeProvider.SetFrameShiftFromCurrent(), Speech.SayAllOf(NextStageCue));

                CurrentStage = NextStage;
                var cStage = CurrentStage as ITakeAnAttitudeProvider;

                if (cStage != null)
                {
                    cStage.AttitudeProvider = EngardeProvider;
                }
                CurrentStage.Activate();
            }
Ejemplo n.º 3
0
        public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
        {
            if (keyCode == Keycode.VolumeDown || keyCode == Keycode.VolumeUp)
            {
                lock (SelectedGestureClass)
                {
                    if (!_collectingData && !_finalizingGesture)
                    {
                        _collectingData = true;

                        ResetStage("Hacking stage");
                        //SingleClickWatch.Restart();
                        CurrentStage.Activate();
                        return(true);
                    }
                }
                if (_collectingData)
                {
                    return(true);
                }
            }
            return(base.OnKeyDown(keyCode, e));
        }