From 74daf5509be4fc140fd1bdb6d4df5f1c1002e368 Mon Sep 17 00:00:00 2001 From: wangguan <wangguan@kt007.com> Date: Thu, 22 Oct 2020 17:28:08 +0800 Subject: [PATCH] Merge branch 'master' of ssh://172.16.1.52:8091/GemBattle --- Assets/Scripts/TowerDefense/Towers/Tower.cs | 71 +++++++++++++++++++++++++++++++++-- 1 files changed, 66 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/TowerDefense/Towers/Tower.cs b/Assets/Scripts/TowerDefense/Towers/Tower.cs index 9b7d72b..020f906 100644 --- a/Assets/Scripts/TowerDefense/Towers/Tower.cs +++ b/Assets/Scripts/TowerDefense/Towers/Tower.cs @@ -58,9 +58,23 @@ public Material materialMonsterOppo; /// <summary> + /// 当前塔防对应的攻击和等待Mat. + /// </summary> + public Material materialTowerAttackSelf; + public Material materialTowerWaitSelf; + public Material materialTowerAttackOppo; + public Material materialTowerWaitOppo; + + /// <summary> + /// 0 空状态 1 等待状态 2 攻击状态. + /// </summary> + protected int curActionState = 0; + + /// <summary> /// 塔防对应的充能状态. /// </summary> public ETowerFuntion eTowerFuntion = ETowerFuntion.NULL; + public BulletUICtl bulletCtl = null; /// <summary> /// The tower levels associated with this tower @@ -104,6 +118,7 @@ /// </summary> public float attackRise { get; set; } + /// <summary> /// 塔防数据的局内升级 /// </summary> @@ -118,6 +133,40 @@ public bool isAtMaxLevel { get { return currentLevel == levels.Length - 1; } + } + + public void setTowerState(bool attack) + { + if (!materialTowerAttackSelf) return; + + if( opponentSide) + { + if (attack && (this.curActionState != 2)) + { + currentTowerLevel.SetTowerMonsterMat(materialTowerAttackOppo); + this.curActionState = 2; + } + + if ((!attack) && (this.curActionState != 1)) + { + currentTowerLevel.SetTowerMonsterMat( materialTowerWaitOppo ); + this.curActionState = 1; + } + } + else + { + if (attack && (this.curActionState != 2)) + { + currentTowerLevel.SetTowerMonsterMat(materialTowerAttackSelf); + this.curActionState = 2; + } + + if ((!attack) && (this.curActionState != 1)) + { + currentTowerLevel.SetTowerMonsterMat(materialTowerWaitSelf); + this.curActionState = 1; + } + } } /// <summary> @@ -144,6 +193,10 @@ else currentTowerLevel.SetTowerMonsterMat(materialMonsterSelf); + // 处理Tower + this.setTowerState(false); + + if (opponentSide) { OpponentMgr.instance.SetTowerAttID(gridPosition.x, attributeId, this.currentLevel); @@ -163,12 +216,20 @@ } // - // 根据是否是子弹塔防来决定是否显示相应的界面.WORK START: 处理出来下一步的子弹减少和对应的充子弹时间. - if (this.eTowerFuntion == ETowerFuntion.BULLET) + // 根据是否是子弹塔防来决定是否显示相应的界面 + BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x); + if ( (this.eTowerFuntion == ETowerFuntion.BULLET) && (buc != null ) ) { - BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x); - if (buc) - buc.gameObject.SetActive(true); + // 设置数据 + buc.gameObject.SetActive(true); + this.bulletCtl = buc; + buc.resetToMaxBullet(); + } + else + { + // 清空数据 + buc.gameObject.SetActive(false); + this.bulletCtl = null; } } -- Gitblit v1.9.1