void CheckExplosion(Vector3 direction) { RaycastHit hit; if (Physics.Raycast(transform.position, direction, out hit)) { if (hit.distance <= currentWidth) { Mole hitMole = hit.transform.gameObject.GetComponent <Mole>(); if (hitMole) { hitMole.Die(hitMole.allowChainReaction); } } } }
void HitWithinRange(GridSpawner gridSpawner) { for (int x = posX - radius; x <= posX + radius; x++) { for (int y = posY - radius; y <= posY + radius; y++) { GameObject obj = gridSpawner.LookupGrid(x, y); if (obj) { Mole mole = obj.GetComponent <Mole>(); if (true) { mole.Die(); } } } } }