| | |
| | | /// </summary> |
| | | protected Targetable m_TrackingEnemy; |
| | | |
| | | public TowerLevel towerLevel; |
| | | |
| | | /// <summary> |
| | | /// 处理装弹时间. |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | protected virtual void SetUpTimers() |
| | | { |
| | | m_FireTimer = 1 / fireRate; |
| | | m_Launcher = GetComponent<ILauncher>(); |
| | | } |
| | | |
| | |
| | | updateTowerSkillData(); |
| | | |
| | | m_FireTimer -= Time.deltaTime; |
| | | |
| | | if (trackingEnemy == null) |
| | | m_TrackingEnemy = targetter.GetTarget(waveLineID, bWoodAffector); |
| | | if (trackingEnemy != null && m_FireTimer <= 0.0f) |
| | | { |
| | | OnFireTimer(); |
| | | m_FireTimer = 1 / fireRate; |
| | | // 多倍攻速: |
| | | if (fInEnergy > 0.0f) |
| | | m_FireTimer = m_FireTimer / 5.0f; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Fired at every poll of the fire rate timer |
| | | /// </summary> |
| | | protected virtual void OnFireTimer() |
| | | { |
| | | if (fireCondition != null) |
| | | if (trackingEnemy != null) |
| | | { |
| | | if (!fireCondition()) |
| | | // m_FireTimer = 1 / fireRate; |
| | | |
| | | if (fInEnergy > 0) |
| | | { |
| | | return; |
| | | m_FireTimer = m_FireTimer / 5f; |
| | | towerLevel.FireSpeed = 5f; |
| | | } |
| | | else |
| | | towerLevel.FireSpeed = 1f; |
| | | |
| | | towerLevel.ChangeState(TowerActionState.Attack); |
| | | } |
| | | FireProjectile(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Common logic when attacking |
| | | /// 调用攻击的核心函数,由这个函数发起真正的攻击,多目标或者单目标 |
| | | /// </summary> |
| | | protected virtual void FireProjectile() |
| | | public virtual void FireProjectile() |
| | | { |
| | | // 不再处理多子弹攻击,确保只有一个弹道 |
| | | isMultiAttack = false; |
| | | m_TrackingEnemy = targetter.GetTarget(waveLineID, bWoodAffector); |
| | | if ((m_TrackingEnemy == null) || (fillBulletTime > 0)) |
| | | { |
| | | if (this.towerPtr) |
| | | towerPtr.setTowerState(false); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | if (this.towerPtr) |
| | | towerPtr.setTowerState(true); |
| | | } |
| | | |
| | | GameObject go = damagerProjectile.gameObject; |
| | | |
| | | if (m_TrackingEnemy == null || fillBulletTime > 0) return; |
| | | |
| | | // 处理子弹充能相关的内容 |
| | | if (towerPtr && (towerPtr.bulletCtl != null)) |
| | | { |