| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Core.Utilities; |
| | | using KTGMGemClient; |
| | | using TowerDefense.Level; |
| | |
| | | /// 等待开启塔位的按钮 |
| | | /// </summary> |
| | | private EndlessTowerGridOpen[,] m_arrTGO; |
| | | |
| | | public GameObject[] TowerGridOpenObjArr; |
| | | |
| | | private float[,] m_arrCoinGenTime; |
| | | |
| | |
| | | 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> |
| | | /// 是否是等待购买的攻击塔位. |
| | |
| | | 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> |
| | |
| | | { |
| | | PlacementTile tileToUse; |
| | | #if UNITY_STANDALONE |
| | | tileToUse = placementTilePrefab; |
| | | //tileToUse = placementTilePrefab; |
| | | tileToUse = placementTilePrefabMobile; |
| | | #else |
| | | tileToUse = placementTilePrefabMobile; |
| | | #endif |
| | |
| | | |
| | | 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. |