chenxin
2020-10-27 43b531f76be6e12c775a1135f6895e8fdc389a59
Assets/Scripts/TowerDefense/Towers/Tower.cs
@@ -62,6 +62,8 @@
        /// </summary>
        public Material materialTowerAttackSelf;
        public Material materialTowerWaitSelf;
        public Material materialTowerAttackOppo;
        public Material materialTowerWaitOppo;
        /// <summary>
        /// 0 空状态  1 等待状态  2 攻击状态.
@@ -73,6 +75,7 @@
        /// </summary>
        public ETowerFuntion eTowerFuntion = ETowerFuntion.NULL;
        public BulletUICtl bulletCtl = null;
        public EnergyUICtl energyCtl = null;
        /// <summary>
        /// The tower levels associated with this tower
@@ -117,12 +120,24 @@
        public float attackRise { get; set; }
        /// <summary>
        /// 用于界面部分的数据位移
        /// </summary>
        protected int progressOffset = 0;
        /// <summary>
        /// 塔防数据的局内升级
        /// </summary>
        public int inSceneTowerLevel
        {
            get; set;
        }
        public int uiProOffset
        {
            get { return this.progressOffset; }
            set { this.progressOffset = value; }
        }
        /// <summary>
        /// Gets whether the tower can level up anymore
@@ -136,16 +151,33 @@
        {
            if (!materialTowerAttackSelf) return;
            if (attack && (this.curActionState != 2))
            if (opponentSide)
            {
                currentTowerLevel.SetTowerMonsterMat(materialTowerAttackSelf);
                this.curActionState = 2;
            }
                if (attack && (this.curActionState != 2))
                {
                    currentTowerLevel.SetTowerMonsterMat(materialTowerAttackOppo);
                    this.curActionState = 2;
                }
            if ((!attack) && (this.curActionState != 1))
                if ((!attack) && (this.curActionState != 1))
                {
                    currentTowerLevel.SetTowerMonsterMat(materialTowerWaitOppo);
                    this.curActionState = 1;
                }
            }
            else
            {
                currentTowerLevel.SetTowerMonsterMat(materialTowerWaitSelf);
                this.curActionState = 1;
                if (attack && (this.curActionState != 2))
                {
                    currentTowerLevel.SetTowerMonsterMat(materialTowerAttackSelf);
                    this.curActionState = 2;
                }
                if ((!attack) && (this.curActionState != 1))
                {
                    currentTowerLevel.SetTowerMonsterMat(materialTowerWaitSelf);
                    this.curActionState = 1;
                }
            }
        }
@@ -171,11 +203,10 @@
                    if (opponentSide)
                        currentTowerLevel.SetTowerMonsterMat(materialMonsterOppo);
                    else
                    {
                        currentTowerLevel.SetTowerMonsterMat(materialMonsterSelf);
                        this.setTowerState(false);
                    }
                    // 处理Tower
                    this.setTowerState(false);
                    if (opponentSide)
                    {
@@ -195,24 +226,122 @@
                        }
                    }
                    //
                    // 根据是否是子弹塔防来决定是否显示相应的界面
                    if (this.eTowerFuntion == ETowerFuntion.BULLET)
                    {
                        BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x);
                        if (buc)
                        {
                            buc.gameObject.SetActive(true);
                            this.bulletCtl = buc;
                            buc.resetToMaxBullet();
                        }
                    }
                    // 处理塔位边上的界面.
                    OnTowerUICtrl();
                }
            }
        }
        /// <summary>
        /// 去掉当前Tower对应的界面数据.
        /// </summary>
        public void DisableTowerUICtrl()
        {
            // 根据是否是子弹塔防来决定是否显示相应的界面
            BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x, gridPosition.y);
            if ((this.eTowerFuntion == ETowerFuntion.BULLET) && (buc != null))
            {
                buc.gameObject.SetActive(false);
                this.bulletCtl = null;
            }
            EnergyUICtl euc = placementArea.GetEnergyUICtl(gridPosition.x, gridPosition.y);
            if ((eTowerFuntion == ETowerFuntion.ENERGY) && (euc != null))
            {
                // 设置数据
                euc.gameObject.SetActive(false);
                this.energyCtl = null;
            }
            return;
       }
        public int GetTowerUICtrlProgress()
        {
            // 根据是否是子弹塔防来决定是否显示相应的界面
            BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x, gridPosition.y);
            if ((this.eTowerFuntion == ETowerFuntion.BULLET) && (buc != null))
                return buc.GetCtlProgress();
            EnergyUICtl euc = placementArea.GetEnergyUICtl(gridPosition.x, gridPosition.y);
            if ((eTowerFuntion == ETowerFuntion.ENERGY) && (euc != null))
                return euc.GetCtlProgress();
            return 0;
        }
        public void SetTowerUICtlProcess( int pro)
        {
            // 根据是否是子弹塔防来决定是否显示相应的界面
            BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x, gridPosition.y);
            if ((this.eTowerFuntion == ETowerFuntion.BULLET) && (buc != null))
            {
                buc.SetCtlProcess(pro);
                progressOffset = pro;
            }
                EnergyUICtl euc = placementArea.GetEnergyUICtl(gridPosition.x, gridPosition.y);
            if ((eTowerFuntion == ETowerFuntion.ENERGY) && (euc != null))
            {
                euc.SetCtlProcess(pro);
                progressOffset = pro;
                if (progressOffset == 10)
                    progressOffset = 0;
            }
                return;
        }
        /// <summary>
        /// 充能技能相关的代码开关。包括子弹充能和时间充能
        /// </summary>
        protected void OnTowerUICtrl()
        {
            // 根据是否是子弹塔防来决定是否显示相应的界面
            BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x, gridPosition.y);
            if (buc == null) return;
            if ((this.eTowerFuntion == ETowerFuntion.BULLET) && (buc != null))
            {
                // 设置数据
                buc.gameObject.SetActive(true);
                this.bulletCtl = buc;
                buc.resetToMaxBullet();
            }
            else
            {
                // 清空数据
                buc.gameObject.SetActive(false);
                this.bulletCtl = null;
            }
            // 根据是否是能量充能来决定是否显示相应的界面.
            EnergyUICtl euc = placementArea.GetEnergyUICtl(gridPosition.x, gridPosition.y);
            if ((eTowerFuntion == ETowerFuntion.ENERGY) && (euc != null))
            {
                // 设置数据
                euc.gameObject.SetActive(true);
                this.energyCtl = euc;
                euc.SetEnergyProgress(0);
            }
            else
            {
                // 清空数据
                euc.gameObject.SetActive(false);
                this.energyCtl = null;
            }
        }
        /// <summary>
        /// 初始化当前塔防的局内升级,lvl从1开始.
        /// </summary>
        /// <param name="lvl"></param>