public override void ActionUpdate(float timekey) { timer += timekey; if (timer > spawnDelay && !projectileSpawned) { // apply damage Vector3 spawnPoint = character.transform.position + character.transform.TransformDirection(projectileSpawn); projectileInstance = GameObject.Instantiate(projectile); projectileInstance.transform.position = spawnPoint; projectileInstance.character = character; projectileInstance.velocity = velocity; projectileSpawned = true; } if (timer > spawnDelay + timeOfFlight) { projectileInstance.Destroy(); Destructible destructible = target.GetComponent <Destructible>(); if (destructible != null) { destructible.Damage(CombatUtils.GetDamageToDestructible(destructible, baseDamage * damageModifer)); } Done(); } }
private void OnCollisionEnter2D(Collision2D collision) { Destructible destructible = collision.gameObject.GetComponent <Destructible>(); if (destructible) { destructible.Damage(damageAmount); } }
private void OnTriggerEnter2D(Collider2D collision) { Destructible destructible = collision.GetComponent <Destructible>(); if (destructible) { destructible.Damage(damageAmount); } }
private void OnTriggerEnter2D(Collider2D collision) { if (controller?.owner != collision.gameObject && !collision.isTrigger) { Destructible destructible = collision.GetComponent <Destructible>(); if (destructible) { destructible.Damage(damageAmount); } } }
private void applyEffects() { if (effect != null) { GameObject instance = GameObject.Instantiate(effect); instance.transform.position = targetSelf ? character.position : target.position; } destructible.Damage(CombatUtils.GetDamageToDestructible(destructible, weapon.baseDamage * damageModifier)); target.AddBuffs(buffs); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject != bulletController.owner) { Destructible destructible = collision.GetComponent <Destructible>(); if (destructible) { destructible.Damage(damage); } } }
void OnTriggerEnter(Collider collision) { Destructible dest = collision.attachedRigidbody.GetComponent <Destructible>(); if (dest != null && WouldDamage(dest.gameObject)) { float damage = Random.Range(Damage.x, Damage.y); dest.Damage(OriginObject.GetComponent <Actor>(), damage, transform.position, GetComponent <Actor>().Velocity.normalized, ImpactStrength); if (DestroyOnImpact) { if (ImpactEffect.Length > 0) { Instantiate(RandomUtils.Pick(ImpactEffect), transform.position, transform.rotation); } Destroy(gameObject); } } }
private void Damage() { Collider2D[] collidersInRange = Physics2D.OverlapCircleAll(transform.position, damageRadius); foreach (Collider2D collider in collidersInRange) { // Test if object can be damaged Destructible dest = collider.GetComponent <Destructible>(); if (dest) { dest.Damage(damageAmount); } } strikesElapsed++; if (strikesElapsed < strikeCount) { Invoke("Damage", strikeInterval); } }
IEnumerator Destroy() { yield return(new WaitForSeconds(0.25f)); des.Damage(100f); }