Exemple #1
0
        public static IObservable <Unit> registerDebugSequence(
            IDisposableTracker tracker,
            DebugSequenceMouseData mouseData = null,
            Option <DebugSequenceDirectionData> directionDataOpt = default,
            DebugConsoleBinding binding = null,
            [CallerMemberName] string callerMemberName = "",
            [CallerFilePath] string callerFilePath     = "",
            [CallerLineNumber] int callerLineNumber    = 0
            )
        {
            Option.ensureValue(ref directionDataOpt);

            binding   = binding ? binding : Resources.Load <DebugConsoleBinding>("Debug Console Prefab");
            mouseData = mouseData ?? DEFAULT_MOUSE_DATA;

            var mouseObs =
                new RegionClickObservable(mouseData.width, mouseData.height)
                .sequenceWithinTimeframe(
                    tracker, mouseData.sequence, 3,
                    // ReSharper disable ExplicitCallerInfoArgument
                    callerMemberName: callerMemberName,
                    callerFilePath: callerFilePath,
                    callerLineNumber: callerLineNumber
                    // ReSharper restore ExplicitCallerInfoArgument
                    );

            var directionObs = directionDataOpt.fold(
                Observable <Unit> .empty,
                directionData => {
                var directions = Observable.everyFrame.collect(_ => {
                    var horizontal = Input.GetAxisRaw(directionData.horizonalAxisName);
                    var vertical   = Input.GetAxisRaw(directionData.verticalAxisName);
                    // Both are equal, can't decide.
                    if (Math.Abs(horizontal - vertical) < 0.001f)
                    {
                        return(Option <Direction> .None);
                    }
                    return
                    (Math.Abs(horizontal) > Math.Abs(vertical)
              ? F.some(horizontal > 0 ? Direction.Right : Direction.Left)
              : F.some(vertical > 0 ? Direction.Up : Direction.Down));
                }).changedValues();

                return
                (directions
                 .withinTimeframe(directionData.sequence.Count, directionData.timeframe)
                 .filter(l => l.Select(t => t._1).SequenceEqual(directionData.sequence))
                 .discardValue());
            }
                );

            var editorShortcut = instance.editorShortcutObs.filter(_ => instance.current.isNone);
            var obs            = mouseObs.join(directionObs).join(editorShortcut);

            obs.subscribe(tracker, _ => instance.show(binding));
            return(obs);
        }
Exemple #2
0
        public static IObservable <Unit> registerDebugSequence(
            DebugSequenceMouseData mouseData = null,
            Option <DebugSequenceDirectionData> directionDataOpt = default(Option <DebugSequenceDirectionData>),
            DebugConsoleBinding binding = null
            )
        {
            Option.ensureValue(ref directionDataOpt);

            binding   = binding ?? Resources.Load <DebugConsoleBinding>("Debug Console Prefab");
            mouseData = mouseData ?? DEFAULT_MOUSE_DATA;

            var mouseObs =
                new RegionClickObservable(mouseData.width, mouseData.height)
                .sequenceWithinTimeframe(mouseData.sequence, 3);

            var directionObs = directionDataOpt.fold(
                Observable <Unit> .empty,
                directionData => {
                var directions = Observable.everyFrame.collect(_ => {
                    var horizontal = Input.GetAxisRaw(directionData.horizonalAxisName);
                    var vertical   = Input.GetAxisRaw(directionData.verticalAxisName);
                    // Both are equal, can't decide.
                    if (Math.Abs(horizontal - vertical) < 0.001f)
                    {
                        return(Option <Direction> .None);
                    }
                    return
                    (Math.Abs(horizontal) > Math.Abs(vertical)
              ? F.some(horizontal > 0 ? Direction.Right : Direction.Left)
              : F.some(vertical > 0 ? Direction.Up : Direction.Down));
                }).changedValues();

                return
                (directions
                 .withinTimeframe(directionData.sequence.Count, directionData.timeframe)
                 .filter(l => l.Select(t => t._1).SequenceEqual(directionData.sequence))
                 .discardValue());
            }
                );

            var obs = mouseObs.join(directionObs);

            obs.subscribe(_ => instance.show(binding));
            return(obs);
        }