//does damage to target by applying burn effect and dealing damage separately private void DoDamage(Transform other) { float temDmg = Damage; temDmg = temDmg / 3; EnemyHealth healthOfEnemy = other.GetComponent <EnemyHealth>(); ApplyingDebuff newDebuf = new ApplyingDebuff(); newDebuf.typeOfDebuff = ApplyingDebuff.DebuffType.Fire; newDebuf.debuffDamage = temDmg; newDebuf.debuffDuration = BurnDuration; healthOfEnemy.DealDebuff(newDebuf); healthOfEnemy.TakeDamage(Damage); }
private bool isIce; //checks for element of the bullet //handles how the cannon bullet collides using the aoe public override void HandleCollision(Collider other) { if (other.gameObject.tag != "Enemy" || other.gameObject.tag != "Tower") { //Calculate the Aoe damage Collider[] targets = Physics.OverlapSphere(this.transform.position, Range, EnemyLayer); for (int i = 0; i < targets.Length; i++) { EnemyHealth healthOfEnemy = targets[i].GetComponent <EnemyHealth>(); float damageCalculation; Vector3 explostionToTarget = targets[i].transform.position - this.transform.position; float explosionDist = explostionToTarget.magnitude; float relativeDistance = (Range - explosionDist) / Range; damageCalculation = relativeDistance * Damage; damageCalculation = Mathf.FloorToInt(damageCalculation); healthOfEnemy.TakeDamage(damageCalculation); ApplyingDebuff newDebuf = new ApplyingDebuff(); if (isIce) { newDebuf.debuffDamage = 0; newDebuf.debuffDuration = 4f; newDebuf.typeOfDebuff = ApplyingDebuff.DebuffType.Freeze; } else { float temDmg = Damage; temDmg = temDmg / 3; newDebuf.typeOfDebuff = ApplyingDebuff.DebuffType.Fire; newDebuf.debuffDamage = temDmg; newDebuf.debuffDuration = 3; } healthOfEnemy.DealDebuff(newDebuf); } DisableBullet(); } }