示例#1
0
    public static void SpawnMonsters_Random()
    {
        List <Tile> spawnTiles = new List <Tile>();

        int         monsterNum      = Formula.CalculateMonsterNum(LevelManager.instance.mazeDifficulty);
        int         distancePlayer  = Formula.CalculateMonsterPlayerLeastDistance(LevelManager.instance.mazeDifficulty);
        int         distanceMonster = Formula.CalculateMonsterLeastDistance(LevelManager.instance.mazeDifficulty);
        List <Tile> exclusiveTiles  = new List <Tile>();

        exclusiveTiles.Add(LevelManager.instance.tileStart);

        List <Tile> oldList = MazeUTL.UpdateTileListOutOfRange(LevelManager.instance.maze.mazeTileList, exclusiveTiles, distancePlayer);

        for (int i = 0; i < monsterNum; i++)
        {
            oldList = MazeUTL.UpdateTileListOutOfRange(oldList, exclusiveTiles, distanceMonster);

            Tile spawnTile = oldList[Random.Range(0, oldList.Count)];
            spawnTiles.Add(spawnTile);
            exclusiveTiles.Add(spawnTile);
        }

        foreach (Tile tile in spawnTiles)
        {
            SpawnMonster(tile);
        }
    }
示例#2
0
    void GenerateObjective_Random(Maze maze)
    {
        // Make sure the objective is at least half map aways from the start point. Also, make it spawn at C shape wall layout.
        List <Tile> orgs = new List <Tile>();

        orgs.Add(level.tileStart);
        List <Tile> tileList = MazeUTL.UpdateTileListOutOfRange(maze.mazeTileList, orgs, Formula.CalculateObjectiveLeastDistance(LevelManager.instance.mazeDifficulty));

        tileList = MazeUTL.UpdateTileListWithDesiredWallLayout(tileList, WallLayout.C);
        Tile tile = MazeUTL.GetRandomTileFromList(tileList);

        tile.SpawnTileItem(level.objectivePrefab);
        level.tileObjective = tile;
        TilesWithItem.Add(tile);
    }
示例#3
0
    List <Tile> GetItemSpawnRandomTiles(int numItems, int range, List <Tile> tileList, List <Tile> tilesLeft, List <Tile> exclusiveTiles)
    {
        if (numItems <= 0)
        {
            return(tileList);
        }

        tilesLeft = MazeUTL.UpdateTileListOutOfRange(tilesLeft, exclusiveTiles, range);
        Tile tile = MazeUTL.GetRandomTileFromList(tilesLeft);

        tileList.Add(tile);

        List <Tile> newExclusiveTiles = new List <Tile>();

        foreach (Tile t in exclusiveTiles)
        {
            newExclusiveTiles.Add(t);
        }
        newExclusiveTiles.Add(tile);

        numItems--;

        return(GetItemSpawnRandomTiles(numItems, range, tileList, tilesLeft, newExclusiveTiles));
    }