Example #1
0
 private void InitializeSiblings()
 {
     for (int xPos = 0; xPos < m_cells.GetLength(0); xPos++)
     {
         for (int yPos = 0; yPos < m_cells.GetLength(1); yPos++)
         {
             GameObject currentCell      = m_cells[xPos, yPos];
             CellModel  currentCellModel = currentCell.GetComponent <CellModel>();
             if (xPos == 0 && yPos > 0)
             {
                 GameObject westCell = m_cells[xPos, yPos - 1];
                 currentCellModel.AddSibling(westCell);
             }
             else if (xPos > 0 && yPos > 0)
             {
                 GameObject westCell  = m_cells[xPos, yPos - 1];
                 GameObject northCell = m_cells[xPos - 1, yPos];
                 currentCellModel.AddSibling(westCell);
                 currentCellModel.AddSibling(northCell);
             }
             else if (xPos > 0 && yPos == 0)
             {
                 GameObject northCell = m_cells[xPos - 1, yPos];
                 currentCellModel.AddSibling(northCell);
             }
         }
     }
 }