void OnTileBreak(DrillAttackInfo info) { GameObject onBreakObject = Instantiate(onBreakSoundPrefab, transform.position, Quaternion.identity); AudioSource source = onBreakObject.GetComponent <AudioSource>(); AudioClip clip = onBreakSounds.GetRandom(); source.PlayOneShot(clip); Destroy(onBreakObject, clip.length); }
void OnDrillAttack(DrillAttackInfo info) { if (invulnerable) { return; } health -= info.damage; /*Color colour = spriteRenderer.color; * colour.a = Mathf.InverseLerp(0, startHealth, health); * spriteRenderer.color = colour;*/ p.position = new Vector3(0, 0, -1) + (Vector3)(info.position + info.normal * 0.01f); p.velocity = info.normal + Random.insideUnitCircle * 1.5f; OnDrillParticleSystem.Emit(p, Random.Range(1, 2)); audioSource.PlayOneShot(onHitSounds.GetRandom()); if (health <= 0) { SendMessage("OnTileBreak", info); Destroy(gameObject); } }