private WorldBlock[, ,] GetEmptyWorld(int sizeX, int sizeY, Block fillBlock, Block borderBlock) { var blockArray = new WorldBlock[2, sizeX, sizeY]; int maxX = sizeX - 1; int maxY = sizeY - 1; // Fill the middle with GravityNothing blocks for (var l = Layer.Background; l >= Layer.Foreground; l += -1) for (int x = 0; x <= maxX; x++) for (int y = 0; y <= maxY; y++) NewBlock(blockArray, l, x, y, fillBlock); // Border drawing for (int y = 0; y <= maxY; y++) { blockArray[0, 0, y].SetBlock(borderBlock); blockArray[0, maxX, y].SetBlock(borderBlock); } for (int x = 0; x <= maxX; x++) { blockArray[0, x, 0].SetBlock(borderBlock); blockArray[0, x, maxY].SetBlock(borderBlock); } return blockArray; }
private void RaisePlaceWorld(WorldBlock b, WorldBlock oldB, int userId = -1) { Player p; this._playerService.TryGetPlayer(userId, out p); this.SynchronizePlatform.Do(() => this.Events.Raise(new PlaceWorldEvent(b, oldB, p))); }
internal PlaceWorldEvent(WorldBlock worldBlock, WorldBlock oldWorldBlock, Player player) { this.OldWorldBlock = oldWorldBlock; this.WorldBlock = worldBlock; this.Player = player; }
private void NewBlock(WorldBlock[,,] blockArray, Layer layer, int x, int y, Block block) { blockArray[(int)layer, x, y] = new WorldBlock(this.MetadataPlatform, layer, x, y, block); }
private IEnumerable<WorldBlock> GetBlocks(int l, byte[] byteArrayX, byte[] byteArrayY, WorldBlock[,,] worldArray) { for (int i = 0; i <= byteArrayX.Length - 1; i += 2) { int x = byteArrayX[i] * 256 + byteArrayX[i + 1]; int y = byteArrayY[i] * 256 + byteArrayY[i + 1]; yield return worldArray[l, x, y]; } }