public VMPlacementError WallChangeValid(WallTile wall,Direction direction,bool checkUnused) { var placeFlags = (WallPlacementFlags)ObjectData[(int)VMStackObjectVariable.WallPlacementFlags]; bool diag = ((wall.Segments & (WallSegments.HorizontalDiag | WallSegments.VerticalDiag)) > 0); if (diag && (placeFlags & WallPlacementFlags.DiagonalAllowed) == 0) { return(VMPlacementError.CantBeThroughWall); //does not allow diagonal and one is present } else if (!diag && ((placeFlags & WallPlacementFlags.DiagonalRequired) > 0)) { return(VMPlacementError.MustBeOnDiagonal); //needs diagonal and one is not present } int rotate = (DirectionToWallOff(direction) + 1) % 4; int rotPart = RotateWallSegs(wall.Segments,rotate); int useRotPart = RotateWallSegs(wall.OccupiedWalls,rotate); if (((int)placeFlags & rotPart) != ((int)placeFlags & 15)) { return(VMPlacementError.MustBeAgainstWall); //walls required are not there in this configuration } //walls that we are attaching to must not be in use! if (checkUnused && ((int)placeFlags & useRotPart) > 0) { return(VMPlacementError.MustBeAgainstUnusedWall); } if (((int)placeFlags & (rotPart << 8)) > 0) { return(VMPlacementError.CantBeThroughWall); //walls not allowed are there in this configuration } return(VMPlacementError.Success); }
WallTile[] ResizeWalls(WallTile[] walls, int size) { if (size >= 64) { return(walls); } var result = new WallTile[size * size]; int iS = 0; int iD = 0; for (int y = 0; y < 64; y++) { if (y >= size) { return(result); } for (int x = 0; x < 64; x++) { if (x < size) { result[iD++] = walls[iS]; } iS++; } } return(result); }
void reset() { reportFree(); state = State.free; //targetObject = null; wallToMine = null; }
// TODO: move to a map generator class // Floor name is something like 1F, etc. private void GenerateMap(string floorName) { var mapData = MapGenerator.GenerateFloor(1, ScreenAndMapWidth, ScreenAndMapHeight); // Apply changes to our map var map = new ArrayMap <AbstractMapTile>(ScreenAndMapWidth, ScreenAndMapHeight); // Convert ArrayMap<Bool> to ArrayMap<MapTile> foreach (var tile in mapData.Map.Positions()) { AbstractMapTile mapTile; // Convert from boolean (true/false) to tiles if (mapData.Map[tile.X, tile.Y]) { mapTile = new FloorTile(); } else { mapTile = new WallTile(); } map[tile.X, tile.Y] = mapTile; } // Position player and stairs player.Position.X = mapData.PlayerPosition.X; player.Position.Y = mapData.PlayerPosition.Y; map[mapData.StairsDownPosition.X, mapData.StairsDownPosition.Y] = new StairsDownTile(); EventBus.Instance.Broadcast("Map changed", map); this.container.DrawFrame(0); // Initial draw without player moving }
public static void ParseWallsCSVFile() { string cwdPath = Directory.GetCurrentDirectory(); cwdPath = Directory.GetCurrentDirectory(); cwdPath = cwdPath.Replace(@"\bin\Debug\netcoreapp3.1", @"\Classes\Level\RoomCSV"); if (roomNumber == storage.undergroundRoomNumber) { cwdPath = Path.Combine(cwdPath, "walls16.csv"); } else { cwdPath = Path.Combine(cwdPath, "walls.csv"); } string[] lines = System.IO.File.ReadAllLines(cwdPath); lines = System.IO.File.ReadAllLines(cwdPath); Vector2 wallPos = new Vector2(0, 0); foreach (string line in lines) { string[] segments = line.Split(new string[] { "," }, StringSplitOptions.None); wallPos = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1])); WallTile wall; tiles.Add(wall = new WallTile(game, new TileSpriteFactory(game), wallPos)); wall.drawLocation = wallPos; } }
public void Deserialize(BinaryReader reader) { Width = reader.ReadInt32(); Height = reader.ReadInt32(); Stories = reader.ReadInt32(); var size = Width * Height; Walls = new WallTile[Stories][]; for (int l = 0; l < Stories; l++) { Walls[l] = new WallTile[size]; for (int i = 0; i < size; i++) { Walls[l][i] = WallTileSerializer.Deserialize(reader); } } Floors = new FloorTile[Stories][]; for (int l = 0; l < Stories; l++) { Floors[l] = new FloorTile[size]; for (int i = 0; i < size; i++) { Floors[l][i] = new FloorTile { Pattern = reader.ReadUInt16() } } ; } WallsDirty = reader.ReadBoolean(); FloorsDirty = reader.ReadBoolean(); }
private static ITileTypeFactory SetUp() { var wallTile = new WallTile(); var emptyTile = new EmptyTile(); var pelletTile = new PelletTile(); return(new TileTypeFactory(wallTile, emptyTile, pelletTile)); }
public static void SerializeInto(WallTile wall, BinaryWriter writer) { writer.Write((byte)wall.Segments); writer.Write(wall.TopLeftPattern); writer.Write(wall.TopRightPattern); writer.Write(wall.BottomLeftPattern); writer.Write(wall.BottomRightPattern); writer.Write(wall.TopLeftStyle); writer.Write(wall.TopRightStyle); }
public void addMiningOrder(MiningOrder miningOrder) { WallTile wall = miningOrder.target; if (wall.inMiningQueue) { Debug.Log("Already in mining queue"); return; } wall.inMiningQueue = true; miningOrders.Add(miningOrder); }
public static WallTile Deserialize(BinaryReader reader) { var result = new WallTile(); result.Segments = (WallSegments)reader.ReadByte(); result.TopLeftPattern = reader.ReadUInt16(); result.TopRightPattern = reader.ReadUInt16(); result.BottomLeftPattern = reader.ReadUInt16(); result.BottomRightPattern = reader.ReadUInt16(); result.TopLeftStyle = reader.ReadUInt16(); result.TopRightStyle = reader.ReadUInt16(); return(result); }
public void mineTile(WallTile target, UnityEngine.AI.NavMeshPath path) { if (state != State.free) { throw new Exception("mineTile: Worker is not free to mine! Make sure to check if you should place a mining order!"); } state = State.mining; navAgent.path = path; Debug.Log("path is set! my name: " + this.name); wallToMine = target; gameControl.decFreeWorkerCount(); }
WallTile SwapWallTile(int x, int y) { Vector2Int pos = new Vector2Int(x, y); WallTile wallTile = Instantiate(tileWallGo, new Vector3(pos.x, pos.y), Quaternion.identity).GetComponent <WallTile>(); wallTile.pos = new Vector3Int(pos.x, pos.y, 0); if (map [pos.x, pos.y] != null) { Destroy(map [pos.x, pos.y].gameObject); } map [pos.x, pos.y] = wallTile; return(wallTile); }
void AdjustSpritesAndHitboxes() { for (int x = 0; x < WIDTH; x++) { for (int y = 0; y < HEIGHT; y++) { GameObject currTile = tiles[x, y]; if (currTile != null && currTile.tag == "Block") { WallTile wallScript = currTile.GetComponent <WallTile>(); wallScript.player = player; wallScript.AdjustSpriteAndHitbox(tiles, new Vector2(x, y)); } } } }
WallTile GenerateWall(Vector2Int pos) { WallTile wallTile = SwapWallTile(pos.x, pos.y); if (wallTile.pos.y == 0) { wallTile.SetSprite(WallPositions.Left); SwapWallTile(wallTile.pos.x + wallTile.width - 1, wallTile.pos.y).SetSprite(WallPositions.Right); } else { wallTile.SetSprite(WallPositions.BottomLeft); SwapWallTile(wallTile.pos.x + wallTile.width - 1, wallTile.pos.y).SetSprite(WallPositions.BottomRight); } SwapWallTile(wallTile.pos.x + wallTile.width - 1, wallTile.pos.y + wallTile.height - 1).SetSprite(WallPositions.UpperRight); SwapWallTile(wallTile.pos.x, wallTile.pos.y + wallTile.height - 1).SetSprite(WallPositions.UpperLeft); for (int i = 1; i < wallTile.width - 1; i++) { if (wallTile.pos.y == 0) { SwapWallTile(wallTile.pos.x + i, wallTile.pos.y).SetSprite(WallPositions.Center); } else { SwapWallTile(wallTile.pos.x + i, wallTile.pos.y).SetSprite(WallPositions.Bottom); } SwapWallTile(wallTile.pos.x + i, wallTile.pos.y + wallTile.height - 1).SetSprite(WallPositions.Upper); } for (int i = 1; i < wallTile.height - 1; i++) { SwapWallTile(wallTile.pos.x, wallTile.pos.y + i).SetSprite(WallPositions.Left); SwapWallTile(wallTile.pos.x + wallTile.width - 1, wallTile.pos.y + i).SetSprite(WallPositions.Right); } for (int x = 1; x < wallTile.width - 1; x++) { for (int y = 1; y < wallTile.height - 1; y++) { SwapWallTile(x + wallTile.pos.x, y + wallTile.pos.y).SetSprite(WallPositions.Center); } } return(wallTile); }
public void SwitchTile(Vector2 mousepos, TileType tp, TextureType tt, TileObject to, string asset) { //check selected tile Vector2 vpos = GridPosition(mousepos + new Vector2(0, cellHeight / 2)); Point pos = new Point((int)vpos.X, (int)vpos.Y); Tile tile = Get(pos.X, pos.Y) as Tile; if (tile != null) { //change tile if (tile.TileObject == to) { tile.ChangeTile(tp, tt, asset); } else { //replace tile Remove(tile.Id, pos.X, pos.Y); Tile newtile; switch (to) { case TileObject.Tile: newtile = new Tile(pos, asset, tp, tt); break; case TileObject.WallTile: newtile = new WallTile(pos, asset, tp, tt); break; case TileObject.TreeTile: newtile = new TreeTile(pos, asset, tp, tt); break; case TileObject.GrassTile: newtile = new GrassTile(pos, asset, tp, tt); break; default: newtile = new Tile(pos); break; } Add(newtile, pos.X, pos.Y); newtile.ChangeTile(tp, tt, asset); } } }
public void Deserialize(BinaryReader reader) { Width = reader.ReadInt32(); Height = reader.ReadInt32(); Stories = reader.ReadInt32(); Terrain = new VMArchitectureTerrain(Width, Height); Terrain.Version = Version; if (Version > 6) { Terrain.Deserialize(reader); } var size = Width * Height; Walls = new WallTile[Stories][]; for (int l = 0; l < Stories; l++) { Walls[l] = new WallTile[size]; for (int i = 0; i < size; i++) { Walls[l][i] = WallTileSerializer.Deserialize(reader); } } Floors = new FloorTile[Stories][]; for (int l = 0; l < Stories; l++) { Floors[l] = new FloorTile[size]; for (int i = 0; i < size; i++) { Floors[l][i] = new FloorTile { Pattern = reader.ReadUInt16() } } ; } WallsDirty = reader.ReadBoolean(); FloorsDirty = reader.ReadBoolean(); if (Version > 13) { RoofStyle = reader.ReadUInt32(); RoofPitch = reader.ReadSingle(); } }
public void AddingPlayerToUnpassableSpaceThrows() { // arrange var wallTile = new WallTile(new Position(0, 0)); var frame = new Frame(tiles: new List <Tile> { wallTile }); var player = DefaultPlayer; // ReSharper disable once NotResolvedInText var expected = new ArgumentOutOfRangeException("player"); // act var actual = Assert.Throws <ArgumentOutOfRangeException>(() => Engine.AddPlayer(frame, player)); // assert Assert.AreEqual(expected.ParamName, actual.ParamName); }
public void MovePlayerIntoWallYieldsNoMovement() { // arrange var wallTile = new WallTile(new Position(0, 1)); var frame = new Frame( players: new List <Player> { DefaultPlayer }, tiles: new List <Tile> { wallTile }); const Direction direction = Direction.South; var expected = new Position(0, 0); // act / assert MovePlayerTester(frame, DefaultPlayer, direction, expected); }
public bool CheckWallValid(LotTilePos pos, WallTile wall) { var objs = SetToNextCache.GetObjectsAt(pos); if (objs == null) { return(true); } foreach (var obj in objs) { if (obj.WallChangeValid(wall, obj.Direction, false) != VMPlacementError.Success) { return(false); } } return(true); }
public bool CheckWallValid(LotTilePos pos, WallTile wall) { if (pos.Level < 1 || pos.Level > ObjectsAt.Count || !ObjectsAt[pos.Level - 1].ContainsKey(pos.TileID)) { return(true); } var objs = ObjectsAt[pos.Level - 1][pos.TileID]; foreach (var id in objs) { var obj = VM.GetObjectById(id); if (obj.WallChangeValid(wall, obj.Direction, false) != VMPlacementError.Success) { return(false); } } return(true); }
public IMap GenerateMap(int width, int height) { IMap map = new DefaultMap(width, height); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (x <= 1 || x >= width - 2 || y <= 1 || y >= height - 2) { map[x, y] = new WallTile(); } } } map.SetUpTileNeigbours(); return(map); }
void Execute() { UnityEngine.Object[] allSprites = AssetDatabase.LoadAllAssetRepresentationsAtPath( "Assets/sprites/" + spriteName + ".png"); Sprite[] sprites = allSprites.Cast <Sprite>().ToArray(); WallTile wt = obj.GetComponent <WallTile>(); if (wt != null) { wt.sprites = sprites; } Number num = obj.GetComponent <Number>(); if (num != null) { num.sprites = sprites; } }
public WallTile[] DecodeWalls(byte[] data) { int j = 0; var result = new WallTile[data.Length / 8]; for (int i = 0; i < data.Length; i += 8) { var tile = new WallTile { Segments = (WallSegments)data[i], TopLeftStyle = data[i + 2], TopRightStyle = data[i + 3], TopLeftPattern = data[i + 4], TopRightPattern = data[i + 5], BottomLeftPattern = data[i + 6], BottomRightPattern = data[i + 7] }; if ((tile.Segments & WallSegments.AnyDiag) == 0) { if (!ValidWallStyles.Contains(tile.TopLeftStyle)) { tile.TopLeftStyle = 1; } if (!ValidWallStyles.Contains(tile.TopRightStyle)) { tile.TopRightStyle = 1; } if ((tile.Segments & WallSegments.TopLeft) == 0) { tile.TopLeftStyle = 0; } if ((tile.Segments & WallSegments.TopRight) == 0) { tile.TopRightStyle = 0; } } result[j++] = tile; } return(result); }
public WallTile[] DecodeAdvWalls(byte[] data) { int j = 0; var result = new WallTile[data.Length / 14]; for (int i = 0; i < data.Length; i += 14) { var tile = new WallTile { Segments = (WallSegments)data[i], TopLeftStyle = (ushort)(data[i + 2] | (data[i + 3] << 8)), TopRightStyle = (ushort)(data[i + 4] | (data[i + 5] << 8)), TopLeftPattern = (ushort)(data[i + 6] | (data[i + 7] << 8)), TopRightPattern = (ushort)(data[i + 8] | (data[i + 9] << 8)), BottomLeftPattern = (ushort)(data[i + 10] | (data[i + 11] << 8)), BottomRightPattern = (ushort)(data[i + 12] | (data[i + 13] << 8)) }; if ((tile.Segments & WallSegments.AnyDiag) == 0) { if (!ValidWallStyles.Contains(tile.TopLeftStyle)) { tile.TopLeftStyle = 1; } if (!ValidWallStyles.Contains(tile.TopRightStyle)) { tile.TopRightStyle = 1; } if ((tile.Segments & WallSegments.TopLeft) == 0) { tile.TopLeftStyle = 0; } if ((tile.Segments & WallSegments.TopRight) == 0) { tile.TopRightStyle = 0; } } result[j++] = tile; } return(result); }
public void SetWall(short tileX, short tileY, sbyte level, WallTile wall) { var off = GetOffset(tileX, tileY); WallsAt[level - 1].Remove(off); if (wall.Segments > 0) { Walls[level - 1][off] = wall; WallsAt[level - 1].Add(off); } else { Walls[level - 1][off] = new WallTile(); } if (RealMode) { WallsDirty = true; } Redraw = true; }
public void Init() { northWall = Instantiate(wallTileTemplate, northWallPlace.transform.position, northWallPlace.transform.rotation, transform).GetComponent <WallTile>(); southWall = Instantiate(wallTileTemplate, southWallPlace.transform.position, southWallPlace.transform.rotation, transform).GetComponent <WallTile>(); eastWall = Instantiate(wallTileTemplate, eastWallPlace.transform.position, eastWallPlace.transform.rotation, transform).GetComponent <WallTile>(); westWall = Instantiate(wallTileTemplate, westWallPlace.transform.position, westWallPlace.transform.rotation, transform).GetComponent <WallTile>(); walls = new Dictionary <string, WallTile> (); walls ["north"] = northWall; walls ["south"] = southWall; walls ["east"] = eastWall; walls ["west"] = westWall; Quaternion stairsRotation = Quaternion.identity; if (isStairs) { if (stairsDirectionName == "north") { stairsRotation = Quaternion.identity; } else if (stairsDirectionName == "south") { stairsRotation = Quaternion.Euler(new Vector3(0, 180, 0)); } else if (stairsDirectionName == "west") { stairsRotation = Quaternion.Euler(new Vector3(0, 90, 0)); } else if (stairsDirectionName == "east") { stairsRotation = Quaternion.Euler(new Vector3(0, -90, 0)); } Instantiate(stairsTemplate, transform.position, stairsRotation, transform); } }
void DetectClick() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Camera camera = Camera.main; Ray ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { GameObject objectHit = hit.transform.gameObject; Debug.Log("hit" + hit.transform.position.ToString()); WallTile wall = objectHit.GetComponent <WallTile>(); if (wall) { Debug.Log("is wall tile"); if (wall.isMinable) { gameControl.addMiningOrder(new MiningOrder(wall)); } } } } }
public void Deserialize(BinaryReader reader) { Width = reader.ReadInt32(); Height = reader.ReadInt32(); Stories = reader.ReadInt32(); Terrain = new VMArchitectureTerrain(Width, Height); Terrain.Version = Version; if (Version > 6) { Terrain.Deserialize(reader); } var size = Width * Height; Walls = new WallTile[Stories][]; for (int l = 0; l < Stories; l++) { Walls[l] = new WallTile[size]; for (int i = 0; i < size; i++) { Walls[l][i] = WallTileSerializer.Deserialize(reader); } } Floors = new FloorTile[Stories][]; for (int l = 0; l < Stories; l++) { Floors[l] = new FloorTile[size]; for (int i = 0; i < size; i++) { Floors[l][i] = new FloorTile { Pattern = reader.ReadUInt16() } } ; } WallsDirty = reader.ReadBoolean(); FloorsDirty = reader.ReadBoolean(); if (Version > 13) { RoofStyle = reader.ReadUInt32(); RoofPitch = reader.ReadSingle(); } if (Version > 21) { var hasIDMap = reader.ReadBoolean(); if (hasIDMap) { IDMap = new VMResourceIDMarshal(); IDMap.Deserialize(reader); } } if (Version > 22) { var hasFineBuild = reader.ReadBoolean(); if (hasFineBuild) { FineBuildableArea = reader.ReadBytes(size).Select(x => x > 0).ToArray(); } } if (Version > 25) { BuildBuyEnabled = reader.ReadBoolean(); } }
public void Rotate(int notches) { if (notches == 0) { return; } var newXDir = XForward[notches]; var newYDir = XForward[(notches + 1) % 4]; var offset = new Point(Offset[notches].X * (Arch.Width - 2), Offset[notches].Y * (Arch.Height - 2)); for (int i = 0; i < Arch.Stories; i++) { int index = 0; var walls = Arch.Walls[i]; var floors = Arch.Floors[i]; var newWalls = new WallTile[walls.Length]; var newFloors = new FloorTile[floors.Length]; for (int y = 0; y < Arch.Height; y++) { for (int x = 0; x < Arch.Width; x++) { var newX = x * newXDir.X + y * newYDir.X + offset.X; var newY = x * newXDir.Y + y * newYDir.Y + offset.Y; if (newX < 0 || newY < 0) { index++; continue; } var newIndex = newY * Arch.Width + newX; newWalls[newIndex] = RotateWall(notches, walls[index], (short)x, (short)y, (sbyte)(i + 1)); newFloors[newIndex] = floors[index]; index++; } } Arch.Walls[i] = newWalls; Arch.Floors[i] = newFloors; } offset = new Point(Offset[notches].X * ((Arch.Width - 1) * 16), Offset[notches].Y * ((Arch.Height - 1) * 16)); for (int i = 0; i < Ents.Length; i++) { var oldPos = Ents[i].Position; if (oldPos != LotTilePos.OUT_OF_WORLD) { Ents[i].Position = new LotTilePos( (short)(oldPos.x * newXDir.X + oldPos.y * newYDir.X + offset.X), (short)(oldPos.x * newXDir.Y + oldPos.y * newYDir.Y + offset.Y), oldPos.Level); if (Ents[i].Position.x < 0 || Ents[i].Position.y < 0) { Ents[i].Position = LotTilePos.OUT_OF_WORLD; } } if (Ents[i] is VMGameObjectMarshal) { var m = (VMGameObjectMarshal)Ents[i]; m.Direction = RotateDirection(m.Direction, notches); } } }
private WallTile RotateWall(int rotN, WallTile input, short x, short y, sbyte level) { var output = new WallTile(); if (rotN != 0) { if (input.Segments == WallSegments.HorizontalDiag) { output.Segments = ((rotN % 2) == 0) ? WallSegments.HorizontalDiag : WallSegments.VerticalDiag; output.TopRightStyle = input.TopRightStyle; switch (rotN) { case 1: output.BottomRightPattern = input.BottomLeftPattern; output.BottomLeftPattern = input.BottomRightPattern; output.TopLeftStyle = input.TopLeftPattern; output.TopLeftPattern = input.TopLeftStyle; break; case 2: output.BottomRightPattern = input.BottomLeftPattern; //flip sides output.BottomLeftPattern = input.BottomRightPattern; output.TopLeftStyle = input.TopLeftPattern; output.TopLeftPattern = input.TopLeftStyle; break; case 3: output.BottomRightPattern = input.BottomRightPattern; output.BottomLeftPattern = input.BottomLeftPattern; output.TopLeftStyle = input.TopLeftStyle; output.TopLeftPattern = input.TopLeftPattern; break; } } else if (input.Segments == WallSegments.VerticalDiag) { output.Segments = ((rotN % 2) == 0) ? WallSegments.VerticalDiag : WallSegments.HorizontalDiag; output.TopRightStyle = input.TopRightStyle; switch (rotN) { case 1: output.BottomRightPattern = input.BottomRightPattern; output.BottomLeftPattern = input.BottomLeftPattern; output.TopLeftStyle = input.TopLeftStyle; output.TopLeftPattern = input.TopLeftPattern; break; case 2: output.BottomRightPattern = input.BottomLeftPattern; //flip sides output.BottomLeftPattern = input.BottomRightPattern; output.TopLeftStyle = input.TopLeftPattern; output.TopLeftPattern = input.TopLeftStyle; break; case 3: output.BottomRightPattern = input.BottomLeftPattern; output.BottomLeftPattern = input.BottomRightPattern; output.TopLeftStyle = input.TopLeftPattern; output.TopLeftPattern = input.TopLeftStyle; break; } } else { switch (rotN) { case 1: if ((input.Segments & WallSegments.TopLeft) > 0) { output.Segments |= WallSegments.TopRight; } if ((input.Segments & WallSegments.TopRight) > 0) { output.Segments |= WallSegments.BottomRight; } if ((input.Segments & WallSegments.BottomRight) > 0) { output.Segments |= WallSegments.BottomLeft; } if ((input.Segments & WallSegments.BottomLeft) > 0) { output.Segments |= WallSegments.TopLeft; } output.TopLeftPattern = input.BottomLeftPattern; output.TopRightPattern = input.TopLeftPattern; output.BottomRightPattern = input.TopRightPattern; output.BottomLeftPattern = input.BottomRightPattern; if (y + 1 < Arch.Height) { var newLeft = Arch.Walls[level - 1][GetOffset(x, y + 1)]; output.TopLeftStyle = newLeft.TopRightStyle; output.ObjSetTLStyle = newLeft.ObjSetTRStyle; output.TopLeftDoor = newLeft.TopRightDoor; } output.TopRightStyle = input.TopLeftStyle; output.ObjSetTRStyle = input.ObjSetTLStyle; output.TopRightDoor = input.TopLeftDoor; break; case 2: if ((input.Segments & WallSegments.TopLeft) > 0) { output.Segments |= WallSegments.BottomRight; } if ((input.Segments & WallSegments.TopRight) > 0) { output.Segments |= WallSegments.BottomLeft; } if ((input.Segments & WallSegments.BottomRight) > 0) { output.Segments |= WallSegments.TopLeft; } if ((input.Segments & WallSegments.BottomLeft) > 0) { output.Segments |= WallSegments.TopRight; } output.TopLeftPattern = input.BottomRightPattern; output.TopRightPattern = input.BottomLeftPattern; output.BottomRightPattern = input.TopLeftPattern; output.BottomLeftPattern = input.TopRightPattern; if (y + 1 < Arch.Height) { var newRight = Arch.Walls[level - 1][GetOffset(x, y + 1)]; output.TopRightStyle = newRight.TopRightStyle; output.ObjSetTRStyle = newRight.ObjSetTRStyle; output.TopRightDoor = newRight.TopRightDoor; } if (x + 1 < Arch.Width) { var newLeft = Arch.Walls[level - 1][GetOffset(x + 1, y)]; output.TopLeftStyle = newLeft.TopLeftStyle; output.ObjSetTLStyle = newLeft.ObjSetTLStyle; output.TopLeftDoor = newLeft.TopLeftDoor; } break; case 3: if ((input.Segments & WallSegments.TopLeft) > 0) { output.Segments |= WallSegments.BottomLeft; } if ((input.Segments & WallSegments.TopRight) > 0) { output.Segments |= WallSegments.TopLeft; } if ((input.Segments & WallSegments.BottomRight) > 0) { output.Segments |= WallSegments.TopRight; } if ((input.Segments & WallSegments.BottomLeft) > 0) { output.Segments |= WallSegments.BottomRight; } output.TopLeftPattern = input.TopRightPattern; output.TopRightPattern = input.BottomRightPattern; output.BottomRightPattern = input.BottomLeftPattern; output.BottomLeftPattern = input.TopLeftPattern; output.TopLeftStyle = input.TopRightStyle; output.TopLeftDoor = input.TopRightDoor; output.ObjSetTLStyle = input.ObjSetTRStyle; if (x + 1 < Arch.Width) { var newRight = Arch.Walls[level - 1][GetOffset(x + 1, y)]; output.TopRightStyle = newRight.TopLeftStyle; output.ObjSetTRStyle = newRight.ObjSetTLStyle; output.TopRightDoor = newRight.TopLeftDoor; } break; } } } else { output = input; } return(output); }
public void finalize(int floor) { tileMap = new Tile[mapX + 2, mapY + 2]; for (int x = 1; x < mapX + 1; x++) { for (int y = 1; y < mapY + 1; y++) { Tile t; switch (map[x - 1, y - 1].tile) { case Node.tileType.floor: t = new FloorTile(x, y); break; case Node.tileType.wall: t = new WallTile(x, y); break; default: t = null; break; } tileMap[x, y] = t; } } for (int x = 0; x < mapX + 2; x++) { tileMap[x, 0] = new WallTile(x, 0); tileMap[x, mapY + 1] = new WallTile(x, mapY + 1); } for (int y = 0; y < mapY + 2; y++) { tileMap[0, y] = new WallTile(0, y); tileMap[mapY + 1, y] = new WallTile(mapY + 1, y); } mapX += 2; mapY += 2; foreach (Tile t in tileMap) { if (t.GetType() == typeof(FloorTile)) { emptyTiles.Add(t); notPopulatedTiles.Add(t); } if (Directions8.Where(d => inMap(t.x + d.X, t.y + d.Y) && tileMap[t.x + d.X, t.y + d.Y].GetType() == typeof(WallTile)).ToList().Count == Directions8.Where(d => inMap(t.x + d.X, t.y + d.Y)).Count()) t.explorable = false; } if(floor != 0) { for (int i = 0; i < 3; i++) { int rand = r.Next(emptyTiles.Count); tileMap[emptyTiles[rand].x, emptyTiles[rand].y].DestroyNow(); tileMap[emptyTiles[rand].x, emptyTiles[rand].y] = new UpStairTile(emptyTiles[rand].x, emptyTiles[rand].y, i); emptyTiles.RemoveAt(rand); notPopulatedTiles.RemoveAt(rand); } } if (floor != GameController.saveGame.maxFloors - 1) { for (int i = 0; i < 3; i++) { int rand = r.Next(emptyTiles.Count); tileMap[emptyTiles[rand].x, emptyTiles[rand].y].DestroyNow(); tileMap[emptyTiles[rand].x, emptyTiles[rand].y] = new DownStairTile(emptyTiles[rand].x, emptyTiles[rand].y, i); emptyTiles.RemoveAt(rand); notPopulatedTiles.RemoveAt(rand); } } map = null; }