| | |
| | | using TowerDefense.Agents; |
| | | using TowerDefense.UI.HUD; |
| | | using UnityEngine; |
| | | using TowerDefense.Level; |
| | | using System.Collections.Generic; |
| | | using KTGMGemClient; |
| | | |
| | |
| | | /// </summary> |
| | | /// <param name="enemy"></param> |
| | | /// <param name="attributeId">子弹的属性id</param> |
| | | public void DealDamage(Targetable enemy, int attributeId = -1) |
| | | public void DealDamage(Targetable enemy, int attributeId = -1, bool isEnhancedBullet = false) |
| | | { |
| | | switch ((enemy as Agent).AgentType) |
| | | { |
| | | case SpawnAgentType.Normal: |
| | | HandleNormal(enemy); |
| | | HandleNormal(enemy, isEnhancedBullet); |
| | | break; |
| | | case SpawnAgentType.BubbleBomb: |
| | | HandleBubbleBomb(enemy); |
| | |
| | | private bool IsCrit() |
| | | { |
| | | CritProbabilityAdd critProbabilityAdd = (CritProbabilityAdd)EndlessBuffManager.instance.GetBuffInstanceByType(EndlessBuffEffectType.CritProbabilityAdd); |
| | | |
| | | if (critProbabilityAdd == null) return false; |
| | | |
| | | float crit = critProbabilityAdd.GetCrit(TowerPtr.attributeId); |
| | | float random = UnityEngine.Random.Range(0, 1f); |
| | | |
| | |
| | | private float GetCritDamageRate() |
| | | { |
| | | CritDamageAdd critDamageAdd = (CritDamageAdd)EndlessBuffManager.instance.GetBuffInstanceByType(EndlessBuffEffectType.CritDamageAdd); |
| | | return critDamageAdd.GetCritDamageRate(TowerPtr.attributeId); |
| | | |
| | | return critDamageAdd == null ? 0 : critDamageAdd.GetCritDamageRate(TowerPtr.attributeId); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 处理普通小怪和boss收到的伤害 |
| | | /// </summary> |
| | | /// <param name="enemy"></param> |
| | | private void HandleNormal(Targetable enemy) |
| | | private void HandleNormal(Targetable enemy, bool isEnhancedBullet) |
| | | { |
| | | float finalDamage = damager.finalDamage; |
| | | bool crit = IsCrit(); |
| | |
| | | } |
| | | |
| | | // 播放受击动画: |
| | | if ((!enemy.isDead) && (enemy.liveID == tid)) |
| | | if (!enemy.isDead && enemy.liveID == tid) |
| | | { |
| | | (enemy as Agent).PlayOnHit(); |
| | | |
| | | // 如果是玉米强化子弹的攻击,要处理击退的效果 |
| | | if (TowerPtr != null && isEnhancedBullet) |
| | | (enemy as Agent).AgentBeRepelled(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | case 2: // 减速. |
| | | SlowDown slowDown = (SlowDown)EndlessBuffManager.instance.GetBuffInstanceByType(EndlessBuffEffectType.SlowDown); |
| | | enemy.addSpeedSlowRate(0.25f + slowDown.GetSlowDownAdd(TowerPtr.attributeId)); |
| | | enemy.addSpeedSlowRate(0.15f + (slowDown != null ? slowDown.GetSlowDownAdd(TowerPtr.attributeId) : 0)); |
| | | enemy.SetTargetableMatColor(Color.blue); |
| | | break; |
| | | case 3: // 中毒 |