| | |
| | | /// 木塔最后一击是特殊攻击,需要替换projectile |
| | | /// </summary> |
| | | public GameObject woodProjectile_SP; |
| | | // |
| | | protected GameObject projectile1; |
| | | protected GameObject projectile2; |
| | | |
| | | /// <summary> |
| | | /// The list of points to launch the projectiles from |
| | |
| | | public Transform epicenter; |
| | | |
| | | /// <summary> |
| | | /// Configuration for when the tower does splash damage |
| | | /// </summary> |
| | | public bool isMultiAttack; |
| | | |
| | | /// <summary> |
| | | /// 如果是多目标攻击,最多攻击目标 |
| | | /// </summary> |
| | | public int maxAttackNum = 1; |
| | | |
| | | /// <summary> |
| | | /// The fire rate in fires-per-second |
| | | /// </summary> |
| | | [SerializeField] |
| | | private float projectileFireRate = 1; |
| | | |
| | | public float FireRate |
| | | { |
| | | get { return 1 / GetFireDuration(); } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 是否木属性数据 |
| | |
| | | /// <summary> |
| | | /// 木属性精灵蓄力特效 |
| | | /// </summary> |
| | | public GameObject WoodChargeEffect; |
| | | |
| | | private GameObject woodChargeEffect; |
| | | public ParticleSystem WoodChargeEffect; |
| | | |
| | | public Transform WoodChargeTransform; |
| | | |
| | |
| | | float rateAdd = 0; |
| | | |
| | | if (fireRateAdd != null) |
| | | rateAdd = fireRateAdd.GetFireSpeedAdd(towerPtr.attributeId); |
| | | rateAdd = fireRateAdd.GetFireSpeedAdd(towerPtr.ElfId); |
| | | return rateAdd > 1 ? rateAdd : fireSpeed; |
| | | } |
| | | } |
| | |
| | | get { return projectile == null ? null : projectile.GetComponent<Damager>(); } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// Returns the total projectile damage |
| | | /// </summary> |
| | | public float GetProjectileDamage() |
| | | { |
| | | var splash = projectile.GetComponent<SplashDamager>(); |
| | | float splashDamage = splash != null ? splash.damage : 0; |
| | | return damagerProjectile.finalDamage + splashDamage; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Initialise the RepeatingTimer |
| | | /// </summary> |
| | |
| | | woodChargeEffectTime -= Time.deltaTime; |
| | | UpdateWoodAim(); |
| | | |
| | | if (woodChargeEffectTime <= 0 && woodChargeEffect != null) |
| | | if (woodChargeEffectTime <= 0) |
| | | { |
| | | towerPtr.IsWoodCharge = false; |
| | | CancelWoodAim(); |
| | | Destroy(woodChargeEffect); |
| | | woodChargeEffect = null; |
| | | WoodChargeEffect.Stop(); |
| | | } |
| | | } |
| | | |
| | |
| | | private void UpdateWoodAim() |
| | | { |
| | | // 离得最近的 Agent |
| | | Agent agent = GetMinDistanceAgent(); |
| | | Agent agent = AgentInsManager.instance.GetMinDisAgent(waveLineID, false); |
| | | |
| | | if (agent != null) |
| | | { |
| | |
| | | ++agent.WoodAimCount; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取距离终点最近的Agent |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private Agent GetMinDistanceAgent() |
| | | { |
| | | Agent ret = null; |
| | | float minDistance = -1f; |
| | | |
| | | WaveLineAgentInsMgr[] waveLineAgentIns = AgentInsManager.instance.GetWaveLineList(); |
| | | WaveLineAgentInsMgr waveLineAgentInsMgr = waveLineAgentIns[waveLineID]; |
| | | List<Agent> agents = waveLineAgentInsMgr.listAgent; |
| | | Vector3 endPos = EndlessLevelManager.instance.GetHomeBasePosition(waveLineID + 1); |
| | | |
| | | for (int i = 0; i < agents.Count; ++i) |
| | | { |
| | | float distance = Mathf.Abs(agents[i].transform.position.z - endPos.z); |
| | | |
| | | if (minDistance < 0 || distance < minDistance) |
| | | { |
| | | minDistance = distance; |
| | | ret = agents[i]; |
| | | } |
| | | } |
| | | |
| | | return ret; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | fireState = true; |
| | | fInEnergy = finalFireSpeed; |
| | | myTower.SetFireMatSpeed(true);//设置了火宝石快速攻击 |
| | | // 设置多倍攻击速度 |
| | | fBackupTimer = m_FireTimer; |
| | | m_FireTimer = m_FireTimer / finalFireSpeed; |
| | |
| | | fInEnergy -= Time.deltaTime; |
| | | if (fInEnergy <= 0) |
| | | { |
| | | myTower.SetFireMatSpeed(false);//恢复了火宝石攻击速度 |
| | | |
| | | fireState = false; |
| | | EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.FireTowerChargeEnd); |
| | | //EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.FireTowerChargeEnd); |
| | | fInEnergy = 0.0f; |
| | | energyCalTime = 0.0f; |
| | | towerPtr.energyCtl.SetEnergyProgress(0); |
| | |
| | | Damager damager = projectile.gameObject.GetComponent<Damager>(); |
| | | float finalDamage = damager.damage; |
| | | |
| | | List<EndlessBuffConfig> list = EndlessBuffManager.instance.GetBuffListByEffectType(EndlessBuffEffectType.AttackAdd, towerPtr.attributeId); |
| | | List<EndlessBuffConfig> list = EndlessBuffManager.instance.GetBuffListByEffectType(EndlessBuffEffectType.AttackAdd, towerPtr.ElfId); |
| | | float ratio = 0; |
| | | float add = 0; |
| | | |
| | |
| | | { |
| | | if (fireState) |
| | | { |
| | | myTower.SetFireMatSpeed(true);//设置了火宝石快速攻击 |
| | | |
| | | towerPtr.PlayEnergyEffect(true); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取子弹发射时间间隔 |
| | | /// </summary> |
| | | public float GetFireDuration() |
| | | { |
| | | DecreaseTowerAttackCD endlessBuff = (DecreaseTowerAttackCD)EndlessBuffManager.instance.GetBuffInstanceByType(EndlessBuffEffectType.DecreaseTowerAttackCD); |
| | | |
| | | return endlessBuff != null ? endlessBuff.GetDecreaseCD(towerPtr.attributeId, 1 / projectileFireRate) : 1 / projectileFireRate; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Update the timers |
| | | /// </summary> |
| | | protected virtual void Update() |
| | |
| | | |
| | | if (m_TrackingEnemy != null && m_FireTimer < 0) |
| | | { |
| | | m_FireTimer = GetFireDuration(); |
| | | m_FireTimer = towerLevel.GetFireRate(); |
| | | |
| | | if (fInEnergy > 0) |
| | | m_FireTimer /= finalFireSpeed; |
| | |
| | | /// </summary> |
| | | public virtual void FireProjectile() |
| | | { |
| | | // 不再处理多子弹攻击,确保只有一个弹道 |
| | | isMultiAttack = false; |
| | | m_TrackingEnemy = targetter.GetTarget(waveLineID, bWoodAffector); |
| | | |
| | | GameObject go = damagerProjectile.gameObject; |
| | | |
| | | if (m_TrackingEnemy == null || fillBulletTime > 0) return; |
| | | |
| | | go.GetComponent<Damager>().IsEnhancedBullet = false; |
| | | Damager goDamager = go.GetComponent<Damager>(); |
| | | goDamager.IsEnhancedBullet = false; |
| | | goDamager.TowerPtr = towerPtr; |
| | | |
| | | // 处理子弹充能相关的内容 |
| | | if (towerPtr && towerPtr.bulletCtl != null) |
| | |
| | | tmpDamager.damageMulti = 10.0f; |
| | | tmpDamager.damage = damagerProjectile.damage; |
| | | tmpDamager.IsEnhancedBullet = true; |
| | | tmpDamager.TowerPtr = towerPtr; |
| | | } |
| | | |
| | | // 下一颗子弹是强化子弹,然后直接蓄力 |
| | |
| | | woodRemainChargeTime = decreaseWoodChargeTime.GetWoodChargeTime(woodChargeTime); |
| | | |
| | | woodChargeEffectTime = woodRemainChargeTime + 0.5f / towerLevel.ActionAnimator.speed; |
| | | woodChargeEffect = Instantiate(WoodChargeEffect); |
| | | woodChargeEffect.transform.SetParent(gameObject.transform); |
| | | woodChargeEffect.transform.SetPositionAndRotation(WoodChargeTransform.position, WoodChargeTransform.rotation); |
| | | ParticleSystem ps = woodChargeEffect.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps.Play(); |
| | | WoodChargeEffect.Play(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (towerPtr) |
| | | towerPtr.setTowerState(true); |
| | | } |
| | | |
| | | if (isMultiAttack) |
| | | if (Targetter.bSearchTarget) |
| | | { |
| | | List<Targetable> enemies = towerTargetter.GetAllTargets(); |
| | | if ((enemies != null) && (Targetter.bSearchTarget)) |
| | | m_Launcher.Launch(enemies, projectile, projectilePoints, maxAttackNum); |
| | | } |
| | | else |
| | | { |
| | | if (Targetter.bSearchTarget) |
| | | { |
| | | m_Launcher.Launch(m_TrackingEnemy, go, projectilePoints); |
| | | if (AudioSourceManager.Ins) |
| | | AudioSourceManager.Ins.Play(audioEnum); |
| | | } |
| | | } |
| | | if (randomAudioSource != null) |
| | | { |
| | | if (Targetter.bSearchTarget) |
| | | randomAudioSource.PlayRandomClip(); |
| | | m_Launcher.Launch(m_TrackingEnemy, go, projectilePoints); |
| | | if (AudioSourceManager.Ins) |
| | | AudioSourceManager.Ins.Play(audioEnum); |
| | | } |
| | | } |
| | | |