public PushWorkBuilder setForwardExtraParams(string key, string value)
        {
            PushMap pushMap = new PushMap();

            pushMap.key   = key;
            pushMap.value = value;
            push.pushForward.schemeDataList.Add(pushMap);
            return(this);
        }
        public PushWorkBuilder setNotifyExtraParams(string key, string value)
        {
            PushMap pushMap = new PushMap();

            pushMap.key   = key;
            pushMap.value = value;
            push.pushNotify.extrasMapList.Add(pushMap);
            return(this);
        }
Ejemplo n.º 3
0
        public void Drop(VectorInt2 cell)
        {
            var action = Peek(cell);

            try
            {
                if (action == Action.Push)
                {
                    var dir = cell - Game.Current.Player.Position;
                    if (dir.IsUnit) // Next to each other
                    {
                        Game.Move(dir);
                    }
                }
                else if (action == Action.Move)
                {
                    start = Game.Current.Player.Position;
                    var end     = cell;
                    var boundry = Game.Current.ToMap(Game.Current.Definition.Wall, Game.Current.Definition.Crate,
                                                     Game.Current.Definition.CrateGoal);
                    var path = PathFinder.Find(boundry, start, end);
                    if (path != null)
                    {
                        foreach (var step in path)
                        {
                            Game.Move(step);
                        }
                    }
                }
                else if (action == Action.Drag)
                {
                    var end   = cell;
                    var state = Game.Analysis.Evalute(Game.Current);

                    var pushMap = PushMap.Find(state.Static, state.Current, start, Game.Current.Player.Position);
                    if (pushMap.CrateMap[end])
                    {
                        // Do Moves
                        var path = pushMap.FindPlayerWalkRoute(end);
                        if (path != null)
                        {
                            foreach (var c in path)
                            {
                                Game.Move(c);
                            }
                        }
                    }
                }
            }
            finally
            {
                // Finally
                isDragInProgress = false;
                start            = VectorInt2.MinValue;
            }
        }
Ejemplo n.º 4
0
        public void Regression1()
        {
            var report        = new TestReport();
            var defaultPuzzle = Puzzle.Builder.DefaultTestPuzzle(); // default puzzle
            var analysis      = new PuzzleAnalysis(defaultPuzzle);
            var state         = analysis.Evalute(defaultPuzzle);

            var pushMap = PushMap.Find(state, new VectorInt2(3, 3), defaultPuzzle.Player.Position);


            report.WriteLine("===================");
            report.WriteLine(defaultPuzzle);
            report.WriteLine(pushMap);
            report.WriteLine("===================");

            var r = pushMap.FindPlayerWalkRoute(new VectorInt2(7, 3));

            report.WriteLine(r);

            Assert.Equal(new TestReport(@"===================
#~~###~~~~#
~~##.#~####
~##..###..#
##.X......#
#...PX.#..#
###.X###..#
~~#..#OO..#
~##.##O#.##
~#......##~
~#.....##~~
########~~~

...........
....X......
...XX...XX.
..XXXXXXXX.
.XXXX...XX.
...X....XX.
...X..XXXX.
...X..X.X..
..XXXXXX...
..XXXXX....
...........

===================
LLURRRR
"), report);
        }
Ejemplo n.º 5
0
        public void CaseA()
        {
            var report = new TestReport();

            var sample = new[]
            {
                "#############",
                "#a ###    b##",
                "# A######  ##",
                "#  ######B ##",
                "#########  ##",
                "#############"
            };


            var boundry = Bitmap.Create(sample, x => x == '#');  //sample.ToMap('#', 'A', 'B');

            var staticMaps = new StaticMaps(
                Bitmap.Create(sample, '#'),
                Bitmap.Create(sample, ' ', 'a', 'b'),
                null,
                null
                );
            var stateMaps = new StateMaps(
                Bitmap.Create(sample, 'A', 'B'),
                FloodFill.Fill(staticMaps.WallMap, Bitmap.FindPosition(sample, 'a')));

            var pushMap = PushMap.Find(staticMaps, stateMaps, Bitmap.FindPosition(sample, 'A'),
                                       Bitmap.FindPosition(sample, 'b'));


            report.WriteLine(pushMap);

            Assert.Equal(new TestReport(@".............
..X..........
.............
..X..........
.............
............."), report);
        }
Ejemplo n.º 6
0
        public void UpdateMouseWithLogicalCell(VectorInt2 cell, bool isLeftDown, bool isRightDown)
        {
            if (!Game.Current.Contains(cell))
            {
                return;
            }

            peekMovePath  = null;
            peekCratePath = null;
            try
            {
                if (isLeftDown && !prevLeftDown)
                {
                    Drag(cell);
                    return;
                }

                if (!isLeftDown && prevLeftDown)
                {
                    Drop(cell);
                    return;
                }

                var peek = Peek(cell);
                if (peek != Action.None)
                {
                    if (peek == Action.Move)
                    {
                        start = Game.Current.Player.Position;
                        var end     = cell;
                        var boundry = Game.Current.ToMap(Game.Current.Definition.Wall, Game.Current.Definition.Crate,
                                                         Game.Current.Definition.CrateGoal);
                        peekMovePath = PathFinder.Find(boundry, start, end);
                    }
                    else if (peek == Action.Drag)
                    {
                        var end     = cell;
                        var state   = Game.Analysis.Evalute(Game.Current);
                        var pushMap = PushMap.Find(state.Static, state.Current, start, Game.Current.Player.Position);
                        if (pushMap.CrateMap[end])
                        {
                            //var walk = pushMap.FindPlayerWalkRoute(end);
                            peekCratePath = pushMap.FindCrateRoute(end);

                            // PLayer move to begin crate stuff

                            var pstart  = Game.Current.Player.Position;
                            var pend    = start - peekCratePath.First();
                            var boundry = Game.Current.ToMap(Game.Current.Definition.Wall,
                                                             Game.Current.Definition.Crate,
                                                             Game.Current.Definition.CrateGoal);
                            peekMovePath = PathFinder.Find(boundry, pstart, pend);
                            if (peekMovePath != null)
                            {
                                peekMovePath.Add(peekCratePath.First());
                            }
                        }
                    }
                }
            }
            finally
            {
                prev          = cell;
                prevLeftDown  = isLeftDown;
                prevRightDown = isRightDown;
            }
        }