From 6f16dfb8bcebe67aeb95ded0d8b644af4932e690 Mon Sep 17 00:00:00 2001 From: chenxin <chenxin6991@163.com> Date: Mon, 26 Oct 2020 21:00:32 +0800 Subject: [PATCH] 无尽模式新手步骤到水元素放置塔位完成 --- Assets/Scripts/TowerDefense/Towers/Tower.cs | 101 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 93 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/TowerDefense/Towers/Tower.cs b/Assets/Scripts/TowerDefense/Towers/Tower.cs index 9b7d72b..2c836dd 100644 --- a/Assets/Scripts/TowerDefense/Towers/Tower.cs +++ b/Assets/Scripts/TowerDefense/Towers/Tower.cs @@ -58,9 +58,24 @@ 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; + public EnergyUICtl energyCtl = null; /// <summary> /// The tower levels associated with this tower @@ -104,6 +119,7 @@ /// </summary> public float attackRise { get; set; } + /// <summary> /// 塔防数据的局内升级 /// </summary> @@ -118,6 +134,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 +194,9 @@ else currentTowerLevel.SetTowerMonsterMat(materialMonsterSelf); + // 处理Tower + this.setTowerState(false); + if (opponentSide) { OpponentMgr.instance.SetTowerAttID(gridPosition.x, attributeId, this.currentLevel); @@ -162,19 +215,51 @@ } } - // - // 根据是否是子弹塔防来决定是否显示相应的界面.WORK START: 处理出来下一步的子弹减少和对应的充子弹时间. - if (this.eTowerFuntion == ETowerFuntion.BULLET) - { - BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x); - if (buc) - buc.gameObject.SetActive(true); - } + // 处理塔位边上的界面. + OnTowerUICtrl(); } } } + 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> -- Gitblit v1.9.1