From 62b2779db75575bebd80ffac74fc3f25b5b994fa Mon Sep 17 00:00:00 2001 From: chenxin <chenxin6991@163.com> Date: Sat, 14 Nov 2020 10:34:52 +0800 Subject: [PATCH] Merge commit '4a083f2f3d8baf1c2630b3717d62904edcc8e24a' into master --- Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs | 130 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 129 insertions(+), 1 deletions(-) diff --git a/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs b/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs index d58b423..0f09267 100644 --- a/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs +++ b/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Core.Utilities; using KTGMGemClient; using TowerDefense.Level; @@ -76,6 +77,8 @@ /// 等待开启塔位的按钮 /// </summary> private EndlessTowerGridOpen[,] m_arrTGO; + + public GameObject[] TowerGridOpenObjArr; private float[,] m_arrCoinGenTime; @@ -275,13 +278,19 @@ public bool isFreeAtackPos(int x, int y) { if (m_AvailableCells[x, y]) + { return false; + } if (m_arrGridType[x, y] == PlacementGridType.EGridOpen) + { return true; + } return false; } + + /// <summary> /// 是否是等待购买的攻击塔位. @@ -819,9 +828,17 @@ if (!arrTowerEnergyEffect[x, dy]) return; if (play) + { + if (!arrTowerEnergyEffect[x, dy].gameObject.activeSelf) + arrTowerEnergyEffect[x, dy].gameObject.SetActive(true); arrTowerEnergyEffect[x, dy].Play(); + } else + { + arrTowerEnergyEffect[x, dy].Stop(); + arrTowerEnergyEffect[x, dy].gameObject.SetActive(false); + } } /// <summary> @@ -844,7 +861,8 @@ { PlacementTile tileToUse; #if UNITY_STANDALONE - tileToUse = placementTilePrefab; + //tileToUse = placementTilePrefab; + tileToUse = placementTilePrefabMobile; #else tileToUse = placementTilePrefabMobile; #endif @@ -872,11 +890,121 @@ m_Tiles[x, y] = newTile; newTile.SetTileType(m_arrGridType[x, y]); + newTile.CheckCanPlace(false);//初始化不显示 } } } } + PlacementTile currentCanPlace;//记录当前标记 + + /// <summary> + /// 开始拖拽的时候判断哪些可以放置 + /// </summary> + /// <param name="allTowerP">不符合条件的数组</param> + public void CheckAllCanPlace(List<IntVector2> allTowerP) + { + int iy = dimensions.y - 1;//3 + bool canPlace; + currentCanPlace = null; + for (int ix = 0; ix < dimensions.x; ix++) + { + for (int y = iy; y >= dimensions.y - AttackRowNumbers; --y) + { + if (m_arrGridType[ix, y] == PlacementGridType.EGridOpen) + { + canPlace = true; + for (int i = 0; i < allTowerP.Count; i++) + { + if (allTowerP[i].x == ix && allTowerP[i].y == y) + { + canPlace = false; + break; + } + } + m_Tiles[ix, y].CheckCanPlace(canPlace); + } + } + } + } + + + /// <summary> + /// 播放升级动画 + /// </summary> + /// <param name="allTowerP"></param> + public void PlayPS(List<IntVector2> allTowerP) + { + for (int i = 0; i < allTowerP.Count; i++) + { + m_Tiles[allTowerP[i].x, allTowerP[i].y].SetParticleSystem(true); + } + } + /// <summary> + /// /// 停止所有升级动画 + /// </summary> + public void StopPS() + { + int iy = dimensions.y - 1;//3 + for (int ix = 0; ix < dimensions.x; ix++) + { + for (int y = iy; y >= dimensions.y - AttackRowNumbers; --y) + { + if (m_arrGridType[ix, y] == PlacementGridType.EGridOpen) + { + m_Tiles[ix, y].SetParticleSystem(false); + } + } + } + } + + /// <summary> + /// 拖动时候实时检查距离哪个格子近 + /// </summary> + /// <param name="x"></param> + /// <param name="y"></param> + public void CheckCanPlaceUpdate(int x, int y, bool isEmpty, string towerName) + { + CloseCanPlace(); + currentCanPlace = m_Tiles[x, y]; + currentCanPlace.SetSelect(true); + if (isEmpty) + { + currentCanPlace.SetTowerVirtualshadow(towerName); + } + } + + /// <summary> + /// 关闭上一个 + /// </summary> + public void CloseCanPlace() + { + if (currentCanPlace != null) + { + currentCanPlace.SetSelect(false); + currentCanPlace = null; + } + } + + /// <summary> + /// 关闭所有 + /// </summary> + public void CloseCanPlaceRenderer() + { + int iy = dimensions.y - 1; + for (int ix = 0; ix < dimensions.x; ix++) + { + for (int y = iy; y >= dimensions.y - AttackRowNumbers; --y) + { + if (m_arrGridType[ix, y] == PlacementGridType.EGridOpen) + { + m_Tiles[ix, y].CheckCanPlace(false); + } + } + } + StopPS(); + } + #if UNITY_EDITOR /// <summary> /// On editor/inspector validation, make sure we size our collider correctly. -- Gitblit v1.9.1