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(); }
//Checking for collision with walls or bullets private void OnTriggerEnter(Collider other) { //Check if we have collided with a obstacle and damage //the player DestructableWall destructableWall = other.GetComponent <DestructableWall>(); if (destructableWall) { //Damage the player DamagePlayer(playerCollisionDamage); //Destroy the wall destructableWall.ExplodeWall(); return; } //Check if the player has collided with a pickup CoinPickup pickup = other.GetComponent <CoinPickup>(); if (pickup) { PickupCoin(pickup); } }