| | |
| | | using System; |
| | | using System.Collections; |
| | | using System; |
| | | using ActionGameFramework.Health; |
| | | using Core.Utilities; |
| | | using TowerDefense.Level; |
| | |
| | | /// </summary> |
| | | public ETowerFuntion eTowerFuntion = ETowerFuntion.NULL; |
| | | public BulletUICtl bulletCtl = null; |
| | | public EnergyUICtl energyCtl = null; |
| | | |
| | | /// <summary> |
| | | /// The tower levels associated with this tower |
| | |
| | | /// </summary> |
| | | public float attackRise { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 用于界面部分的数据位移 |
| | | /// </summary> |
| | | protected int progressOffset = 0; |
| | | |
| | | public bool PlayWaveLineFlash { get; set; } = true; |
| | | |
| | | /// <summary> |
| | | /// 塔防数据的局内升级 |
| | |
| | | { |
| | | get; set; |
| | | } |
| | | |
| | | public int uiProOffset |
| | | { |
| | | get { return this.progressOffset; } |
| | | set { this.progressOffset = value; } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// Gets whether the tower can level up anymore |
| | |
| | | { |
| | | if (!materialTowerAttackSelf) return; |
| | | |
| | | if( opponentSide) |
| | | if (opponentSide) |
| | | { |
| | | 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; |
| | | } |
| | | } |
| | |
| | | { |
| | | 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; |
| | | } |
| | | } |
| | |
| | | /// 是否是对手塔防 |
| | | /// </summary> |
| | | public bool opponentSide { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 播放充能状态特效. |
| | | /// </summary> |
| | | /// <param name="play"></param> |
| | | public void PlayEnergyEffect(bool play, bool isClose = true) |
| | | { |
| | | if (this.energyCtl && isClose) |
| | | energyCtl.gameObject.SetActive(!play); |
| | | else if(!isClose){ |
| | | |
| | | } |
| | | |
| | | if (!opponentSide) |
| | | { |
| | | 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 |
| | | ((TowerPlacementGrid)OpponentMgr.instance.m_CurrentArea).PlayEnergyEffect(gridPosition.x, play); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 当前是否处于攻击模式 |
| | |
| | | if (value) |
| | | { |
| | | if (opponentSide) |
| | | currentTowerLevel.SetTowerMonsterMat(materialMonsterOppo); |
| | | currentTowerLevel.SetTowerMonsterMat(materialTowerWaitOppo, false); |
| | | else |
| | | currentTowerLevel.SetTowerMonsterMat(materialMonsterSelf); |
| | | currentTowerLevel.SetTowerMonsterMat(materialTowerWaitSelf, false); |
| | | |
| | | // 处理Tower |
| | | this.setTowerState(false); |
| | | |
| | | |
| | | if (opponentSide) |
| | | { |
| | |
| | | else if (EndlessLevelManager.instanceExists) |
| | | { |
| | | EndlessLevelManager.instance.SetTowerAttID(gridPosition.x, attributeId, this.currentLevel); |
| | | EndlessWaveLineManager.instance.AttackTowerFixed(gridPosition.x); |
| | | EndlessWaveLineManager.instance.AttackTowerFixed(gridPosition.x, PlayWaveLineFlash); |
| | | } |
| | | } |
| | | |
| | | // |
| | | // 根据是否是子弹塔防来决定是否显示相应的界面 |
| | | BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x); |
| | | /* |
| | | if ( (this.eTowerFuntion == ETowerFuntion.BULLET) && (buc != null ) ) |
| | | { |
| | | // 设置数据 |
| | | buc.gameObject.SetActive(true); |
| | | this.bulletCtl = buc; |
| | | buc.resetToMaxBullet(); |
| | | } |
| | | else |
| | | { |
| | | // 清空数据 |
| | | buc.gameObject.SetActive(false); |
| | | this.bulletCtl = null; |
| | | }*/ |
| | | // 处理塔位边上的界面. |
| | | 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> |
| | | /// This function is called when the object becomes enabled and active. |
| | | /// </summary> |
| | | void OnEnable() |
| | | { |
| | | |
| | | // if (bulletCtl != null) |
| | | // { |
| | | // Debug.Log("打开了bulletCtl"); |
| | | // bulletCtl.gameObject.SetActive(true); |
| | | // } |
| | | |
| | | |
| | | // if (energyCtl != null) |
| | | // { |
| | | // Debug.Log("打开了energyCtl"); |
| | | // energyCtl.gameObject.SetActive(true); |
| | | // } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// This function is called when the behaviour becomes disabled or inactive. |
| | | /// </summary> |
| | | void OnDisable() |
| | | { |
| | | if (bulletCtl != null) |
| | | { |
| | | bulletCtl.gameObject.SetActive(false); |
| | | } |
| | | |
| | | if (energyCtl != null) |
| | | { |
| | | energyCtl.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | |
| | | 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) |
| | |
| | | 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> |
| | |
| | | // |
| | | // 初始化当前的局内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> |