Пример #1
0
    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);
    }
Пример #2
0
    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);
        }
    }
Пример #3
0
        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);
        }
Пример #4
0
 // 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);
     }
 }
Пример #5
0
 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);
     }
 }
Пример #6
0
    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;
    }
Пример #7
0
        // Creates a Wall tile at the specified X/Y location
        private void CreateWall(Point location)
        {
            TileWall wall = new TileWall(location, "stone");

            _map.SetTerrain(wall);
        }
Пример #8
0
        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();
        }
Пример #9
0
 public bool HasWall(TileWall wall)
 {
     return((Walls & wall) == wall);
 }
Пример #10
0
 public void wallClicked(TileWall wall)
 {
     WallSelectDelegate?.Invoke(this, wall);
 }