public override void OnPickUp(bool abilityOne) { // bomb placed on _abilityIsActive = true; SetVisualModelActive(true); _timeBombState = TimeBombState.IDLE; UpdateDisplay("NOT ACTIVE"); _countDownTimer = _countDownTime; _abilityOne = abilityOne; _bIscountingDown = false; _displayText.color = _startColor; _displayText.fontSize = _fontSizeText; }
IEnumerator StartCountDown() { _bIscountingDown = false; _displayText.color = _activateColor; int flickerAmount = Mathf.FloorToInt(_timeDisplayActivated / _flickerSpeed / 2); for (int i = 0; i < flickerAmount; i++) { UpdateDisplay(">>ACTIVE<<"); yield return(new WaitForSeconds(_flickerSpeed)); UpdateDisplay(" "); yield return(new WaitForSeconds(_flickerSpeed)); } _countDownTimer = _countDownTime; _timeBombState = TimeBombState.ACTIVATED; _bIscountingDown = true; }
private void Explode() { if (_timeBombState != TimeBombState.ACTIVATED) { return; } _timeBombState = TimeBombState.DETONATED; EnableActivateParticles(true); Vector3 explosionPos = transform.position; Collider[] colliders = Physics.OverlapSphere(explosionPos, _radius); foreach (Collider col in colliders) { Rigidbody rb = col.GetComponent <Rigidbody>(); if (rb != null) { if (rb.CompareTag("DonutTruck")) { SCR_TruckDestructionManager truckDestrManager = col.GetComponent <SCR_TruckDestructionManager>(); // Calc damage Vector3 truckPos = rb.position; float distance = (explosionPos - truckPos).magnitude; float damage = (distance / _radius) * _maxDamage; truckDestrManager.TakeDamage(damage); rb.AddExplosionForce(_strength * _truckStrengthMultiplier, explosionPos, _radius); } else if (!rb.CompareTag("PoliceCar")) { rb.AddExplosionForce(_strength, explosionPos, _radius); _SoundHolder.GetComponent <SCR_AudioManager>().PlaySound(_SoundHolder.GetComponent <SCR_AudioManager>().GetSoundEffects()[9], GameObject.FindWithTag("PoliceCar")); } } } }