Ejemplo n.º 1
0
        private void Move(object sender, EventArgs e)
        {
            timer.Interval = Utilities.Basic.Rand(5000, 15000);

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

            if (newCell <= 0)
            {
                return;
            }

            path.UpdatePath(Maps.Pathfinding.GetDirChar(Dir) + Maps.Pathfinding.GetCellChars(Cell) +
                            Maps.Pathfinding.GetDirChar(newDir) + 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);
            }
        }
Ejemplo n.º 2
0
        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 Maps.Pathfinding("", map, MapCell, Dir);
            var newDir  = Utilities.Basic.Rand(0, 3) * 2 + 1;
            var newCell = Maps.Pathfinding.NextCell(map, MapCell, newDir);

            if (newCell <= 0)
            {
                return;
            }

            path.UpdatePath(Maps.Pathfinding.GetDirChar(Dir) + Maps.Pathfinding.GetCellChars(MapCell) + Maps.Pathfinding.GetDirChar(newDir) +
                            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);
            }
        }