public NewGlyphTrainingStage(int targetGlyphIndex, Focus Focus, OrientationSensorProvider Provider = null)
                : base($"Training glyph {Glyph.AllGlyphs[targetGlyphIndex].Name}")
            {
                TargetGlyphIndex        = targetGlyphIndex;
                TargetGlyph             = Glyph.AllGlyphs[targetGlyphIndex];
                Implement               = Focus;
                Res.DebuggingSignalFlag = true;

                verbLog("Ctor");
                Stillness = new StillnessProvider();
                //Stillness.StartDisplayLoop(Current, 750);

                SetUpProvider(Stillness);
                Volume = 0.1f;

                verbLog("Averages");
                //AverageAttitude = new AdvancedRollingAverageQuat(timeFrameInPeriods: 15);
                AverageAttitude  = new RollingAverage <Quaternion>(timeFrameInPeriods: 10);
                AttitudeProvider = Provider ?? new GravityOrientationProvider(Implement.FrameShift);
                AttitudeProvider.Activate();

                if (targetGlyphIndex == 0)
                {
                    lastOrientation = Quaternion.Identity;
                }
                else
                {
                    lastOrientation = Glyph.AllGlyphs[targetGlyphIndex - 1].Orientation;
                }

                verbLog("Auto-activation");
                Activate();
            }
            public GlyphTrainingStage(string label, Focus Focus, OrientationSensorProvider Provider = null) : base(label)
            {
                Implement = Focus;
                Res.DebuggingSignalFlag = true;

                verbLog("Ctor");
                Stillness = new StillnessProvider();
                //Stillness.StartDisplayLoop(Current, 750);

                SetUpProvider(Stillness);
                Volume = 0.1f;

                verbLog("Averages");
                //AverageAttitude = new AdvancedRollingAverageQuat(timeFrameInPeriods: 15);
                AverageAttitude  = new RollingAverage <Quaternion>(timeFrameInPeriods: 10);
                AttitudeProvider = Provider ?? new GravityOrientationProvider(Implement.FrameShift);
                AttitudeProvider.Activate();

                if (Current.SpellBeingTrained.Glyphs.Count == 0)
                {
                    lastOrientation = Quaternion.Identity;
                }
                else
                {
                    lastOrientation = Current.SpellBeingTrained.Glyphs.Last().Orientation;
                }

                verbLog("Auto-activation");
                Activate();
            }
Beispiel #3
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();
                }
            }
            public DefineEnGardeStage(string label, bool AutoStart = false) : base(label)
            {
                Blade     = Current.ThePlayersSword;
                Stillness = new StillnessProvider();
                SetUpProvider(Stillness);

                AttitudeProvider = new GravityOrientationProvider();
                AttitudeProvider.Activate();

                if (AutoStart)
                {
                    Activate();
                }
            }
Beispiel #5
0
            public Gunfight_AimStage(string label, Gun gun, CancellationToken?externalToken = null, bool AutoStart = false) : base(label)
            {
                Weapon = gun;
                DependsOn(externalToken ?? CancellationToken.None);
                //SetUpParser(Weapon.PitchAccel, Weapon.MinimumAimTime, 2, 1);
                Stillness = new StillnessProvider(externalToken: StopToken);
                SetUpProvider(Stillness);
                Gravity = new GravityOrientationProvider(null, StopToken);
                Gravity.Activate();
                random = new Random();

                if (AutoStart)
                {
                    Activate();
                }
            }
            public NewSpell_Training_TutorialStage(string label, Focus Focus, bool AutoStart = false) : base(label)
            {
                Implement = Focus;
                Stillness = new StillnessProvider();
                SetUpProvider(Stillness);
                Stillness.StartDisplayLoop(Current, 1000);
                SpellBeingTrained = Current.SpellBeingTrained;

                AttitudeProvider = new GravityOrientationProvider(Implement.FrameShift);
                AttitudeProvider.Activate();

                if (AutoStart)
                {
                    Activate();
                }
            }
            public EnGardeStage(string label, string nextStageCue, IGestureRecognizerStage nextStage, bool AutoStart = false) : base(label)
            {
                Blade        = Current.ThePlayersSword;
                NextStageCue = nextStageCue;
                NextStage    = nextStage;

                Stillness = new StillnessProvider();
                SetUpProvider(Stillness);

                AttitudeProvider = new GravityOrientationProvider(); // Always a fresh, un-frame-shifted, gravity-only one for this part!
                AttitudeProvider.Activate();

                if (AutoStart)
                {
                    Activate();
                }
            }
            public FormSetupStage(string label, FrameShiftedOrientationProvider provider = null, bool Autostart = false) : base(label)
            {
                Blade = Current.ThePlayersSword;
                IsInitialPoseEstimate = (Current.FormBeingTrained.InitialOrientation.IsIdentity);

                Stillness = new StillnessProvider();
                SetUpProvider(Stillness);

                //AttitudeProvider = provider ?? new OrientationSensorProvider(Android.Hardware.SensorType.GameRotationVector);
                AttitudeProvider = provider; // If null, we'd bloody well better be planning to set it externally! ?? new FrameShiftedOrientationProvider(Android.Hardware.SensorType.GameRotationVector, Blade.EnGardeOrientation.Average);
                if (provider == null && Autostart)
                {
                    throw new ArgumentNullException("provider", "Provider cannot be null if you're planning to automatically start - that only works if you're setting it externally after ctor but before Activate().");
                }
                //if (!AttitudeProvider.IsActive) AttitudeProvider.Activate();

                if (Autostart)
                {
                    Activate();
                }
            }
