private void OnTriggerEnter(Collider other) { if (_owner == null) { return; } if (other.tag == "Target") { _owner.DoDamage(other.GetComponent <TargetBehaviour>().TargetConfig); } if (other.tag == "Character") { _owner.DoDamage(other.GetComponent <CharacterBehaviour>().character); } }
private void OnTriggerEnter(Collider other) { if (_shooter == null) { return; } if (other.CompareTag("Character Part")) { if (other.transform.GetComponentInParent <CharacterBehaviour>() != _owner) { Destroy(other.gameObject); } } if (other.tag == "Character") { if (other.transform.GetComponentInParent <CharacterBehaviour>() != _owner) { _shooter.DoDamage(other.GetComponent <CharacterBehaviour>().character); Destroy(gameObject); } } if (other.tag == "Target") { _shooter.DoDamage(other.GetComponent <TargetBehaviour>().TargetConfig); Destroy(gameObject); } if (other.tag == "Enviornment") { Destroy(gameObject); } if (other.tag == "Breakable") { var b = other.GetComponent <BarrelBehaviour>(); if (b == null) { var c = other.GetComponent <CrateBehaviour>(); _shooter.DoDamage(c.CrateConfig); } else { _shooter.DoDamage(b.BarrelConfig); } } }
void OnTriggerEnter(Collider other) { if (other.gameObject == this.transform.root.gameObject) { return; } IDamager attacker = this.transform.root.gameObject.GetComponent <IDamager>(); IDamageable defender = other.gameObject.GetComponent <IDamageable>(); if (attacker == null || defender == null) { return; } attacker.DoDamage(defender); }
private void NewMethod(List <GameObject> hovered) { var hoveredchildren = new List <Transform>(); foreach (var h in hovered) { var transforms = h.GetComponentsInChildren <Transform>(); hoveredchildren.AddRange(transforms); } foreach (var go in hoveredchildren) { var damageable = go.GetComponent <IDamageable>(); if (damageable == null) { continue; } _damager.DoDamage(damageable); } }