void explode() { int x = (int)this.gameObject.transform.position.x; int y = (int)this.gameObject.transform.position.z; int right = 0; int left = 0; int up = 0; int down = 0; GameObject player; if ((player = map.checkPlayersPosition(x, y)) != null) { player.GetComponent <PlayerControl>().DestroyPlayer(); } for (int i = 1; i < bombRange && (x + i) < 40; i++) { if (map.blockArray[x + i, y]) { if (map.blockArray[x + i, y].tag == "DestructibleBox") { map.blockArray[x + i, y].GetComponent <BoxScript>().BoxDestroy(); } right = i; break; } else { if ((player = map.checkPlayersPosition(x + i, y)) != null) { player.GetComponent <PlayerControl>().DestroyPlayer(); } } right = i; } for (int i = 1; i < bombRange && (y + i) < 30; i++) { if (map.blockArray[x, y + i]) { if (map.blockArray[x, y + i].tag == "DestructibleBox") { map.blockArray[x, y + i].GetComponent <BoxScript>().BoxDestroy(); } up = i; break; } else { if ((player = map.checkPlayersPosition(x, y + i)) != null) { player.GetComponent <PlayerControl>().DestroyPlayer(); } } up = i; } for (int i = 1; i < bombRange && (x - i) >= 0; i++) { if (map.blockArray[x - i, y]) { if (map.blockArray[x - i, y].tag == "DestructibleBox") { map.blockArray[x - i, y].GetComponent <BoxScript>().BoxDestroy(); } left = i; break; } else { if ((player = map.checkPlayersPosition(x - i, y)) != null) { player.GetComponent <PlayerControl>().DestroyPlayer(); } } left = i; } for (int i = 1; i < bombRange && (y - i) >= 0; i++) { if (map.blockArray[x, y - i]) { if (map.blockArray[x, y - i].tag == "DestructibleBox") { map.blockArray[x, y - i].GetComponent <BoxScript>().BoxDestroy(); } down = i; break; } else { if ((player = map.checkPlayersPosition(x, y - i)) != null) { player.GetComponent <PlayerControl>().DestroyPlayer(); } } down = i; } foreach (Transform child in explosion.transform) { switch ((int)child.gameObject.transform.eulerAngles.y) { case 0: child.gameObject.GetComponent <ParticleSystem>().startLifetime = (up) * 0.025f; child.gameObject.GetComponent <ParticleSystem>().startSpeed = 50; break; case 90: child.gameObject.GetComponent <ParticleSystem>().startLifetime = (right) * 0.025f; child.gameObject.GetComponent <ParticleSystem>().startSpeed = 50; break; case 180: child.gameObject.GetComponent <ParticleSystem>().startLifetime = (down) * 0.025f; child.gameObject.GetComponent <ParticleSystem>().startSpeed = 50; break; case 270: child.gameObject.GetComponent <ParticleSystem>().startLifetime = (left) * 0.025f; child.gameObject.GetComponent <ParticleSystem>().startSpeed = 50; break; } // child.gameObject.GetComponent<ParticleSystem>().startLifetime = (bombRange - 1) * 0.05f; // child.gameObject.GetComponent<ParticleSystem>().startSpeed = 25; } explosion.SetActive(true); explosion.transform.parent = null; Destroy(map.blockArray[x, y]); map.blockArray[x, y] = null; owner.GetComponent <PlayerControl>().bombNumber += 1; }