IEnumerator StartChainReaction(Explosion.ExplosionInfo info) { //Look for our own explosion and get things rolling! Explosion exp = GetComponent <Explosion>(); if (exp != null && exp != info.source && exp.TimesExploded <= 0) { //Have a delegate for starting a chain reaction explosive. Maybe move this to Explosion.cs //Delay for visuals yield return(new WaitForSeconds(ChainReactionDelay)); UnsetFlag(ResponseType, ExplosionResponse.ChainReaction); //Chain Reaction has begun! //Debug.Log("Chain Raction on " + exp.name + " caused by " + name + "\n"); exp.Explode(); } }
public bool RecieveExplosion(Explosion.ExplosionInfo info) { if (HasFlag(ExplosionResponse.None)) { return(false); } Vector3 direction = transform.position - info.explosionCenter; Vector3 blast = Vector3.Scale(direction.normalized, info.forceMultipliers); //Debug.Log("I have recieved an explosion\t" + name + "\n\tForce: " + forceMultipliers); if (HasFlag(ExplosionResponse.Rigidbody)) { if (rb != null) { if (rb.isKinematic && info.source.RemoveKinematicAttribute) { rb.isKinematic = false; rb.useGravity = true; } //Debug.Log("Applying force to " + name + "\n"); rb.AddForce(blast, ForceMode.Impulse); } } if (HasFlag(ExplosionResponse.Haptics)) { if (info.explosionSequence != null) { var Where = HardlightSuit.Find().FindNearestFlag(info.explosionCenter, 5); HardlightSuit.Find().EmanatingHit(Where, info.explosionSequence, .25f, 8); } } if (HasFlag(ExplosionResponse.Fireworks)) { //Create a visual effect at the point of impact? } if (HasFlag(ExplosionResponse.ChainReaction)) { StartCoroutine(StartChainReaction(info)); } if (HasFlag(ExplosionResponse.Destroyable)) { Destroyable breakable = GetComponent <Destroyable>(); if (breakable != null) { //Debug.Log(info.BlastStrength() + " \n" + blast + "\n"); breakable.DestroyableHit(info.BlastStrength(), blast); } } if (HasFlag(ExplosionResponse.CallScript)) { if (WhenExploded != null) { WhenExploded.Invoke(info); } //Delegate to call if (HitByExplosionDelegate != null) { HitByExplosionDelegate.Invoke(info); } } return(true); }