Beispiel #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Gunfight);

            stillnessMonitor = new StillnessProvider(externalToken: StopToken);

            // See if the current gun is already in our (local, for now) library, and load it if so.  Otherwise, take us to calibration.
            //var gunString = Res.SpecificTags.Get(InteractionLibrary.CurrentSpecificTag);
            //if (gunString != null && CurrentActivity is GunfightActivity)
            //{
            //    CurrentGun = Gun.FromString(gunString, InteractionLibrary.CurrentSpecificTag);
            //}
            //else if (InteractionLibrary.CurrentSpecificTag == InteractionLibrary.Gunfight.Name + "0000")
            //{
            //    CurrentGun = new Gun();
            //}
            //else
            //{
            //    CurrentGun = new Gun(InteractionLibrary.CurrentSpecificTag);
            //    //InteractionLibrary.Current = InteractionLibrary.GunCalibration;
            //}
            CurrentGun = CurrentGun ?? new Gun();

            bulletPane = FindViewById <LinearLayout>(Resource.Id.gunfight_bullet_pane);
            foreach (var i in Enumerable.Range(0, CurrentGun.MaxAmmoCapacity))
            {
                var bulletI = new ImageView(this);
                bulletI.SetImageDrawable(GetDrawable(Resource.Drawable.bullet));
                bulletI.LayoutParameters = new ViewGroup.LayoutParams(width: ViewGroup.LayoutParams.MatchParent, height: ViewGroup.LayoutParams.WrapContent);
                bulletList.Add(bulletI);
                bulletPane.AddView(bulletI);
            }

            killMarkers = FindViewById <ImageView>(Resource.Id.gunfight_killmarkers);

            CurrentStage = new Gunfight_AimStage("Aim", CurrentGun, StopToken);

            ShotHitSFX = new EffectGroup("Gun.Hit", //new Effect("Gun.Hit.0", Resource.Raw._104170_mild_ouch),
                                                    //new Effect("Gun.Hit.1", Resource.Raw._129346_male_grunt_1),
                                         new Effect("Gun.Hit.2", Resource.Raw._188544_breathy_ugh),
                                         new Effect("Gun.Hit.3", Resource.Raw._262279_male_grunt_3),
                                         new Effect("Gun.Hit.4", Resource.Raw._340280_male_oof_med),
                                         new Effect("Gun.Hit.5", Resource.Raw._340285_female_oof_med),
                                         new Effect("Gun.Hit.6", Resource.Raw._34249_mild_agh),
                                         new Effect("Gun.Hit.7", Resource.Raw._44430_vocalized_ow)
                                         //,new Effect("Gun.Shot.8", Resource.Raw._85553_male_grunt_2)
                                         );
            ShotMissSFX = new EffectGroup("Gun.Miss", new Effect("Gun.Miss.0", Resource.Raw._148840_multiple_ricochet),
                                          new Effect("Gun.Miss.1", Resource.Raw._156140_dull_platic_or_metal_impact),
                                          //new Effect("Gun.Miss.2", Resource.Raw._169551_crisp_faint_impact),
                                          new Effect("Gun.Miss.3", Resource.Raw._170509_crate_impact),
                                          new Effect("Gun.Miss.4", Resource.Raw._96629_ricochet_metal),
                                          new Effect("Gun.Miss.5", Resource.Raw._96630_ricochet_metal2),
                                          new Effect("Gun.Miss.6", Resource.Raw._96631_ricochet_metal3),
                                          new Effect("Gun.Miss.7", Resource.Raw._96632_ricochet_metal4),
                                          new Effect("Gun.Miss.8", Resource.Raw._96633_ricochet_metal5),
                                          new Effect("Gun.Miss.9", Resource.Raw._96634_ricochet_wood),
                                          new Effect("Gun.Miss.10", Resource.Raw._96635_ricochet_wood2),
                                          new Effect("Gun.Miss.11", Resource.Raw._96636_ricochet_wood3)
                                          );

            //SetTagRemovalResult(Finish, 10, 2);
            //LinkSeekbars();

            useVolumeTrigger       = true;
            OnVolumeButtonClicked += (o, e) => { ((Gunfight_AimStage)CurrentStage).ResolveTriggerPull(); };

            // Automatically distribute "OnGunshotFired" results to the "OnHit" and "OnMiss" events, based on the result.
            OnGunshotFired += (o, e) =>
            {
                if (e.Value > 0)
                {
                    OnGunshotHit.Raise(e.Value);
                }
                else
                {
                    OnGunshotMiss.Raise(-e.Value);
                }
            };

            Task.Run(async() =>
            {
                await System.Threading.Tasks.Task.Delay(750);
                //Res.SFX.PlaySound("Gun.C**k");
                await CurrentGun.CockSFX.PlayToCompletion(useSpeakers: true);
                //await System.Threading.Tasks.Task.Delay(500);
            });
        }