コード例 #1
0
ファイル: NPCMap.cs プロジェクト: Guiedo/SunDofus
        private void Move(object e, EventArgs e2)
        {
            timer.Interval = Utilities.Basic.Rand(5000, 15000);

            var map = Entities.Requests.MapsRequests.MapsList.First(x => x.Model.ID == MapID);

            var path = new Game.Maps.Pathfinding("", map, MapCell, Dir);
            var newDir = Utilities.Basic.Rand(0, 3) * 2 + 1;
            var newCell = Game.Maps.Pathfinding.NextCell(map, MapCell, newDir);

            if (newCell <= 0)
                return;

            path.UpdatePath(Game.Maps.Pathfinding.GetDirChar(Dir) + Game.Maps.Pathfinding.GetCellChars(MapCell) + Game.Maps.Pathfinding.GetDirChar(newDir) +
                Game.Maps.Pathfinding.GetCellChars(newCell));

            var startpath = path.GetStartPath;
            var cellpath = path.RemakePath();

            if (!map.RushablesCells.Contains(newCell))
                return;

            if (cellpath != "")
            {
                MapCell = path.destination;
                Dir = path.direction;

                var packet = string.Format("GA0;1;{0};{1}", ID, startpath + cellpath);

                map.Send(packet);
            }
        }
コード例 #2
0
ファイル: GuildCollector.cs プロジェクト: Guiedo/SunDofus
        private void Move(object sender, EventArgs e)
        {
            timer.Interval = Utilities.Basic.Rand(5000, 15000);

            var path = new Game.Maps.Pathfinding("", Map, Cell, Dir);
            var newDir = Utilities.Basic.Rand(0, 3) * 2 + 1;
            var newCell = Game.Maps.Pathfinding.NextCell(Map, Cell, newDir);

            if (newCell <= 0)
                return;

            path.UpdatePath(Game.Maps.Pathfinding.GetDirChar(Dir) + Game.Maps.Pathfinding.GetCellChars(Cell) +
                Game.Maps.Pathfinding.GetDirChar(newDir) + Game.Maps.Pathfinding.GetCellChars(newCell));

            var startpath = path.GetStartPath;
            var cellpath = path.RemakePath();

            if (!Map.RushablesCells.Contains(newCell))
                return;

            if (cellpath != "")
            {
                Cell = path.destination;
                Dir = path.direction;

                var packet = string.Format("GA0;1;{0};{1}", ID, startpath + cellpath);

                Map.Send(packet);
            }
        }