public void Move() { cells = new List <Cell>(); //CheckPersonalSpace(0, 3000); for (int row = 0; row < m_Height; row++) { for (int col = 0; col < m_Width; col++) { int neighbours = CheckPersonalSpace(col, row); if (neighbours < 2) { if (RetrieveCell(col, row).IsAlive) { Cell temp = new Cell(col, row, m_graphics, m_spriteBatch, texture, dead); cells.Add(temp); } } else if (neighbours == 3) { if (!RetrieveCell(col, row).IsAlive) { Cell temp = new Cell(col, row, m_graphics, m_spriteBatch, texture, dead); temp.Birth(); cells.Add(temp); } } else if (neighbours > 3) { if (RetrieveCell(col, row).IsAlive) { Cell temp = new Cell(col, row, m_graphics, m_spriteBatch, texture, dead); cells.Add(temp); } } } } for (int i = 0; i < cells.Count; i++) { if (cells[i].IsAlive) { m_Grid[cells[i].Row, cells[i].Column].Birth(); } else { m_Grid[cells[i].Row, cells[i].Column].Death(); } } cells.Clear(); }
public void Move() { cells = new List<Cell>(); //CheckPersonalSpace(0, 3000); for (int row = 0; row < m_Height; row++) { for (int col = 0; col < m_Width; col++) { int neighbours = CheckPersonalSpace(col, row); if (neighbours < 2) { if (RetrieveCell(col, row).IsAlive) { Cell temp = new Cell(col, row, m_graphics, m_spriteBatch,texture,dead); cells.Add(temp); } } else if (neighbours == 3) { if (!RetrieveCell(col, row).IsAlive) { Cell temp = new Cell(col, row, m_graphics, m_spriteBatch, texture,dead); temp.Birth(); cells.Add(temp); } } else if (neighbours > 3) { if (RetrieveCell(col, row).IsAlive) { Cell temp = new Cell(col, row, m_graphics, m_spriteBatch, texture,dead); cells.Add(temp); } } } } for (int i = 0; i < cells.Count; i++) { if (cells[i].IsAlive) m_Grid[cells[i].Row, cells[i].Column].Birth(); else m_Grid[cells[i].Row, cells[i].Column].Death(); } cells.Clear(); }