public override void OnTriggerEnter2D(Collider2D collision) { //Debug.Log("THERE IS NO CHARACTERCOLLISION"); //monsterChecks.Enemies.Clear(); GameObject g = collision.gameObject; string t = g.tag; if (t == "Predator") { if (damageSFX != null) { sfxPlayer.PlayRandPitch(damageSFX); } CharacterData charData = collision.gameObject.GetComponent <CharacterData>(); //Debug.Log("THERE IS CHARACTER COLLISION"); if (charData != null) { if (myCharData != null) { myCharData.damageDealt += (int)meleeDamage; } if (charData.DoDamage((int)meleeDamage) && myCharData != null) { myCharData.entitiesKilled += 1; } } } if (g.GetComponent <DestructableEnvironment>() != null) { DestructableEnvironment de = g.GetComponent <DestructableEnvironment>(); de.health -= ((int)meleeDamage); de.Destroy(); } }
protected virtual void OnTriggerEnter2D(Collider2D collision) { if (collision.GetType() == typeof(BoxCollider2D)) { Physics2D.IgnoreCollision(collision, gameObject.GetComponent <CapsuleCollider2D>()); } GameObject go = collision.gameObject; // Debug.Log("Projectile trigger entered"); if (go.tag == "SkewerableObject") { return; } if (go == attacker) { return; } if ((go.tag == "Player" || go.tag == "Prey") && !hurtPlayer) { return; } if (go.tag == "Predator" && !hurtDrones) { return; } if (dropItem != null) { Instantiate(dropItem, transform.position, Quaternion.identity); } CharacterData characterData = go.GetComponent <CharacterData>(); if (characterData != null) { //myCharData.damageDealt += (int)projectileDamage; //Debug.Log("Dealing DMG"); if (characterData.DoDamage((int)projectileDamage) && myCharData != null) { myCharData.entitiesKilled += 1; } if (!penetrateTargets) { Destroy(this.gameObject); } } else if (go.tag == "ThrowThrough") { DestructableEnvironment envData = go.GetComponent <DestructableEnvironment>(); //myCharData.damageDealt += (int)projectileDamage; //Debug.Log("Dealing DMG"); if (envData != null) { envData.health -= (int)Mathf.Max(projectileDamage, 1); envData.Destroy(); if (!penetrateTargets) { Destroy(this.gameObject); } } } }