private void InflictDamage() { if (drillTarget == null) { StopDrilling(true); IsDrilling = false; return; } //query damage from parent float damage = parent.DrillDamageQuery(firstHit); //bigger effects for more damage ResizeParticleSystem(firstHit ? 1f : damage / parent.MaxDrillDamage()); //This is so that no damage is dealt while drilling while game is paused if (!firstHit) { damage *= Time.deltaTime * 60f; } firstHit = false; //if damage is 0 then stop drilling if (damage <= 0f && !Pause.IsStopped && !Pause.isShifting) { bool launch = parent.ShouldLaunch() && drillTarget.CanBeLaunched(); Vector2 launchDirection = Vector2.up; if (launch) { launchDirection = parent.LaunchDirection(((Entity)drillTarget).transform); Transform eff = Instantiate(drillLaunchSparkEffect).transform; eff.parent = ParticleGenerator.holder; eff.position = transform.position; float angle = -Vector2.SignedAngle(Vector2.up, launchDirection); eff.eulerAngles = Vector3.forward * -angle; Pause.TemporaryPause(drillLaunchPauseTime); if (cameraCtrl) { cameraCtrl.CamShake(); cameraCtrl.QuickZoom(0.8f, drillLaunchPauseTime, true); } screenRippleSO.StartRipple(this, wait: drillLaunchPauseTime); parent.Launching(); if (drillLaunchBurstAnimations.Length > 0) { Pause.DelayedAction(() => { int chooseLaunchBurstAnimation = Random.Range(0, drillLaunchBurstAnimations.Length); Transform burst = Instantiate(drillLaunchBurstAnimations[chooseLaunchBurstAnimation]).transform; burst.parent = ParticleGenerator.holder; burst.position = transform.position; burst.eulerAngles = Vector3.forward * -angle; }, 0.02f, true); } } StopDrilling(false, launch, launchDirection, parent); } //else send the damage to the drill target else { if (drillTarget.TakeDrillDamage(damage, transform.position, parent, 1f)) { parent.DrillComplete(); } } //adjust sound if (!Pause.IsStopped) { currentVolume = Mathf.MoveTowards(currentVolume, maxVolume, maxVolume * volumeIncrease); } drillSoundSource.volume = Pause.IsStopped ? 0f : currentVolume; drillSoundSource.pitch = Mathf.MoveTowards(drillPitchRange.x, drillPitchRange.y, damage * pitchModifier); }