public static Color GetCellColor( Cell cell ) { switch( cell ) { case Cell.Head: return COLOR_CELL_HEAD; case Cell.Body: return COLOR_CELL_BODY; case Cell.Pellet: return COLOR_CELL_PELLET; case Cell.Wall: return COLOR_CELL_WALL; case Cell.Empty: return COLOR_CELL_EMPTY; default: throw new ArgumentOutOfRangeException( "cell" ); } }
// Returns true if the next cell is valid; false if it's invalid private bool handleNewCell( Cell c ) { switch( c ) { case Cell.Head: case Cell.Body: case Cell.Wall: return false; case Cell.Pellet: eatPellet(); break; case Cell.Empty: break; default: throw new ArgumentOutOfRangeException( "c" ); } return true; }
private void CreateGreed() { Greed = new Cell[Count]; for (int i = 0; i < Count; ++i) { var cell = Instantiate(cellPrefab); Point pos = IndexToPos(i); cell.Init(i, pos, false); cell.transform.parent = transform; cell.transform.localPosition = GetRealPosition(pos.X, pos.Y); Greed[i] = cell; } for (int i = 0; i < Count; ++i) { var cell = Greed[i]; cell.SetNeighbour(NeighbourPos.Left, GetCell(cell.Position.X - 1, cell.Position.Y)); cell.SetNeighbour(NeighbourPos.Right, GetCell(cell.Position.X + 1, cell.Position.Y)); cell.SetNeighbour(NeighbourPos.Top, GetCell(cell.Position.X, cell.Position.Y + 1)); cell.SetNeighbour(NeighbourPos.Bottom, GetCell(cell.Position.X, cell.Position.Y - 1)); } var cellsInfo = GameController.CurrentLevel.GetComponent<CellsInfo>(); if (cellsInfo != null) { cellsInfo.InitCells(this); } }