コード例 #1
0
        /// <summary>
        ///     Pauses and resumes the path recorder based on
        ///     its current state.
        /// </summary>
        private void Record()
        {
            // Return when the user has not selected a process.
            if (FFACE == null)
            {
                AppServices.InformUser("No process has been selected.");
                return;
            }

            if (FFACE.Player.Zone != Config.Instance.Route.Zone && Config.Instance.Route.Zone != Zone.Unknown)
            {
                AppServices.InformUser("Cannot record waypoints from a different zone.");
                return;
            }

            Config.Instance.Route.Zone = FFACE.Player.Zone;

            if (!PathRecorder.IsRecording)
            {
                PathRecorder.OnPositionAdded += PathRecorder_OnPositionAdded;
                PathRecorder.Start();
                RecordHeader = "Recording!";
            }
            else
            {
                PathRecorder.OnPositionAdded -= PathRecorder_OnPositionAdded;
                PathRecorder.Stop();
                RecordHeader = "Record";
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: jnoyola/GW2-Live
        private void pathButton_Click(object sender, System.EventArgs e)
        {
            if (isPathing)
            {
                isPathing = false;

                pathButton.SetPropertyThreadSafe("Text", "Path");
                saveButton.Enabled  = true;
                resetButton.Enabled = true;

                pathRecorder.StopRecording();
            }
            else
            {
                bool shouldStartPathing = true;

                if (mapView.Plan.Route.Count > 0)
                {
                    DialogResult dialogResult = MessageBox.Show("This will overwrite any previously recorded path.\n Are you sure you want to proceed?", "Overwrite Path", MessageBoxButtons.YesNo);
                    shouldStartPathing = (dialogResult == DialogResult.Yes);
                }

                if (shouldStartPathing)
                {
                    isPathing = true;
                    pathButton.SetPropertyThreadSafe("Text", "Done");
                    saveButton.Enabled  = false;
                    resetButton.Enabled = false;

                    pathRecorder = new PathRecorder(mumble, mapView);
                    pathRecorder.Record();
                }
            }
        }
コード例 #3
0
        public void AddNewPositionWithPositionWillRecordIt()
        {
            Position expected = new Position {
                H = 1, X = 1, Y = 1, Z = 1
            };
            Position result = null;

            var recorder = new PathRecorder(null);

            recorder.OnPositionAdded += actual => result = actual;
            recorder.AddNewPosition(expected);

            Assert.Equal(expected, result);
        }
コード例 #4
0
        public static void Part2_Step1(IEnumerable <long> program)
        {
            // Record the path needed to complete the scaffolding
            var map  = GetMap(program);
            var xmax = map[0].Length - 1;
            var ymax = map.Count - 1;

            // utility function, position is in map boundaries and to get a map character
            bool InMap((int x, int y) p) => p.x >= 0 && p.x <= xmax && p.y >= 0 && p.y <= ymax;
            char Map((int x, int y) p) => map[p.y][p.x];

            var startPosition = Utils.Range2D(0, 0, map[0].Length, map.Count).Where(p => Map(p) == '^').First();
            var pathRecorder  = new PathRecorder(startPosition);

            while (true)
            {
                var nextForwardPosition = pathRecorder.NextForwardPosition();
                // can move forward?
                if (InMap(nextForwardPosition) && Map(nextForwardPosition) == '#')
                {
                    pathRecorder.Forward();
                    continue;
                }
                // attempt a right turn
                var rightTurnPosition = pathRecorder.RightTurnPosition();
                if (InMap(rightTurnPosition) && Map(rightTurnPosition) == '#')
                {
                    pathRecorder.TurnRight();
                    pathRecorder.Forward();
                    continue;
                }
                // attempt a left turn
                var leftTurnPosition = pathRecorder.LeftTurnPosition();
                if (InMap(leftTurnPosition) && Map(leftTurnPosition) == '#')
                {
                    pathRecorder.TurnLeft();
                    pathRecorder.Forward();
                    continue;
                }
                // no way to go, we are done
                pathRecorder.Stop();
                break;
            }
            var steps = pathRecorder.Steps;

            // print the steps which have to be factorized (manually for now)
            Console.WriteLine("Steps:\n" + steps);
        }
コード例 #5
0
        /// <summary>
        /// Set up session from given fface session.
        /// </summary>
        /// <param name="fface"></param>
        protected static void SetSession(IMemoryAPI fface)
        {
            if (fface == null)
            {
                return;
            }

            // Save fface Write
            FFACE = fface;

            // Create a new game engine to control our character.
            GameEngine = new GameEngine(FFACE);

            // Create path record for navigation
            PathRecorder = new PathRecorder(FFACE);
        }
コード例 #6
0
        /// <summary>
        /// Set up session from given EliteApi session.
        /// </summary>
        /// <param name="fface"></param>
        public static void SetSession(IMemoryAPI fface)
        {
            if (fface == null)
            {
                return;
            }

            // Save EliteApi Write
            FFACE = fface;

            // Create a new game engine to control our character.
            GameEngine = new GameEngine(FFACE);

            // Create path record for navigation
            PathRecorder = new PathRecorder(FFACE);

            AbilityService = new AbilityService(FFACE);

            AutoLoadSettings();
        }
コード例 #7
0
 public void Initialize()
 {
     recorder          = new PathRecorder(new MMemoryWrapper());
     recorder.Interval = 5;
 }
コード例 #8
0
 private void ViewModelBase_OnSessionSet(MemoryWrapper fface)
 {
     _recorder = new PathRecorder(fface);
     _recorder.OnPositionAdded += _recorder_OnPositionAdded;
 }