public void Explode() { Destroy(this.gameObject); DestructibleMap.RemoveObjectFromMap(bombPlacement.x, bombPlacement.y); if (player != null) { player.actualBombNumber--; } SetExplosion(); }
private void CreateBomb() { if (actualBombNumber >= maxNumberBomb) { return; } Vector3Int bombPlacement = GetPositionOnTilemap(); bool testCreationBomb = DestructibleMap.FreePlaceOnMap((int)bombPlacement.x, (int)bombPlacement.y); if (testCreationBomb) { Bomb bombObject = Instantiate(bomb, GetPosition(), Quaternion.identity); DestructibleMap.AddBombOnMap(bombPlacement.x, bombPlacement.y); bombObject.player = this; actualBombNumber++; } }
void PutBomb() { int row = 0; int column = 0; do { row = (int)Random.Range(0, 11); column = (int)Random.Range(0, 11); if (row % 2 == 1 && column % 2 == 1) { column++; } }while(DestructibleMap.Map(row, column) != 0); DestructibleMap.AddBombOnMap(row, column); Vector3 positionBomb = new Vector3(row - 4.5f, -column + 4.5f, 0f); Vector3 test = Vector3.zero; Instantiate(bomb, positionBomb, Quaternion.identity); }
private int ExplosionCheckRight() { if (Math.Min(rangeOfFire, 10 - bombPlacement.x) == 0) { return(0); } int i = 1; while (i < Math.Min(rangeOfFire, 10 - bombPlacement.x)) { if (DestructibleMap.Map(bombPlacement.x + i, bombPlacement.y) == -1) { return(i - 1); } if (DestructibleMap.Map(bombPlacement.x + i, bombPlacement.y) >= 1) { i++; return(i); } i++; } return(i); }