public char WhatIsHere(int x, int y) { GridSquare location = FindGridSquare(x, y); Blocks contents = location.Contents; if (location.Goal && location.Contents == Blocks.Empty) { return('.'); } else if (location.Goal && location.Contents == Blocks.Moveable) { return('!'); } else { return((char)contents); } }
private void BuildLevel(string levelDesign) { MyGrid = new List <GridSquare>(); MyBoxes = new List <GridSquare>(); MyGoals = new List <GridSquare>(); for (var y = 0; y < RowCount; y += 1) { for (var x = 0; x < RowWidth; x += 1) { int stringPosition = y * RowWidth + x; char stringContent = levelDesign[stringPosition]; Blocks contents; Boolean isGoal = false; if (stringContent == '.') { isGoal = true; contents = (Blocks.Empty); } else if (stringContent == '!') { isGoal = true; contents = (Blocks.Moveable); } else { contents = (Blocks)stringContent; } GridSquare newSquare = new GridSquare(x, y, contents, isGoal); if (newSquare.Contents == Blocks.Moveable) { AllMyBoxes.Add(newSquare); } if (newSquare.Goal) { AllMyGoals.Add(newSquare); } MyGrid.Add(newSquare); } } }