示例#1
0
 private void GenerateDoors()
 {
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             Cell           cell     = tabCells[x, y];
             Cell.CASE_TYPE cellType = cell.GetCaseType();
             if (cellType == Cell.CASE_TYPE.Border || cellType == Cell.CASE_TYPE.Plain)
             {
                 DIRECTION corridorDir = GetNearTypeDirection(new CellPosition(x, y), Cell.CASE_TYPE.Corridor);
                 if (corridorDir != DIRECTION.None)
                 {
                     Cell corridor = GetCaseByDirection(cell.Pos, corridorDir);
                     if (corridor.walls[(int)GetOpposedDirection(corridorDir)])
                     {
                         continue;
                     }
                     cell.obj                     = Cell.CASE_OBJECT.Door;
                     cell.objDirection            = corridorDir;
                     cell.walls[(int)corridorDir] = false;
                 }
             }
         }
     }
 }
示例#2
0
 private void GenerateSpawnsEnemy()
 {
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             Cell.CASE_TYPE caseType = tabCells[x, y].GetCaseType();
             if (caseType != Cell.CASE_TYPE.Plain)
             {
                 continue;
             }
             if (tabCells[x, y].obj != Cell.CASE_OBJECT.None)
             {
                 continue;
             }
             if (IsObjNear(new CellPosition(x, y), Cell.CASE_OBJECT.SpawnEnemy))
             {
                 continue;
             }
             if (Random.value < densitySpawn)
             {
                 tabCells[x, y].obj = Cell.CASE_OBJECT.SpawnEnemy;
             }
         }
     }
 }
示例#3
0
 private void GenerateDecos()
 {
     if (decoPrefabs.Length == 0)
     {
         return;
     }
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             Cell.CASE_TYPE caseType = tabCells[x, y].GetCaseType();
             if (caseType != Cell.CASE_TYPE.Plain)
             {
                 continue;
             }
             if (tabCells[x, y].obj != Cell.CASE_OBJECT.None)
             {
                 continue;
             }
             if (HasObjNear(new CellPosition(x, y)))
             {
                 continue;
             }
             if (Random.value < densityDeco)
             {
                 tabCells[x, y].obj       = Cell.CASE_OBJECT.Decor;
                 tabCells[x, y].decoIndex = Random.Range(0, decoPrefabs.Length);
             }
         }
     }
 }
示例#4
0
 private void GenerateTreasures()
 {
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             Cell.CASE_TYPE caseType = tabCells[x, y].GetCaseType();
             if (caseType != Cell.CASE_TYPE.Border && caseType != Cell.CASE_TYPE.Trap)
             {
                 continue;
             }
             if (tabCells[x, y].obj != Cell.CASE_OBJECT.None)
             {
                 continue;
             }
             if (IsObjNear(new CellPosition(x, y), Cell.CASE_OBJECT.Tresor))
             {
                 continue;
             }
             if (Random.value < densityTreasure)
             {
                 tabCells[x, y].obj = Cell.CASE_OBJECT.Tresor;
             }
         }
     }
 }
示例#5
0
 private DIRECTION GetNearTypeDirection(CellPosition pos, Cell.CASE_TYPE caseType)
 {
     if (IsInWidth(pos.x + 1))
     {
         if (tabCells[pos.x + 1, pos.y].GetCaseType() == caseType)
         {
             return(DIRECTION.East);
         }
     }
     if (IsInWidth(pos.x - 1))
     {
         if (tabCells[pos.x - 1, pos.y].GetCaseType() == caseType)
         {
             return(DIRECTION.West);
         }
     }
     if (IsInHeight(pos.y + 1))
     {
         if (tabCells[pos.x, pos.y + 1].GetCaseType() == caseType)
         {
             return(DIRECTION.North);
         }
     }
     if (IsInHeight(pos.y - 1))
     {
         if (tabCells[pos.x, pos.y - 1].GetCaseType() == caseType)
         {
             return(DIRECTION.South);
         }
     }
     return(DIRECTION.None);
 }
示例#6
0
 private void BuildWall(CellPosition pos, DIRECTION dir)
 {
     Cell.CASE_TYPE caseType = tabCells[pos.x, pos.y].GetCaseType();
     if (caseType == Cell.CASE_TYPE.Corridor || caseType == Cell.CASE_TYPE.Border)
     {
         if (torchIndex == 0)
         {
             BuildWallWithTorch(pos, dir);
         }
         else
         {
             BuildScaledObject(pos, dir, cubePrefab, normalWallScale, false, "Wall");
         }
         torchIndex = (torchIndex + 1) % torchModulo;
     }
     else
     {
         BuildScaledObject(pos, dir, cubePrefab, normalWallScale, false, "Wall");
     }
 }