wangguan
2020-11-11 fd1ac06475bf155996ac4aed6307eb43f9e04f53
Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs
@@ -176,18 +176,37 @@
            towerTargetter.ResetTargetter();
            towerTargetter.alignment = affectorAlignment;
            towerTargetter.acquiredTarget += OnAcquiredTarget;
            towerTargetter.lostTarget += OnLostTarget;
            // towerTargetter.lostTarget += OnLostTarget;
            GetAudioEnum();
            myTower = transform.parent.GetComponent<TowerLevel>();
        }
        private AudioEnum audioEnum;//当前音乐的种类
        void GetAudioEnum()
        {
            if (transform.parent.name.StartsWith("GrowUpTower"))
            {
                //火元素
                audioEnum = AudioEnum.FireTAttack;
            }
            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.lostTarget -= OnLostTarget;
        }
        void OnLostTarget()
        {
            m_TrackingEnemy = null;
            // towerTargetter.lostTarget -= OnLostTarget;
        }
        void OnAcquiredTarget(Targetable acquiredTarget)
@@ -230,6 +249,7 @@
            m_Launcher = GetComponent<ILauncher>();
        }
        TowerLevel myTower;
        protected void updateTowerSkillData()
        {
@@ -264,7 +284,7 @@
                    if (proint == 10)
                    {
                        fInEnergy = 5.0f;
                        myTower.SetFireMatSpeed(true);//设置了火宝石快速攻击
                        // 设置多倍攻击速度
                        fBackupTimer = m_FireTimer;
                        m_FireTimer = m_FireTimer / 3.0f;
@@ -278,6 +298,8 @@
                    fInEnergy -= Time.deltaTime;
                    if (fInEnergy <= 0)
                    {
                        myTower.SetFireMatSpeed(false);//恢复了火宝石攻击速度
                        EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.FireTowerChargeEnd);
                        fInEnergy = 0.0f;
                        this.energyCalTime = 0.0f;
@@ -299,8 +321,6 @@
        /// </summary>
        protected virtual void Update()
        {
            // Agent 和 Tower 身上都有 AttackAffector,如果获取不到 ILauncher 说明是 Agent
            // 目前为止,Agent 并不需要发射子弹攻击
            if (m_Launcher == null) return;
            // 处理当前Affector所在Tower对应的技能
@@ -313,10 +333,9 @@
            {
                OnFireTimer();
                m_FireTimer = 1 / fireRate;
                // 多倍攻速:
                if (fInEnergy > 0.0f)
                    m_FireTimer = m_FireTimer / 3.0f;
                    m_FireTimer = m_FireTimer / 5.0f;
            }
        }
@@ -364,9 +383,14 @@
                // 
                if (bnum == 0)
                {
                    damagerProjectile.damageMulti = 2.0f;
                    damagerProjectile.damageMulti = 10.0f;
                    fillBulletTime = 2.0f;
                }
            }
            else
            {
                if (this.towerPtr)
                    towerPtr.setTowerState(true);
            }
            if (isMultiAttack)
@@ -378,7 +402,11 @@
            else
            {
                if (Targetter.bSearchTarget)
                {
                    m_Launcher.Launch(m_TrackingEnemy, damagerProjectile.gameObject, projectilePoints);
                    if (AudioSourceManager.Ins)
                        AudioSourceManager.Ins.Play(audioEnum);
                }
            }
            if (randomAudioSource != null)
            {