void FindStartEndRooms(GridDungeonModel gridModel, out Cell spawnCell, out Cell finalBossCell)
    {
        var furthestCells = GridDungeonModelUtils.FindFurthestRooms(gridModel);

        if (furthestCells.Length == 2 && furthestCells[0] != null && furthestCells[1] != null)
        {
            spawnCell     = furthestCells[0];
            finalBossCell = furthestCells[1];
        }
        else
        {
            spawnCell     = null;
            finalBossCell = null;
        }
    }
Example #2
0
        /// <summary>
        /// Called after the dungeon is completely built
        /// </summary>
        /// <param name="model">The dungeon model</param>
        public override void OnPostDungeonBuild(Dungeon dungeon, DungeonModel model)
        {
            if (model is GridDungeonModel)
            {
                // Handle the grid builder
                var gridModel = model as GridDungeonModel;

                var furthestCells = GridDungeonModelUtils.FindFurthestRooms(gridModel);
                if (furthestCells.Length == 2 && furthestCells[0] != null && furthestCells[1] != null)
                {
                    var startCell = furthestCells[0];
                    var endCell   = furthestCells[1];

                    SetStartingCell(gridModel, startCell);
                    SetEndingCell(gridModel, endCell);
                }
            }
            else if (model is SimpleCityDungeonModel)
            {
                var cityModel = model as SimpleCityDungeonModel;

                // Randomly pick two road tiles
                var roadCells = new List <SimpleCityCell>();
                for (int x = 0; x < cityModel.Cells.GetLength(0); x++)
                {
                    for (int y = 0; y < cityModel.Cells.GetLength(1); y++)
                    {
                        var cell = cityModel.Cells[x, y];
                        if (cell.CellType == SimpleCityCellType.Road)
                        {
                            roadCells.Add(cell);
                        }
                    }
                }

                var startCell = roadCells[Random.Range(0, roadCells.Count)];
                roadCells.Remove(startCell);
                var endCell = roadCells[Random.Range(0, roadCells.Count)];

                SetStartingCell(cityModel, startCell);
                SetEndingCell(cityModel, endCell);
            }
        }
Example #3
0
        public void FindSpecialRooms(DungeonModel model)
        {
            var gridModel = model as GridDungeonModel;

            if (gridModel == null)
            {
                return;
            }

            var furthestCells = GridDungeonModelUtils.FindFurthestRooms(gridModel);

            if (furthestCells.Length == 2 && furthestCells[0] != null && furthestCells[1] != null)
            {
                var startCell = furthestCells[0];
                var endCell   = furthestCells[1];

                SetStartingCell(gridModel, startCell);
                SetEndingCell(gridModel, endCell);
            }
        }
        /// <summary>
        /// Called after the dungeon is completely built
        /// </summary>
        /// <param name="model">The dungeon model</param>
        public override void OnPostDungeonBuild(Dungeon dungeon, DungeonModel model)
        {
            var gridModel = model as GridDungeonModel;

            if (gridModel == null)
            {
                return;
            }

            var furthestCells = GridDungeonModelUtils.FindFurthestRooms(gridModel);

            if (furthestCells.Length == 2 && furthestCells[0] != null && furthestCells[1] != null)
            {
                var startCell = furthestCells[0];
                var endCell   = furthestCells[1];

                SetStartingCell(gridModel, startCell);
                SetEndingCell(gridModel, endCell);
            }
        }