示例#1
0
            public GlyphCastStage(IEnumerable <Glyph> validGlyphs, Glyph lastGlyph, double timeCoefficient, bool autoStart = true)
                : base($"Selecting glyphs among {String.Join("/", validGlyphs)}.")
            {
                Res.DebuggingSignalFlag = true;
                CurrentGlyph            = this;

                Stillness = new StillnessProvider();
                //Stillness.StartDisplayLoop(Current, 500);
                SetUpProvider(Stillness);
                //AverageStillness = new RollingAverage<float>(70);

                Shaking = new ShakingMonitor();
                //StopToken.Register(Shaking.Deactivate);
                Shaking.DependsOn(StopToken);

                //AttitudeProvider = new GravityOrientationProvider();
                //AttitudeProvider.Activate();
                GravityProvider = new Vector3Provider(SensorType.Gravity);
                GravityProvider.Activate(StopToken);

                ValidGlyphs     = validGlyphs.ToList();
                LastGlyph       = lastGlyph;
                TimeCoefficient = timeCoefficient;

                var activity = SpellCastingActivity.Current;

                activity.adapter = new GlyphDisplayAdapter(activity, ValidGlyphs);
                activity.RunOnUiThread(() => activity.listView.Adapter = activity.adapter);

                DependsOn(Current.StopToken);
                if (autoStart)
                {
                    Activate();
                }
            }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            GravProvider = new Vector3Provider(SensorType.Gravity, StopToken);
            GravProvider.Activate(); // Getting this running right away means that we can ask it for a meaningful value when the player presses the button.

            useVolumeTrigger        = true;
            OnVolumeButtonPressed  += LimberUpVolumePressed;
            OnVolumeButtonReleased += LimberUpVolumeReleased;

            Speech.Say("Limber up.");
            Speech.Say("Start at zero, hold down button and mime your rotation, let go at zero.", SoundOptions.AtSpeed(1.25));
        }
            public SeekReadyPositionStage(string label, Vector3 upDirection, bool AutoStart = true) : base(label)
            {
                UpDirection = upDirection;
                Stillness   = new StillnessProvider();
                SetUpProvider(Stillness, allowProviderToPersist: true);
                Gravity = new Vector3Provider(SensorType.Gravity, StopToken);
                Gravity.Activate();

                Current.RunOnUiThread(() =>
                {
                    Current.FindViewById(Resource.Id.vault_notification).Visibility = ViewStates.Visible;
                    Current.FindViewById(Resource.Id.vault_dial_text).Visibility    = ViewStates.Gone;
                });

                Current.LockBeingOpened.NumberOfAttempts++;
                if (AutoStart)
                {
                    Activate(Current.StopToken);
                }
            }
            public LimberingUpStage(Vector3 estimatedAxis, Vector3Provider gravProvider, bool AutoStart = true) : base("Limbering up")
            {
                AverageAxis  = new SimpleAverage <Vector3>(estimatedAxis);
                GyroProvider = new Vector3Provider(SensorType.Gyroscope, StopToken);
                GravProvider = gravProvider;
                SetUpProvider(GyroProvider);

                UpDirectionInitial = GravProvider.Vector;

                //Current.RunOnUiThread(() =>
                //{
                //    Current.FindViewById(Resource.Id.vault_notification).Visibility = ViewStates.Visible;
                //    Current.FindViewById(Resource.Id.vault_dial_text).Visibility = ViewStates.Gone;
                //});

                InterimInterval = TimeSpan.FromMilliseconds(20);
                if (AutoStart)
                {
                    Activate(Current.StopToken);
                }
            }
            public StrokeTrainingStage(string label, bool includeRandomWait = true, bool Autostart = false) : base(label)
            {
                Blade = Current.ThePlayersSword;

                GyroProvider = new Vector3Provider(Android.Hardware.SensorType.Gyroscope);
                GyroProvider.Activate();
                SetUpProvider(GyroProvider);
                AverageAxis          = new AdvancedRollingAverageVector3(averagingLength);
                AverageRotationSpeed = new AdvancedRollingAverageFloat(averagingLength);

                AccelProvider = new Vector3Provider(Android.Hardware.SensorType.LinearAcceleration);
                AccelProvider.Activate();
                AverageAccel = new AdvancedRollingAverageVector3(averagingLength);

                // AttitudeProvider moved into the prestartAction function, since it wants to inherit the provider of the EnGardeStage launching it.
                //AverageAttitude = new AdvancedRollingAverageQuat(averagingLength);

                thisStroke = new Stroke();

                if (Autostart)
                {
                    Activate();
                }
            }