From 0e8a4a629f0db7d9dc7b8c3b9795a195c279f7b9 Mon Sep 17 00:00:00 2001 From: wangguan <wangguan@kt007.com> Date: Mon, 26 Oct 2020 14:25:48 +0800 Subject: [PATCH] Merge branch 'master' of ssh://172.16.1.52:8091/GemBattle --- Assets/Scripts/TowerDefense/Towers/Tower.cs | 95 +++++++++++++++++++++++++++++++++++------------ 1 files changed, 71 insertions(+), 24 deletions(-) diff --git a/Assets/Scripts/TowerDefense/Towers/Tower.cs b/Assets/Scripts/TowerDefense/Towers/Tower.cs index 4aa7604..3709139 100644 --- a/Assets/Scripts/TowerDefense/Towers/Tower.cs +++ b/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 @@ -137,16 +140,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; + } } } @@ -172,11 +192,10 @@ if (opponentSide) currentTowerLevel.SetTowerMonsterMat(materialMonsterOppo); else - { currentTowerLevel.SetTowerMonsterMat(materialMonsterSelf); - this.setTowerState(false); - } - + + // 处理Tower + this.setTowerState(false); if (opponentSide) { @@ -196,24 +215,52 @@ } } - // - // 根据是否是子弹塔防来决定是否显示相应的界面 - if (this.eTowerFuntion == ETowerFuntion.BULLET) - { - BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x); - /* - if (buc) - { - buc.gameObject.SetActive(true); - this.bulletCtl = buc; - buc.resetToMaxBullet(); - }*/ - } + // 处理塔位边上的界面. + OnTowerUICtrl(); } } } + protected void OnTowerUICtrl() + { + // + // 根据是否是子弹塔防来决定是否显示相应的界面 + BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x); + + 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); + 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> -- Gitblit v1.9.1