public void affect(GameObject target) { var e = target.GetComponent <ITarget>(); if (e != null && target != this.shooter && !e.invulnerable) { var d = this.transform.position - target.transform.position; float damage = dampeningFunction.Evaluate(Mathf.Clamp(Vector3.Magnitude(d) / this.effectRadius, 0f, 1f)) * this.damage; if (curOther == target) { damage = this.damage; Debug.Log("Use this damage"); } Debug.Log("damage: " + damage); float blocked = damage * Mathf.Clamp((e.armor), 0.1f, 1f); float before = e.hitPoints; float rawDamage = damage - blocked; e.hitPoints -= rawDamage; StatisticManager.calculateDamageStatistics(this, target, damage, rawDamage); if (this.shooter.tag == "Player") { StatisticManager.calculateHitStatistics(this.shooter.GetComponent <Player>(), target.tag == "Player" ? StatisticManager.Targets.enemy : StatisticManager.Targets.spawner, 1); } //Weaken armor by blocked amount. Divider is just some weakening value that needs to be tweaked. e.armor -= blocked / 15f; if (e.armor < 0) { e.armor = 0f; } if (e.dead && before > 0) { // Target just died StatisticManager.calculateKillStatistics(this, target); } } }
public void affect(GameObject target) { var e = target.GetComponent <ITarget>(); if (!GameConfig.friendlyFire && this.shooter != null && this.shooter.tag == "Player" && target.tag == "Player") { return; } if (e != null && target != this.shooter && !e.invulnerable) { float blocked = this.damage * Mathf.Clamp((e.armor), 0.1f, 1f); float before = e.hitPoints; float rawDamage = this.damage - blocked; e.hitPoints -= rawDamage; StatisticManager.calculateDamageStatistics(this, target, this.damage, rawDamage); if (this.shooter.tag == "Player") { StatisticManager.calculateHitStatistics( this.shooter.GetComponent <Player>(), target.tag == "Enemy" ? StatisticManager.Targets.enemy : StatisticManager.Targets.spawner, this._bulletToShotRatio); } //Weaken armor by blocked amount. Divider is just some weakening value that needs to be tweaked. e.armor -= blocked / 30f; if (e.armor < 0) { e.armor = 0f; } if (e.dead && before > 0) { // Target just died StatisticManager.calculateKillStatistics(this, target); } } }