public bool isTileValid(GameTile tile) { bool atLeastOneDoor = false; foreach (Vector2Int dir in tile.tileSides.Keys) { TileWall side = tile.tileSides[dir]; Vector2Int neighborPos = tile.gridPos + dir; if (grid.ContainsKey(neighborPos)) { if (side.isDoor()) { if (grid[neighborPos].tileSides[-dir].isDoor()) { atLeastOneDoor = true; } else { return(false); } } else { if (grid[neighborPos].tileSides[-dir].isDoor()) { return(false); } } } } return(atLeastOneDoor); }
public void rotate90CW(bool animateRotation = true) { if (rotating) { return; } Dictionary <Vector2Int, TileWall> newDict = new Dictionary <Vector2Int, TileWall>(); foreach (Vector2Int dir in tileSides.Keys) { TileWall tw = tileSides[dir]; Vector2Int rotDir = VectorUtils.rotate90CW(dir); tw.setDirection(rotDir); newDict.Add(rotDir, tw); } tileSides = newDict; RpcRotateWallDirections(); if (animateRotation) { StartCoroutine(RotateMe()); } else { transform.rotation = Quaternion.Euler(transform.eulerAngles + Vector3.up * 90); } }
public override void Populate() { var txtFileLines = File.ReadAllLines(Install.GetPath("walls.txt")); var typeNames = txtFileLines[1].Split(Separators); TileCategory category = null; for (int i = 2; i < txtFileLines.Length; i++) { var infos = txtFileLines[i].Split('\t'); if (infos[1] == "0") { category = new TileCategory(Int32.Parse(infos[2])) { Name = infos.Last() }; Categories.Add(category); } var style = new TileStyle(); category.AddStyle(style); style.Name = infos.Last(); style.Index = Int32.Parse(infos[1]); for (int j = 3; j < typeNames.Length - 2; j++) { if (infos[j] != "0") { var tile = new TileWall { Id = short.Parse(infos[j]) }; style.AddTile(tile); } } } TilesCategorySDKModule.Supp.PositionCheck(Categories); }
// Fills the map with walls private void FloodWalls() { for (int i = 0; i < _map.Tiles.Length; i++) { TileWall wall = new TileWall(Point.FromIndex(i, _map.Width), "stone"); _map.SetTerrain(wall); } }
private void wallSelected(GameTile tile, TileWall wall) { //Called via a Delegate on the TileWall class. Passes the data to the server for verification then passed back by RPC for visuals. if (myTurn) { CmdWallSelected(tile.gridPos, wall.direction); } }
private void RpcRotateWallDirections() { if (isServer) { return; } Dictionary <Vector2Int, TileWall> newDict = new Dictionary <Vector2Int, TileWall>(); foreach (Vector2Int dir in tileSides.Keys) { TileWall tw = tileSides[dir]; Vector2Int rotDir = VectorUtils.rotate90CW(dir); tw.setDirection(rotDir); newDict.Add(rotDir, tw); } tileSides = newDict; }
// Creates a Wall tile at the specified X/Y location private void CreateWall(Point location) { TileWall wall = new TileWall(location, "stone"); _map.SetTerrain(wall); }
private void ButtonAddTile_Click(object sender, RoutedEventArgs e) { var category = DataCategory.SelectedItem as TileCategory; var id = ListData.SelectedIndex; var style = DataStyle.SelectedItem as TileStyle; if (style == null) { style = new TileStyle(); category.AddStyle(style); } if (ComboEnum.SelectedItem == null) { return; } switch ((TilesInfo.Components.Enums.Type)ComboEnum.SelectedItem) { case Type.Wall: { var tile = new TileWall(); tile.Id = (short)id; style.AddTile(tile); break; } case Type.Roofs: { var tile = new TileRoof(); tile.Id = (short)id; style.AddTile(tile); break; } case Type.Floor: { var tile = new TileFloor(); tile.Id = (short)id; style.AddTile(tile); break; } case Type.Misc: { var tile = new TileMisc(); tile.Id = (short)id; style.AddTile(tile); break; } default: { var tile = new Tile(); tile.Id = (short)id; style.AddTile(tile); break; } } DataRefresh(); }
public bool HasWall(TileWall wall) { return((Walls & wall) == wall); }
public void wallClicked(TileWall wall) { WallSelectDelegate?.Invoke(this, wall); }