wangguan
2020-11-07 ecf4d19b87cd196970515e9669b5e43f9ab65500
Assets/Scripts/TowerDefense/Towers/Tower.cs
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System;
using ActionGameFramework.Health;
using Core.Utilities;
using TowerDefense.Level;
@@ -124,6 +125,8 @@
        /// </summary>
        protected int progressOffset = 0;
        public bool PlayWaveLineFlash { get; set; } = true;
        /// <summary>
        /// 塔防数据的局内升级
        /// </summary>
@@ -134,7 +137,7 @@
        public int uiProOffset
        {
            get { return this.progressOffset; }
            get { return this.progressOffset; }
            set { this.progressOffset = value; }
        }
@@ -155,13 +158,13 @@
            {
                if (attack && (this.curActionState != 2))
                {
                    currentTowerLevel.SetTowerMonsterMat(materialTowerAttackOppo);
                    currentTowerLevel.SetTowerMonsterMat(materialTowerAttackOppo, true);
                    this.curActionState = 2;
                }
                if ((!attack) && (this.curActionState != 1))
                {
                    currentTowerLevel.SetTowerMonsterMat(materialTowerWaitOppo);
                    currentTowerLevel.SetTowerMonsterMat(materialTowerWaitOppo, false);
                    this.curActionState = 1;
                }
            }
@@ -169,13 +172,13 @@
            {
                if (attack && (this.curActionState != 2))
                {
                    currentTowerLevel.SetTowerMonsterMat(materialTowerAttackSelf);
                    currentTowerLevel.SetTowerMonsterMat(materialTowerAttackSelf, true);
                    this.curActionState = 2;
                }
                if ((!attack) && (this.curActionState != 1))
                {
                    currentTowerLevel.SetTowerMonsterMat(materialTowerWaitSelf);
                    currentTowerLevel.SetTowerMonsterMat(materialTowerWaitSelf, false);
                    this.curActionState = 1;
                }
            }
@@ -190,30 +193,20 @@
        /// 播放充能状态特效.
        /// </summary>
        /// <param name="play"></param>
        public void PlayEnergyEffect( bool play)
        public void PlayEnergyEffect(bool play)
        {
            if( play)
            if (this.energyCtl)
                energyCtl.gameObject.SetActive(!play);
            if (!opponentSide)
            {
                if( !opponentSide)
                {
                    ((TowerPlacementGrid)GameUI.instance.selfTowerPlaceArea).PlayEnergyEffect(gridPosition.x, true);
                }
                else
                {
                    ((TowerPlacementGrid)OpponentMgr.instance.m_CurrentArea).PlayEnergyEffect(gridPosition.x, true);
                }
                if (GameUI.instanceExists)
                    ((TowerPlacementGrid)GameUI.instance.selfTowerPlaceArea).PlayEnergyEffect(gridPosition.x, play);
                else if (EndlessGameUI.instanceExists)
                    ((TowerPlacementGridEndless)EndlessGameUI.instance.selfTowerPlaceArea).PlayEnergyEffect(gridPosition.x, gridPosition.y, play);
            }
            else
            {
                if ( !opponentSide)
                {
                    ((TowerPlacementGrid)GameUI.instance.selfTowerPlaceArea).PlayEnergyEffect(gridPosition.x, false);
                }
                else
                {
                    ((TowerPlacementGrid)OpponentMgr.instance.m_CurrentArea).PlayEnergyEffect(gridPosition.x, false);
                }
            }
                ((TowerPlacementGrid)OpponentMgr.instance.m_CurrentArea).PlayEnergyEffect(gridPosition.x, play);
        }
        /// <summary>
@@ -231,9 +224,9 @@
                if (value)
                {
                    if (opponentSide)
                        currentTowerLevel.SetTowerMonsterMat(materialMonsterOppo);
                        currentTowerLevel.SetTowerMonsterMat(materialTowerWaitOppo, false);
                    else
                        currentTowerLevel.SetTowerMonsterMat(materialMonsterSelf);
                        currentTowerLevel.SetTowerMonsterMat(materialTowerWaitSelf, false);
                    // 处理Tower
                    this.setTowerState(false);
@@ -252,7 +245,7 @@
                        else if (EndlessLevelManager.instanceExists)
                        {
                            EndlessLevelManager.instance.SetTowerAttID(gridPosition.x, attributeId, this.currentLevel);
                            EndlessWaveLineManager.instance.AttackTowerFixed(gridPosition.x);
                            EndlessWaveLineManager.instance.AttackTowerFixed(gridPosition.x, PlayWaveLineFlash);
                        }
                    }
@@ -286,7 +279,7 @@
            }
            return;
       }
        }
        public int GetTowerUICtrlProgress()
        {
@@ -303,7 +296,7 @@
            return 0;
        }
        public void SetTowerUICtlProcess( int pro)
        public void SetTowerUICtlProcess(int pro)
        {
            // 根据是否是子弹塔防来决定是否显示相应的界面
            BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x, gridPosition.y);
@@ -314,7 +307,7 @@
                progressOffset = pro;
            }
                EnergyUICtl euc = placementArea.GetEnergyUICtl(gridPosition.x, gridPosition.y);
            EnergyUICtl euc = placementArea.GetEnergyUICtl(gridPosition.x, gridPosition.y);
            if ((eTowerFuntion == ETowerFuntion.ENERGY) && (euc != null))
            {
                euc.SetCtlProcess(pro);
@@ -325,7 +318,7 @@
                return;
            return;
        }
@@ -384,7 +377,8 @@
                return;
            }
            // 设置攻击数据的加强,暂时是测试数据,后面需要读取表格数据处理:
            float damageAdd = (inSceneTowerLevel - 1) * this.INSCENE_TU_DAMAGE;
            float damageAdd = 0;
            // float damageAdd = (inSceneTowerLevel - 1) * this.INSCENE_TU_DAMAGE;
            for (int ti = 0; ti < this.levels.Length; ti++)
            {
                if (levels[ti].levelDamager)
@@ -471,6 +465,16 @@
        public Action towerDestroyed;
        /// <summary>
        /// 放置到目标位置
        /// </summary>
        /// <param name="destination"></param>
        public virtual void SetToDestination(IntVector2 destination)
        {
            gridPosition = destination;
            transform.position = placementArea.GridToWorld(destination, dimensions);
        }
        /// <summary>
        /// Provide the tower with data to initialize with
        /// </summary>
        /// <param name="targetArea">The placement area configuration</param>
@@ -507,6 +511,20 @@
            // 
            // 初始化当前的局内Tower等级数据
            this.initInSceneTowerLevel(SceneTowerLvl.getInSceneTowerLvl(this.towerName));
            StartCoroutine(ResetScale());
        }
        IEnumerator ResetScale(){
            yield return new WaitForSeconds(0.2f);
            if (gridPosition.y > 1)
            {
                currentTowerLevel.ResetScale();
            }
            else
            {
                currentTowerLevel.NormalScale();
            }
        }
        /// <summary>