private void FillCells(Random rnd) { Orchard appleOrchard = new Orchard(); foreach (Cell cell in CellGrid) { _appleOrchardArray[cell.XPosition, cell.YPosition] = false; rnd = new Random(); cell.CellContents = "- "; if (cell.IsEdge) { cell.CellContents = "% "; } else if (appleOrchard.Pollinate(rnd) <= 33 && !cell.ContainsPlayer) { _appleOrchardArray[cell.XPosition, cell.YPosition] = true; cell.HasApple = true; } if (ThePlayer.Position[0] == cell.YPosition && ThePlayer.Position[1] == cell.XPosition) { cell.ContainsPlayer = true; cell.WasVisited = true; } else { cell.ContainsPlayer = false; } } }
public string DrawPlayfield() { Playfield = null; _scoreDrawn = false; Console.Clear(); Orchard appleOrchard = new Orchard(); FillCells(rnd); int lineLength = 0; foreach (Cell cell in CellGrid) { Random rnd = new Random(); if (cell.ContainsPlayer) { cell.CellContents = "* "; } if (cell.WasVisited && !cell.ContainsPlayer) { cell.CellContents = " "; } if (cell.HasApple) { cell.CellContents = "o "; } Playfield += cell.CellContents; lineLength++; if (lineLength == GridSize && _scoreDrawn == false) { Playfield += " PLAYER SCORE: " + ThePlayer.PlayerScore; _scoreDrawn = true; } if (lineLength == GridSize) { Playfield += "\n"; lineLength = 0; } } _scoreDrawn = false; return(Playfield); }