コード例 #1
0
    protected void CheckNeighbours()
    {
        if (_grid == null)
        {
            _grid = FindObjectOfType <LevelGrid>();
        }

        if (!_grid.CheckRoomExistence(new Vector2Int(_position.x, _position.y + 1)) && _upDoor != null)
        {
            _upDoor.RemplaceByWall();
        }

        if (!_grid.CheckRoomExistence(new Vector2Int(_position.x - 1, _position.y)) && _leftDoor != null)
        {
            _leftDoor.RemplaceByWall();
        }

        if (!_grid.CheckRoomExistence(new Vector2Int(_position.x, _position.y - 1)) && _downDoor != null)
        {
            _downDoor.RemplaceByWall();
        }

        if (!_grid.CheckRoomExistence(new Vector2Int(_position.x + 1, _position.y)) && _rightDoor != null)
        {
            _rightDoor.RemplaceByWall();
        }
    }