| | |
| | | /// 木塔最后一击是特殊攻击,需要替换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; |
| | | } |
| | | } |
| | |
| | | towerTargetter.alignment = affectorAlignment; |
| | | towerTargetter.acquiredTarget += OnAcquiredTarget; |
| | | // towerTargetter.lostTarget += OnLostTarget; |
| | | GetAudioEnum(); |
| | | |
| | | myTower = transform.parent.GetComponent<TowerLevel>(); |
| | | GetAudioEnum(); |
| | | |
| | | } |
| | | private AudioEnum audioEnum;//当前音乐的种类 |
| | | bool isWoodAudio; |
| | | |
| | | void GetAudioEnum() |
| | | { |
| | | if (transform.parent.name.StartsWith("GrowUpTower")) |
| | | //小怪身上也有这个脚本,塔的名字做了更改,所以判断条件需要变成transform.parent.parent |
| | | if (transform.parent.parent != null) |
| | | { |
| | | //火元素 |
| | | audioEnum = AudioEnum.FireTAttack; |
| | | if (transform.parent.parent.name.StartsWith("GrowUpTower")) |
| | | { |
| | | //火元素 |
| | | audioEnum = AudioEnum.FireTAttack; |
| | | } |
| | | else if (transform.parent.parent.name.StartsWith("BlinkTower")) |
| | | { |
| | | //木元素 |
| | | audioEnum = AudioEnum.WoodTAttack; |
| | | } |
| | | else if (transform.parent.parent.name.StartsWith("CopyCatTower")) |
| | | { |
| | | //水元素 |
| | | audioEnum = AudioEnum.WaterTAttack; |
| | | } |
| | | } |
| | | else if (transform.parent.name.StartsWith("BlinkTower")) |
| | | { |
| | | //木元素 |
| | | audioEnum = AudioEnum.WoodTAttack; |
| | | } |
| | | else if (transform.parent.name.StartsWith("CopyCatTower")) |
| | | { |
| | | //水元素 |
| | | audioEnum = AudioEnum.WaterTAttack; |
| | | } |
| | | |
| | | } |
| | | |
| | | void OnDestroy() |
| | | { |
| | | towerTargetter.acquiredTarget -= OnAcquiredTarget; |
| | | // towerTargetter.acquiredTarget -= OnAcquiredTarget; |
| | | // towerTargetter.lostTarget -= OnLostTarget; |
| | | } |
| | | |
| | |
| | | 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> |
| | |
| | | bool fireState = false; |
| | | protected void updateTowerSkillData() |
| | | { |
| | | HandleBullet(); |
| | | HandleEnergy(); |
| | | HandleFreezeBreath(); |
| | | if (towerLevel != null && towerLevel.ParentTower != null && towerLevel.ParentTower.ElfId == 301) |
| | | HandleBullet(); |
| | | if (towerLevel != null && towerLevel.ParentTower != null && towerLevel.ParentTower.ElfId == 101) |
| | | HandleEnergy(); |
| | | if (towerLevel != null && towerLevel.ParentTower != null && towerLevel.ParentTower.ElfId == 201) |
| | | HandleFreezeBreath(); |
| | | } |
| | | |
| | | // 处理木精灵装填子弹 |
| | |
| | | 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); |
| | |
| | | if (towerPtr && towerPtr.FreezeBreathCtrl) |
| | | { |
| | | Damager damager = projectile.gameObject.GetComponent<Damager>(); |
| | | float finalDamage = damager.damage; |
| | | |
| | | List<EndlessBuffConfig> list = EndlessBuffManager.instance.GetBuffListByEffectType(EndlessBuffEffectType.AttackAdd, towerPtr.attributeId); |
| | | float ratio = 0; |
| | | float add = 0; |
| | | |
| | | if (list.Count > 0) |
| | | { |
| | | for (int i = 0; i < list.Count; ++i) |
| | | { |
| | | ratio += list[i].Config.buff_effect[1]; |
| | | add += list[i].Config.buff_effect[2]; |
| | | } |
| | | } |
| | | |
| | | finalDamage += (ratio / 100f) * finalDamage + add; |
| | | |
| | | if (inFreezeBreath <= 0) |
| | | { |
| | |
| | | towerPtr.PlayFreezeBreathEffect(true); |
| | | towerPtr.FreezeBreathCtrl.ReleaseCount = 1; |
| | | towerPtr.FreezeBreathCtrl.PlayFreezeEffect(waveLineID); |
| | | towerPtr.FreezeBreathCtrl.ReleaseFreeze(waveLineID, finalDamage, damager.alignmentProvider); |
| | | towerPtr.FreezeBreathCtrl.ReleaseFreeze(waveLineID, towerPtr, damager.alignmentProvider); |
| | | } |
| | | } |
| | | else |
| | |
| | | if (interval == time * (towerPtr.FreezeBreathCtrl.DamageCount - towerPtr.FreezeBreathCtrl.ReleaseCount - 1) + offset && towerPtr.FreezeBreathCtrl.ReleaseCount < towerPtr.FreezeBreathCtrl.DamageCount) |
| | | { |
| | | ++towerPtr.FreezeBreathCtrl.ReleaseCount; |
| | | towerPtr.FreezeBreathCtrl.ReleaseFreeze(waveLineID, finalDamage, damager.alignmentProvider); |
| | | towerPtr.FreezeBreathCtrl.ReleaseFreeze(waveLineID, towerPtr, damager.alignmentProvider); |
| | | } |
| | | |
| | | if (inFreezeBreath <= 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_Launcher == null) return; |
| | | if (m_Launcher == null || towerPtr != null && !towerPtr.CanAttack) return; |
| | | |
| | | // 处理当前Affector所在Tower对应的技能 |
| | | updateTowerSkillData(); |
| | |
| | | |
| | | 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; |
| | | GameObject go = projectile; |
| | | |
| | | 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) |
| | |
| | | //这里需要替换特效 |
| | | var poolable = Core.Utilities.Poolable.TryGetPoolable<Core.Utilities.Poolable>(woodProjectile_SP); |
| | | go = poolable.gameObject; |
| | | //go = Instantiate(woodProjectile_SP); |
| | | Damager tmpDamager = go.GetComponent<Damager>(); |
| | | tmpDamager.damageMulti = 10.0f; |
| | | tmpDamager.damage = damagerProjectile.damage; |
| | | tmpDamager.IsEnhancedBullet = true; |
| | | tmpDamager.TowerPtr = towerPtr; |
| | | isWoodAudio = true; |
| | | } |
| | | |
| | | // 下一颗子弹是强化子弹,然后直接蓄力 |
| | |
| | | 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) |
| | | { |
| | | m_Launcher.Launch(m_TrackingEnemy, go, projectilePoints); |
| | | if (AudioSourceManager.Ins) |
| | | if (isWoodAudio) |
| | | { |
| | | isWoodAudio = false; |
| | | AudioSourceManager.Ins.Play(AudioEnum.WoodSkill); |
| | | } |
| | | else |
| | | { |
| | | AudioSourceManager.Ins.Play(audioEnum); |
| | | } |
| | | } |
| | | } |
| | | if (randomAudioSource != null) |
| | | { |
| | | if (Targetter.bSearchTarget) |
| | | randomAudioSource.PlayRandomClip(); |
| | | } |
| | | } |
| | | |