//Drawing all bricks into panel private void createBricks() { // Creating bricks Random randomLocation = new Random(); for (int i = 0; i < brickNumber; i++) { int brickLocation = randomLocation.Next(0, emptySpaceList.Count); EmptySpace emptySpace = emptySpaceList.ElementAt(brickLocation); emptySpaceList.RemoveAt(brickLocation); Brick brick = new Brick(emptySpace.X, emptySpace.Y, brickWidth, brickHeight, mapPanel); brickList.Add(brick); } }
// Creating the monsters into monsterList. private void createMonster() { Random randomLocation = new Random(); for (int i = 0; i < monsterNumber; i++) { int monsterLocation = randomLocation.Next(0, emptySpaceList.Count); EmptySpace emptySpace = emptySpaceList.ElementAt(monsterLocation); emptySpaceList.RemoveAt(monsterLocation); Monster monster = new Monster(emptySpace.X, emptySpace.Y, playerHeight, playerWidth, mapPanel); monster.setMonsterMovementDirection(playerPB); monsterList.Add(monster); } monsterSequence = true; }
// Creating the bricks into brickList. private void createEmptySpaces() { int verticalBlockNumber = calculateVerticalBoxNumber(); int horizontalBlockNumber = calculateHorizontalBoxNumber(); brickNumber = verticalBlockNumber * horizontalBlockNumber; //Creating empty space locations. // 1, 3, 5, 7.. for every row, column is filled. (whole column). for (int verticalOdd = 0; verticalOdd < verticalBlockNumber + 1; verticalOdd++) { for (int horizontalEvery = 0; horizontalEvery < horizontalBlockNumber * 2 + 1; horizontalEvery++) { //(0,0) and (1,0) is safe. if ((verticalOdd == 0 && horizontalEvery == 0) || (verticalOdd == 0 && horizontalEvery == 1)) { continue; } EmptySpace emptySpace = new EmptySpace(verticalOdd * (patternHeight * 2), horizontalEvery * patternWidth); emptySpaceList.Add(emptySpace); } } // 2, 4, 6, 8.. every once column for (int verticalEven = 0; verticalEven < verticalBlockNumber; verticalEven++) { for (int horizontalOdd = 0; horizontalOdd < horizontalBlockNumber + 1; horizontalOdd++) { // (0,1) is safe. if (verticalEven == 0 && horizontalOdd == 0) { continue; } EmptySpace emptySpace = new EmptySpace(patternHeight + (verticalEven * patternHeight * 2), horizontalOdd * (patternHeight * 2)); emptySpaceList.Add(emptySpace); } } }