public override void BuildBoard() { UpdatePosition(); for (int i = 0; i < BoardWidth; i++) { for (int j = 0; j < BoardHeight; j++) { //build the ground var groundpiece = new BombermanFloorTile(_Style); groundpiece.RegisterToBoardGameControlItem(this, new Point3D(i, j, 0)); BackgroundItems.Add(groundpiece); //build the outer walls and inner grid walls if (i == 0 || i == BoardWidth - 1 || j == 0 || j == BoardHeight - 1 || j % 2 == 0 && i % 2 == 0) { var wallpiece = new IndestructableWall(_Style, true); wallpiece.RegisterToBoardGameControlItem(this, new Point3D(i, j, 0)); BackgroundItems.Add(wallpiece); } else { if (_State == BoardGameState.Active) //if a game is active, then build obstacles and such { //don't put obstacles in the player starting positions if (i < 3 && j < 3 || i > BoardWidth - 4 && j < 3 || i < 3 && j > BoardHeight - 4 || i > BoardWidth - 4 && j > BoardHeight - 4) { continue; } if (j > BoardHeight / 2 - 2 && j < BoardHeight / 2 + 2 && (i < 3 || i > BoardWidth - 4)) { continue; } if (i > BoardWidth / 2 - 2 && i < BoardWidth / 2 + 2 && (j < 3 || j > BoardHeight - 4)) { continue; } //obstacles if (Utility.RandomDouble() < BombermanSettings.OBSTACLE_CHANCE) { var wallpiece = new DestructableWall(_Style); wallpiece.RegisterToBoardGameControlItem(this, new Point3D(i, j, 0)); BackgroundItems.Add(wallpiece); } } } } } base.BuildBoard(); }
private void BuildLevel(List <string[]> levelData) { // iterate through lines for (int i = 0; i < levelData.Count(); i++) { switch (levelData[i][0]) { case "00": // mario Mario.Instance.PlayableObjectState = new SmallRightIdleMario(Mario.Instance); Mario.Instance.Position = new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize); break; case "01": // floor tiles StaticObjects.Add(new FloorTile(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), new Vector2(StringToInt(i, 3), StringToInt(i, 4)), levelData[i][5])); break; case "02": // blocks Blocks.Add(new Block(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelData[i][3], levelData[i][4])); break; case "03": // floating coins Coins.Add(new Item(new Vector2((StringToInt(i, 1) * levelCellSize) + (levelCellSize / 4), StringToInt(i, 2) * levelCellSize), "FloatingCoin")); break; case "04": // pipes Pipes.Add(new Pipe(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3), Convert.ToBoolean(levelData[i][4]), levelData[i][5])); break; case "05": // enemies Enemies.Add(new Enemy(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize - 10), levelData[i][3])); break; case "06": // hills BackgroundItems.Add(new Hill(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3))); break; case "07": // bushes BackgroundItems.Add(new Bush(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3))); break; case "08": // clouds BackgroundItems.Add(new Cloud(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3))); break; case "09": // castle Castle = new Castle(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize)); break; case "10": // flag pole Flagpoles.Add(new Flagpole(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelCellSize)); break; case "11": // check point Checkpoints.Add(new CheckPoint(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize))); break; case "12": // coin room CoinRoomPosition = new Vector2(StringToInt(i, 1) * levelCellSize + (levelCellSize / 8), StringToInt(i, 2) * levelCellSize); break; } } DynamicObjects.Add(Mario.Instance); foreach (Block block in Blocks) { DynamicObjects.Add(block); DynamicObjects.Add(block.Item); // Add items in each block too. } foreach (Item coin in Coins) { DynamicObjects.Add(coin); } foreach (Enemy enemy in Enemies) { // Added such that the Koopa spawns in a correct position before any updates are made, otherwise he spawns in the floor to start. if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.LeftWalkingKoopa" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.RightWalkingKoopa") { enemy.Position = new Vector2(enemy.Position.X, enemy.Position.Y - GameValues.KoopaPositionOffset); } DynamicObjects.Add(enemy); } foreach (Pipe pipe in Pipes) { StaticObjects.Add(pipe); } foreach (Flagpole flagpole in Flagpoles) { StaticObjects.Add(flagpole); } if (Flagpoles.Count > 0) { Flag.Position = new Vector2(Flagpoles[0].CollisionRectangle.X - GameValues.FlagPositionOffsetVector.X, Flagpoles[0].CollisionRectangle.Y + GameValues.FlagPositionOffsetVector.Y); } }
public void AddBackgroundItem(BackgroundItem backgroundItem) { BackgroundItems.Add(backgroundItem); }