//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); }
//checks for all nearby enemies and provides them with the buff corresponding to the id private void ExtendRangeOfAllies() { Collider[] allies = Physics.OverlapSphere(this.transform.position, Range, EnemyLayer); foreach (Collider ally in allies) { if (ally.gameObject != this.gameObject) { ApplyingDebuff buffType = new ApplyingDebuff(); buffType.debuffDamage = TowerStats.towerTier[CurrentTowerTier].damage; buffType.debuffDuration = repeatRate; buffType.typeOfDebuff = (ApplyingDebuff.DebuffType)buffId; ally.GetComponent <Tower>().AddBuff(buffType); } } }
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(); } }