| | |
| | | /// </summary> |
| | | protected TextMeshProUGUI towerPriceText; |
| | | |
| | | protected bool tdBuyDisable = false; |
| | | public bool tdBuyDisable { get; protected set; } = false; |
| | | |
| | | /// <summary> |
| | | /// 鼠标在移动一个Tower之前,要隐藏的Tower数据和指针。 |
| | |
| | | |
| | | //首次购买宝石特效 |
| | | public GameObject fireAppearEffect1; |
| | | public GameObject fireAppearEffect2; |
| | | //public GameObject fireAppearEffect2; |
| | | |
| | | public GameObject waterAppearEffect1; |
| | | public GameObject waterAppearEffect2; |
| | | //public GameObject waterAppearEffect2; |
| | | public GameObject woodAppearEffect1; |
| | | public GameObject woodAppearEffect2; |
| | | //public GameObject woodAppearEffect2; |
| | | /// <summary> |
| | | /// 保存所有生成或合成的塔的最小等级 |
| | | /// </summary> |
| | |
| | | return lt; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据塔位索引位置,查找位置上是否有对应的塔防数据。 |
| | | /// </summary> |
| | | /// <param name="x"></param> |
| | | /// <param name="y"></param> |
| | | /// <returns></returns> |
| | | public int GetTowerNum() |
| | | { |
| | | int num = 0; |
| | | foreach (Tower lt in m_listTower) |
| | | { |
| | | if (lt.gridPosition.y == 0 || lt.gridPosition.y == 1) |
| | | { |
| | | num++; |
| | | } |
| | | } |
| | | return num; |
| | | } |
| | | |
| | | public bool towerInList(Tower t) |
| | |
| | | |
| | | if ((m_GridPosition.x >= 0) && (m_GridPosition.y >= 0)) |
| | | { |
| | | if (m_CurrentArea.isFreeAtackPos(m_GridPosition.x, m_GridPosition.y)) |
| | | if ((m_CurrentArea as TowerPlacementGridEndless).isFreeAtackPos(m_GridPosition.x, m_GridPosition.y)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | PlayUpgradeEffect(m_listTower[i]); |
| | | } |
| | | } |
| | | GameConfig.IsUpgradeTowerLevel = true; |
| | | UpdateMinLevelArr(); |
| | | EndlessRandomTower.instance.UpdateDescDisplay(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | if (m_GridPosition.y == 0 || m_GridPosition.y == 1) |
| | | { |
| | | Debug.Log("未上阵区域,不管有没有塔,都强行吸附"); |
| | | //Debug.Log("未上阵区域,不管有没有塔,都强行吸附"); |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, true, ""); |
| | | |
| | | m_CurrentTower.transform.position = (m_CurrentArea as TowerPlacementGridEndless).GridToWorld(m_GridPosition, m_CurrentTower.controller.dimensions); |
| | |
| | | |
| | | if (checkTowerPlaceTower != null) |
| | | { |
| | | Debug.Log(checkTowerPlaceTower.name); |
| | | //Debug.Log(checkTowerPlaceTower.name); |
| | | |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | |
| | | // 判断目标位置是否有Tower且类型和等级一致,如果没有,则GhostTower删除,原Tower显示。 |
| | | if (isValidateCombineTarget(pointerInfo)) |
| | | { |
| | | //Debug.Log("isValidateCombineTarget"); |
| | | TryPlaceTower(pointerInfo); |
| | | EndlessRandomTower.instance.UpdateDescDisplay(); |
| | | } |
| | | else if (isFreeAttackGrid(pointerInfo)) |
| | | { |
| | | //Debug.Log("isFreeAttackGrid:" + m_GridPosition); |
| | | |
| | | if (!TryPlaceTower(pointerInfo, false)) |
| | | { |
| | | CancelPlaceTower(pointerInfo); |
| | |
| | | } |
| | | else if (EndlessLevelManager.instanceExists && IsSubstitute(pointerInfo)) |
| | | { |
| | | //Debug.Log("IsSubstitute"); |
| | | |
| | | CheckCanChangePos(pointerInfo); |
| | | if (EndlessUIStart.instance.GameStartTime >= JsonDataCenter.DOUBLE_GEM_TIME) |
| | | UpgradeAllTowerMinLevel(1); |
| | | } |
| | | else |
| | | CancelPlaceTower(pointerInfo); |
| | |
| | | { |
| | | if (!isBuilding) return false; |
| | | |
| | | //Debug.Log("开始造塔" + m_GridPosition); |
| | | // 判断是否格子上重复放置塔防 |
| | | if (!m_CurrentTower || !IsGhostAtValidPosition()) |
| | | { |
| | |
| | | CancelGhostPlacement(); |
| | | return false; |
| | | } |
| | | |
| | | PlaceGhost(pointer); |
| | | } |
| | | return true; |
| | |
| | | { |
| | | //火元素 |
| | | PlayAppearEffect(worldPos, fireAppearEffect1); |
| | | PlayAppearEffect(worldPos, fireAppearEffect2); |
| | | //PlayAppearEffect(worldPos, fireAppearEffect2); |
| | | if (Application.platform == RuntimePlatform.WindowsEditor) |
| | | { |
| | | //UnityEditor.EditorApplication.isPaused = true; |
| | |
| | | { |
| | | //木元素 |
| | | PlayAppearEffect(worldPos, woodAppearEffect1); |
| | | PlayAppearEffect(worldPos, woodAppearEffect2); |
| | | //PlayAppearEffect(worldPos, woodAppearEffect2); |
| | | |
| | | } |
| | | else if (towerName.StartsWith("CopyCatTower")) |
| | | { |
| | | //水元素 |
| | | PlayAppearEffect(worldPos, waterAppearEffect1); |
| | | PlayAppearEffect(worldPos, waterAppearEffect2); |
| | | //PlayAppearEffect(worldPos, waterAppearEffect2); |
| | | } |
| | | } |
| | | void PlayAppearEffect(Vector3 worldPos, GameObject prefab) |
| | |
| | | /// <summary> |
| | | /// 随机放置Tower按钮禁止使用,灰掉. |
| | | /// </summary> |
| | | protected void disableRandomTowerBtn() |
| | | public void disableRandomTowerBtn() |
| | | { |
| | | randomTowerBtn.GetComponent<EndlessRandomTower>().ChangeBtnClick(); |
| | | //randomTowerBtn.interactable = false; |
| | |
| | | /// <summary> |
| | | /// 随机购买Tower的按钮重设置为有效. |
| | | /// </summary> |
| | | protected void enableRandomTowerBtn() |
| | | public void enableRandomTowerBtn() |
| | | { |
| | | // ATTENTION TO FIX: 再次判断是因为有的地方是直接调用 |
| | | if ((TowerPrice.instance.currentTowerPrice > EndlessLevelManager.instance.Currency.currentCurrency) || |
| | |
| | | bool successfulPurchase = EndlessLevelManager.instance.Currency.TryPurchase(cost); |
| | | if (!successfulPurchase) return false; |
| | | |
| | | EndlessRandomTower.instance.UpdateDescDisplay(); |
| | | SetUpGhostTower(tow); |
| | | //Debug.Log("设置影子塔防."); |
| | | m_CurrentTower.Show(); |
| | |
| | | return; |
| | | } |
| | | m_GridPosition = m_CurrentArea.WorldToGrid(raycast.point, m_CurrentTower.controller.dimensions); |
| | | //Debug.Log("修改了m_GridPosition:" + m_GridPosition); |
| | | TowerFitStatus fits = m_CurrentArea.Fits(m_GridPosition, m_CurrentTower.controller.dimensions); |
| | | |
| | | m_CurrentTower.Show(); |
| | |
| | | /// <exception cref="InvalidOperationException">If we're not in the correct state</exception> |
| | | protected void PlaceGhost(UIPointer pointer) |
| | | { |
| | | MoveGhost(pointer); |
| | | //MoveGhost(pointer); |
| | | |
| | | if (m_CurrentArea != null) |
| | | { |
| | | //Debug.Log("开始检测PlaceGhost:" + m_GridPosition); |
| | | |
| | | TowerFitStatus fits = m_CurrentArea.Fits(m_GridPosition, m_CurrentTower.controller.dimensions); |
| | | |
| | | if (fits == TowerFitStatus.Fits) |
| | |
| | | |
| | | m_CurrentTower = Instantiate(towerToBuild.towerGhostPrefab); |
| | | m_CurrentTower.Initialize(towerToBuild); |
| | | Debug.Log("SetUpGhostTower:" + towerToBuild.gridPosition); |
| | | |
| | | Debug.Log("SetUpGhostTower:" + m_CurrentTower.controller.gridPosition); |
| | | |
| | | } |
| | | |
| | | /// <summary> |