Ejemplo n.º 1
0
        private List<Map> OnLoadMaps(BotBitsClient botBits, ISignFormat signFormat, IPositionMapper positionMapper)
        {
            var maps = new List<Map>();
            var blocks = Blocks.Of(botBits);

            for (var x = 1; x < blocks.Width - MapWidth; x++)
            {
                for (var y = 1; y < blocks.Height - MapHeight; y++)
                {
                    var block = blocks.At(x, y).Foreground.Block;

                    if (block.Type != ForegroundType.Sign)
                        continue;

                    MapData mapData;
                    if (!signFormat.TryGetMapData(block.Text, Room.Of(botBits).Owner, out mapData))
                        continue;

                    maps.Add(new Map(blocks, positionMapper.GetMapRectangle(new Point(x, y), MapWidth, MapHeight),
                        mapData.Name, mapData.Creators));
                }
            }

            return maps;
        }
Ejemplo n.º 2
0
        private List <Map> OnLoadMaps(BotBitsClient botBits, ISignFormat signFormat, IPositionMapper positionMapper)
        {
            var maps   = new List <Map>();
            var blocks = Blocks.Of(botBits);

            for (var x = 1; x < blocks.Width - MapWidth; x++)
            {
                for (var y = 1; y < blocks.Height - MapHeight; y++)
                {
                    var block = blocks.At(x, y).Foreground.Block;

                    if (block.Type != ForegroundType.Sign)
                    {
                        continue;
                    }

                    MapData mapData;
                    if (!signFormat.TryGetMapData(block.Text, Room.Of(botBits).Owner, out mapData))
                    {
                        continue;
                    }

                    maps.Add(new Map(blocks, positionMapper.GetMapRectangle(new Point(x, y), MapWidth, MapHeight),
                                     mapData.Name, mapData.Creators));
                }
            }

            return(maps);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Asynchronously loads maps from world with the specified <see cref="worldId" />.
        /// </summary>
        /// <param name="worldId">World identifier.</param>
        /// <param name="signFormat"><see cref="MapData" /> reader.</param>
        /// <param name="positionMapper">The position mapper used to get map rectangle.</param>
        /// <returns>The loaded maps.</returns>
        public async Task<List<Map>> LoadMapsAsync(string worldId, ISignFormat signFormat, IPositionMapper positionMapper)
        {
            var botBits = new BotBitsClient();

            await Login.Of(botBits).AsGuestAsync().CreateJoinRoomAsync(worldId);
            Console.WriteLine("Connected");

            var connectResult = new TaskCompletionSource<bool>();
            var cts = new CancellationTokenSource();

            // Wait for init or info event
            // Only one of them is sent depending on visibility of the world
            WaitForInfoEvent(botBits, connectResult, cts.Token);
            WaitForInitEvent(botBits, connectResult, cts.Token);

            await connectResult.Task;
            cts.Cancel();

            var maps = OnLoadMaps(botBits, signFormat, positionMapper);

            botBits.Dispose();

            return maps;
        }
 public SpiderMapper(IPositionMapper positionMapper, IInstructionMapper instructionMapper)
 {
     _positionMapper    = positionMapper;
     _instructionMapper = instructionMapper;
 }
 public TextFileOutputWriter(IFileSystem fileSystem, IPositionMapper positionMapper)
 {
     _fileSystem     = fileSystem;
     _positionMapper = positionMapper;
 }
Ejemplo n.º 6
0
 public EmployeeRepository(IEmployeeMapper employeeMapper, IPositionMapper positionMapper, IBranchMapper branchMapper) : base()
 {
     this.employeeMapper = employeeMapper;
     this.positionMapper = positionMapper;
     this.branchMapper   = branchMapper;
 }
Ejemplo n.º 7
0
        /// <summary>
        ///     Asynchronously loads maps from world with the specified <see cref="worldId" />.
        /// </summary>
        /// <param name="worldId">World identifier.</param>
        /// <param name="signFormat"><see cref="MapData" /> reader.</param>
        /// <param name="positionMapper">The position mapper used to get map rectangle.</param>
        /// <returns>The loaded maps.</returns>
        public async Task <List <Map> > LoadMapsAsync(string worldId, ISignFormat signFormat, IPositionMapper positionMapper)
        {
            var botBits = new BotBitsClient();

            await Login.Of(botBits).AsGuestAsync().CreateJoinRoomAsync(worldId);

            Console.WriteLine("Connected");

            var connectResult = new TaskCompletionSource <bool>();
            var cts           = new CancellationTokenSource();

            // Wait for init or info event
            // Only one of them is sent depending on visibility of the world
            WaitForInfoEvent(botBits, connectResult, cts.Token);
            WaitForInitEvent(botBits, connectResult, cts.Token);

            await connectResult.Task;

            cts.Cancel();

            var maps = OnLoadMaps(botBits, signFormat, positionMapper);

            botBits.Dispose();

            return(maps);
        }
Ejemplo n.º 8
0
 public List <Map> LoadMaps(string worldId, ISignFormat signFormat, IPositionMapper positionMapper)
 {
     return(LoadMapsAsync(worldId, signFormat, positionMapper).Result);
 }
Ejemplo n.º 9
0
 public List<Map> LoadMaps(string worldId, ISignFormat signFormat, IPositionMapper positionMapper)
 {
     return LoadMapsAsync(worldId, signFormat, positionMapper).Result;
 }
Ejemplo n.º 10
0
 public PositionRepository(IPositionMapper positionMapper, IEmployeeMapper employeeMapper)
 {
     this.employeeMapper = employeeMapper;
     this.positionMapper = positionMapper;
 }
 public EmployeeMapper(IPositionMapper positionMapper)
 {
     this.positionMapper = positionMapper;
 }