コード例 #1
0
 // Shuffling orbs
 public IEnumerator shuffleBoard(int numShuffles = 1, float delay = 0f)    // sum ugly ass code
 {
     for (int s = 0; s < numShuffles; s++)
     {
         for (int i = 0; i < ROWS * COLUMNS - 1; i++)
         {
             int        j     = RNG.Next(i, ROWS * COLUMNS);
             int        row_i = i / COLUMNS;
             int        col_i = i % COLUMNS;
             int        row_j = j / COLUMNS;
             int        col_j = j % COLUMNS;
             Orb        orb1  = orbArray[col_i][row_i];
             Orb        orb2  = orbArray[col_j][row_j];
             Vector2Int temp  = orb1.getGridPos();
             orb1.setGridPos(orb2.getGridPos());
             orb2.setGridPos(temp);
             orbArray[col_i][row_i] = orb2;
             orbArray[col_j][row_j] = orb1;
             orb1.getTrans().position = convertGridToWorldPos(orb1.getGridPos());
             orb2.getTrans().position = convertGridToWorldPos(orb2.getGridPos());
         }
         if (delay != 0)
         {
             yield return(new WaitForSeconds(delay));
         }
     }
 }