Beispiel #1
0
 public void AddDirection(MapDirectionEnum direction)
 {
     if (!DirectionEnum.Exists(x => x == direction))
     {
         DirectionEnum.Add(direction);
     }
 }
Beispiel #2
0
        public IMapChangement ChangeMap(MapDirectionEnum direction)
        {
            lock (CheckLock)
            {
                var neighbourId = -1;
                var num2        = -1;
                switch (direction)
                {
                case MapDirectionEnum.North:
                    neighbourId = ((API.Gamedata.D2p.Map)Data).TopNeighbourId;
                    num2        = 64;
                    break;

                case MapDirectionEnum.South:
                    neighbourId = ((API.Gamedata.D2p.Map)Data).BottomNeighbourId;
                    num2        = 4;
                    break;

                case MapDirectionEnum.East:
                    neighbourId = ((API.Gamedata.D2p.Map)Data).RightNeighbourId;
                    num2        = 1;
                    break;

                case MapDirectionEnum.West:
                    neighbourId = ((API.Gamedata.D2p.Map)Data).LeftNeighbourId;
                    num2        = 16;
                    break;
                }

                if (num2 == -1 || neighbourId < 0)
                {
                    return(null);
                }
                var list = new List <int>();
                var num4 = ((API.Gamedata.D2p.Map)Data).Cells.Count - 1;

                for (var i = 0; i < num4; i++)
                {
                    if ((((API.Gamedata.D2p.Map)Data).Cells[i].MapChangeData & num2) > 0 && NothingOnCell(i) && i != _account.Character.CellId)
                    {
                        list.Add(i);
                    }
                }
                var randomCellId = list[Randomize.GetRandomNumber(0, list.Count)];
                var move         = MoveToCell(randomCellId);
                if (move == null)
                {
                    throw new Exception("ICellMovement cannot be null");
                }
                return(new MapChangement(_account, move, neighbourId));
            }
        }
Beispiel #3
0
        public IMapChangement ChangeMap(MapDirectionEnum direction, int cellID = -1)
        {
            var neighbourId = -1;
            var num2        = -1;

            switch (direction)
            {
            case MapDirectionEnum.North:
                neighbourId = ((API.Gamedata.D2p.Map)Data).TopNeighbourId;
                num2        = 64;
                break;

            case MapDirectionEnum.South:
                neighbourId = ((API.Gamedata.D2p.Map)Data).BottomNeighbourId;
                num2        = 4;
                break;

            case MapDirectionEnum.East:
                neighbourId = ((API.Gamedata.D2p.Map)Data).RightNeighbourId;
                num2        = 1;
                break;

            case MapDirectionEnum.West:
                neighbourId = ((API.Gamedata.D2p.Map)Data).LeftNeighbourId;
                num2        = 16;
                break;
            }

            if (num2 == -1 || neighbourId < 0)
            {
                return(null);
            }
            if (cellID == -1)
            {
                var list = new List <int>();
                var num4 = ((API.Gamedata.D2p.Map)Data).Cells.Count - 1;

                for (var i = 0; i < num4; i++)
                {
                    if ((((API.Gamedata.D2p.Map)Data).Cells[i].MapChangeData & num2) > 0 && NothingOnCell(i))
                    {
                        list.Add(i);
                    }
                }
                cellID = list[Randomize.GetRandomNumber(0, list.Count)];
            }
            var move = MoveToCell(cellID);

            return(new MapChangement(_account, move, neighbourId));
        }
Beispiel #4
0
        public void ChangeMapButton(MapDirectionEnum direction)
        {
            if (Data is null)
            {
                Logger.Default.Log($"Bot currently not running", LogMessageType.Error);
            }
            if (WaitingForMapChange)
            {
                return;
            }
            WaitingForMapChange = true;
            IMapChangement mapChangement = ChangeMap(direction);

            mapChangement.ChangementFinished += MapChangement_ChangementFinished;
            mapChangement.PerformChangement();
        }
Beispiel #5
0
        public IMapChangement ChangeMap(MapDirectionEnum direction)
        {
            IMapChangement toReturn    = null;
            var            neighbourId = -1;
            var            num2        = -1;

            if (direction == MapDirectionEnum.North)
            {
                neighbourId = ((API.Gamedata.D2p.Map)Data).TopNeighbourId;
                num2        = 64;
            }
            else if (direction == MapDirectionEnum.South)
            {
                neighbourId = ((API.Gamedata.D2p.Map)Data).BottomNeighbourId;
                num2        = 4;
            }
            else if (direction == MapDirectionEnum.East)
            {
                neighbourId = ((API.Gamedata.D2p.Map)Data).RightNeighbourId;
                num2        = 1;
            }
            else if (direction == MapDirectionEnum.West)
            {
                neighbourId = ((API.Gamedata.D2p.Map)Data).LeftNeighbourId;
                num2        = 16;
            }

            if (num2 != -1 && neighbourId >= 0)
            {
                var list = new List <int>();
                var num4 = ((API.Gamedata.D2p.Map)Data).Cells.Count - 1;

                for (var i = 0; i < num4; i++)
                {
                    if ((((API.Gamedata.D2p.Map)Data).Cells[i].MapChangeData & num2) > 0 && NothingOnCell(i))
                    {
                        list.Add(i);
                    }
                }
                var randomCellId = list[Randomize.GetRandomNumber(0, list.Count)];
                var move         = MoveToCell(randomCellId);
                toReturn = new MapChangement(_account, move, neighbourId, _account.Character.CellId);
                return(toReturn);
            }
            return(toReturn);
        }