Ejemplo n.º 1
0
 public Creator(RoomPattern roomPattern)
 {
     this.roomPattern = roomPattern;
     AmountOfRooms    = roomPattern.amount.Random;
     if (!roomPattern.PainterHaveTile)
     {
         Debug.LogWarning("There is no tile attached to the " + roomPattern.name + ".");
     }
 }
Ejemplo n.º 2
0
        // ------------------------------------------------------------------------
        // Private Methods
        // ------------------------------------------------------------------------
        private void setRoomPattern(RoomPattern pattern)
        {
            if (pattern != _roomPattern)
            {
                _roomPattern = pattern;

                PweRoomTools.Instance.showToolPanels(pattern);
            }
        }
Ejemplo n.º 3
0
        // ------------------------------------------------------------------------
        public void activate(RoomPattern pattern, PrefabLevelEditor.Part part)
        {
            reset();              // just in case

            _curPart = part;

            setRoomPattern(pattern);

            update(-1, -1);              // force update
        }
Ejemplo n.º 4
0
    public Room(TileVector vector, RoomPattern roomPattern)
    {
        this.roomPattern = roomPattern;
        direction        = vector.direction;
        int width  = roomPattern.GetRoomWidth(vector.direction);
        int height = roomPattern.GetRoomHeight(vector.direction);

        startPosition    = GetPositionWithLowestCoordinates(vector, width, height);
        endPosition      = GetPositionWithHighestCoordinates(width, height);
        unusedDirections = roomPattern.GetDirectionsContainer(vector.direction);
    }
Ejemplo n.º 5
0
        // ------------------------------------------------------------------------
        public void activateAndCopy(RoomPattern pattern, PrefabLevelEditor.Part part, int w, int h, int d)
        {
            _rebuildOnUpdate = false;

            reset();              // just in case

            _curPart = part;

            setRoomPattern(pattern);

            PweRoomTools.Instance.setWidthValue(w, pattern);
            PweRoomTools.Instance.setHeightValue(h, pattern);

            _rebuildOnUpdate = true;

            update(-1, -1);              // force update
        }
Ejemplo n.º 6
0
    private void CreateDungeonBlocks()
    {
        if (dungeonBlockGrid != null)
        {
            Debug.LogWarning("dungeonBlockGrid is already created.");
            return;
        }

        dungeonBlockGrid = new DungeonBlock[SizeX, SizeY];
        int numXDiv = (SizeX - 2) / divXSize;
        int numYDiv = (SizeY - 2) / divYSize;

        // Fill up edges with walls.
        for (int edgeX = 0; edgeX < SizeX; edgeX++)
        {
            DungeonBlock curTopRowBlock = new DungeonBlock(TerrainType.Wall, edgeX, 0);
            dungeonBlockGrid[edgeX, 0] = curTopRowBlock;

            for (int edgeY = numYDiv * divYSize + 1; edgeY < SizeY; edgeY++)
            {
                DungeonBlock curBtmRowBlock = new DungeonBlock(TerrainType.Wall, edgeX, edgeY);
                dungeonBlockGrid[edgeX, edgeY] = curBtmRowBlock;
            }
        }
        for (int edgeY = 1; edgeY < SizeY - 1; edgeY++)
        {
            DungeonBlock curLeftColBlock = new DungeonBlock(TerrainType.Wall, 0, edgeY);
            dungeonBlockGrid[0, edgeY] = curLeftColBlock;

            for (int edgeX = numXDiv * divXSize + 1; edgeX < SizeX; edgeX++)
            {
                DungeonBlock curRightColBlock = new DungeonBlock(TerrainType.Wall, edgeX, edgeY);
                dungeonBlockGrid[edgeX, edgeY] = curRightColBlock;
            }
        }

//		RoomPattern[] patterns = Resources.FindObjectsOfTypeAll<RoomPattern>();
//		#if UNITY_EDITOR
//		Debug.Log(patterns.Length);
//		if (patterns.Length == 0)
//			Debug.LogError("There are no Room Patterns found.");
//		#endif

        // Actual floor terrain, generated in batches of 5x5 grids.
        for (int divY = 0; divY < numYDiv; divY++)
        {
            for (int divX = 0; divX < numXDiv; divX++)
            {
                int anchorX = divXSize * divX + 1;
                int anchorY = divYSize * divY + 1;

                RoomPattern curPattern = GetRandPattern();

                for (int y = 0; y < divYSize; y++)
                {
                    for (int x = 0; x < divXSize; x++)
                    {
                        int          indexX = anchorX + x;
                        int          indexY = anchorY + y;
                        DungeonBlock curBlock;

                        TerrainType terrainType = curPattern.BlockTerrainType[y * curPattern.SizeY + x];
                        if (terrainType == TerrainType.Wall)
                        {
                            if ((Random.value - curPattern.MatchPercentage) > 0.0f)
                            {
                                terrainType = TerrainType.Tile;
                            }
                        }

                        curBlock = new DungeonBlock(terrainType, indexX, indexY);
                        dungeonBlockGrid[indexX, indexY] = curBlock;
                    }
                }
            }
        }

        // Set the EndTile.
        mnExitPosX  = divXSize * (numXDiv - 1) + 1;
        mnExitPosY  = divYSize * (numYDiv - 1) + 1;
        mnExitPosX += divXSize / 2;
        mnExitPosY += divYSize / 2;
        dungeonBlockGrid[ExitPosX, ExitPosY] = new DungeonBlock(TerrainType.Stairs, ExitPosX, ExitPosY);
        SetSurroundingTilesToEmpty(ExitPosX, ExitPosY);

        // Set the PlayerSpawnPosition
        mnSpawnPosX = divXSize / 2 + 1;
        mnSpawnPosY = divYSize / 2 + 1;
        dungeonBlockGrid[SpawnPosX, SpawnPosY] = new DungeonBlock(TerrainType.Tile, SpawnPosX, SpawnPosY);
        SetSurroundingTilesToEmpty(SpawnPosX, SpawnPosY);
    }