| | |
| | | using System.Globalization; |
| | | using Core.Health; |
| | | using Core.Health; |
| | | using Core.Input; |
| | | using Core.Utilities; |
| | | using DG.Tweening; |
| | | using JetBrains.Annotations; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using TMPro; |
| | | using TowerDefense.Level; |
| | |
| | | using UnityEngine.EventSystems; |
| | | using UnityEngine.UI; |
| | | using TowerDefense.Nodes; |
| | | using TowerDefense.Affectors; |
| | | using KTGMGemClient; |
| | | |
| | | namespace TowerDefense.UI.HUD |
| | |
| | | public TextMoveDoTween bloodCrit; |
| | | |
| | | /// <summary> |
| | | /// 减速飘字 |
| | | /// </summary> |
| | | public Image SlowDownWord; |
| | | |
| | | /// <summary> |
| | | /// 暴击飘字 |
| | | /// </summary> |
| | | public Image CritWord; |
| | | |
| | | /// <summary> |
| | | /// 冰冻飘字 |
| | | /// </summary> |
| | | public Image FrostWord; |
| | | |
| | | public Image RestrainWord; |
| | | |
| | | /// <summary> |
| | | /// 购买塔防按钮上的Text. |
| | | /// </summary> |
| | | protected TextMeshProUGUI towerPriceText; |
| | | |
| | | //protected TextMeshProUGUI towerPriceText1; |
| | | |
| | | protected bool tdBuyDisable = false; |
| | | public bool tdBuyDisable { get; protected set; } = false; |
| | | |
| | | /// <summary> |
| | | /// 鼠标在移动一个Tower之前,要隐藏的Tower数据和指针。 |
| | |
| | | /// </summary> |
| | | Camera m_Camera; |
| | | |
| | | //Camera m_CameraBG; |
| | | |
| | | |
| | | /// <summary> |
| | | /// Current tower placeholder. Will be null if not in the <see cref="State.Building" /> state. |
| | | /// </summary> |
| | |
| | | return m_CurrentTower != null; |
| | | } |
| | | } |
| | | |
| | | |
| | | // TowerList用于简单记录相关的数据 |
| | | protected List<Tower> m_listTower = new List<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 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) |
| | | { |
| | | return m_listTower.Contains(t); |
| | |
| | | { |
| | | foreach (Tower tower in m_listTower) |
| | | { |
| | | tower.bInAttackMode = canAttack; |
| | | tower.CanAttack = canAttack; |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | return; |
| | | } |
| | | if (state == State.GameOver) |
| | | { |
| | | CommonDebugHelper.DebugError("已经游戏结束了,为什么还在修改状态"); |
| | | return; |
| | | } |
| | | CommonDebugHelper.Debug($"设置了状态 state:{state} newState:{newState} "); |
| | | |
| | | State oldState = state; |
| | | if (oldState == State.Paused || oldState == State.GameOver) |
| | | { |
| | |
| | | /// </summary> |
| | | public void GameOver() |
| | | { |
| | | CommonDebugHelper.Debug("游戏结束了"); |
| | | |
| | | SetState(State.GameOver); |
| | | } |
| | | |
| | |
| | | if (tower.towerName != towerOld.towerName) |
| | | continue; |
| | | |
| | | newT = Instantiate(tower, transform); |
| | | newT = tower; |
| | | break; |
| | | } |
| | | |
| | |
| | | SetToDragMode(newT); |
| | | |
| | | if (towerOld.towerFeature == EFeatureTower.Skill_Bomb) |
| | | m_CurrentTower.SetAttackArea(dragTowerLevel, towerOld.attributeId); |
| | | m_CurrentTower.SetAttackArea(dragTowerLevel, towerOld.ElfId); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | 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; |
| | | } |
| | |
| | | if (!m_CurrentTower || !IsGhostAtValidPosition()) |
| | | { |
| | | // 最大级别的Tower不能再合并了. |
| | | if (towerToMove.isAtMaxLevel) |
| | | if (towerToMove.IsMaxLevel) |
| | | return false; |
| | | |
| | | // 判断格子上的塔防: |
| | | UIPointer pointer = WrapPointer(pinfo); |
| | | Tower sTower = PickTowerInGrid(pointer); |
| | | |
| | | // 泡泡禁锢状态不允许合并 |
| | | if (sTower && sTower.IsStartBondage) return false; |
| | | |
| | | if (sTower && sTower != towerToMove) |
| | | { |
| | | int testLvl = dragTowerLevel; |
| | |
| | | UIPointer pointer = WrapPointer(pinfo); |
| | | Tower sTower = PickTowerInGrid(pointer); |
| | | |
| | | // 泡泡禁锢状态不允许置换 |
| | | if (sTower && sTower.IsStartBondage) return false; |
| | | |
| | | if (sTower && sTower != towerToMove) |
| | | { |
| | | if (towerToMove && sTower.towerFeature == EFeatureTower.NULL && towerToMove.towerFeature == EFeatureTower.NULL && sTower.bInAttackMode && towerToMove.bInAttackMode) |
| | | if (towerToMove) |
| | | return true; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 提升所有塔的等级,如果现在塔的等级 < level,设置等级为 level,如果 > level 不做改变 |
| | | /// </summary> |
| | | /// <param name="level">从0开始</param> |
| | | public void UpgradeAllTowerMinLevel(int level) |
| | | { |
| | | if (level < 0 || level > ElfUpgradeData.MaxTowerLevel - 1) return; |
| | | |
| | | for (int i = 0; i < m_listTower.Count; ++i) |
| | | { |
| | | if (m_listTower[i].currentLevel < level) |
| | | { |
| | | m_listTower[i].currentLevel = level; |
| | | m_listTower[i].CurrentTowerLevel.SetShowLevel(level + 1); |
| | | m_listTower[i].CurrentTowerLevel.SetScale(level + 1); |
| | | PlayUpgradeEffect(m_listTower[i]); |
| | | } |
| | | } |
| | | GameConfig.IsUpgradeTowerLevel = true; |
| | | UpdateMinLevelArr(); |
| | | EndlessRandomTower.instance.UpdateDescDisplay(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | EndlessBossSkillManager.instance.ClearSkillList(); |
| | | EndlessBossHPManager.instance.SwitchHP(true); |
| | | EndlessBossHPManager.instance.SetCurrentHP(0); |
| | | EndlessLevelManager.instance.WaveManager.HideTunel(); |
| | | |
| | | // 停止所有兵线的出兵 |
| | | for (int i = 0; i < TotalWaveLines; ++i) |
| | |
| | | if (m_CurrentArea != null && m_CurrentArea is TowerPlacementGridEndless) |
| | | { |
| | | checkTowerPlaceTower = isFreeAttackGridOnDrag(pointerInfo); |
| | | |
| | | //下面是为了设置一个虚拟的塔 |
| | | if (checkTowerPlaceTower != null) |
| | | { |
| | | Debug.Log(checkTowerPlaceTower.name); |
| | | |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | if (checkTowerPlaceTower.bInAttackMode) |
| | |
| | | if (bInAttackModeTower == null) |
| | | { |
| | | bInAttackModeTower = checkTowerPlaceTower; |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(true); |
| | | bInAttackModeTower.CurrentTowerLevel.SetCanPlace(true); |
| | | } |
| | | else if (bInAttackModeTower != checkTowerPlaceTower) |
| | | { |
| | | |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(false); |
| | | bInAttackModeTower.CurrentTowerLevel.SetCanPlace(false); |
| | | bInAttackModeTower = checkTowerPlaceTower; |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(true); |
| | | bInAttackModeTower.CurrentTowerLevel.SetCanPlace(true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | else if (m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Fire || m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Bomb) |
| | | { |
| | | //技能宝石没有上阵 |
| | | if (bInAttackModeTower == null) |
| | | { |
| | | bInAttackModeTower = checkTowerPlaceTower; |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(true); |
| | | } |
| | | else if (bInAttackModeTower != checkTowerPlaceTower) |
| | | { |
| | | |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(false); |
| | | bInAttackModeTower = checkTowerPlaceTower; |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(true); |
| | | } |
| | | m_CurrentTower.transform.position = (m_CurrentArea as TowerPlacementGridEndless).GridToWorld(checkTowerPlaceTower.gridPosition, m_CurrentTower.controller.dimensions); |
| | | |
| | | } |
| | | } |
| | | else if ((m_GridPosition.x >= 0) && (m_GridPosition.y >= 0)) |
| | |
| | | { |
| | | //空格子 |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, true, towerToMove.towerName); |
| | | |
| | | m_CurrentTower.transform.position = (m_CurrentArea as TowerPlacementGridEndless).GridToWorld(m_GridPosition, m_CurrentTower.controller.dimensions); |
| | | |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | } |
| | | |
| | | void CloseCanPlace() |
| | | public void CloseCanPlace() |
| | | { |
| | | dragTowerPlacement.CloseCanPlace(); |
| | | if (bInAttackModeTower != null) |
| | | { |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(false); |
| | | bInAttackModeTower.CurrentTowerLevel.SetCanPlace(false); |
| | | bInAttackModeTower = null; |
| | | } |
| | | } |
| | | |
| | | TowerPlacementGridEndless dragTowerPlacement; |
| | | |
| | | public void CheckTowerPlaceNew(PointerInfo pointerInfo) |
| | | { |
| | | //return; |
| | | if (m_CurrentArea != null && m_CurrentArea is TowerPlacementGridEndless) |
| | | { |
| | | if ((m_GridPosition.x >= 0) && (m_GridPosition.y >= 0)) |
| | | { |
| | | if (m_GridPosition.y == 0 || m_GridPosition.y == 1) |
| | | { |
| | | //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); |
| | | |
| | | } |
| | | else if (m_GridPosition.y == 2 || m_GridPosition.y == 3) |
| | | { |
| | | //Debug.Log("已上阵区域,如果是空格子就强行吸附,先判断是否有塔"); |
| | | //pointerInfo.currentPosition += new Vector2(0, -25f); |
| | | checkTowerPlaceTower = isFreeAttackGridOnDrag(pointerInfo); |
| | | |
| | | if (checkTowerPlaceTower != null) |
| | | { |
| | | //Debug.Log(checkTowerPlaceTower.name); |
| | | //Debug.Log($"checkTowerPlaceTower.name:{checkTowerPlaceTower.name} m_GridPosition:{m_GridPosition}"); |
| | | |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | if (checkTowerPlaceTower.bInAttackMode) |
| | | { |
| | | //Debug.Log("检测到了塔"); |
| | | //鼠标检测到了塔 |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(checkTowerPlaceTower.gridPosition.x, checkTowerPlaceTower.gridPosition.y, false, ""); |
| | | } |
| | | else |
| | | { |
| | | if (!towerToMove.bInAttackMode) |
| | | { |
| | | //没有上阵 |
| | | if (bInAttackModeTower == null) |
| | | { |
| | | bInAttackModeTower = checkTowerPlaceTower; |
| | | bInAttackModeTower.CurrentTowerLevel.SetCanPlace(true); |
| | | } |
| | | else if (bInAttackModeTower != checkTowerPlaceTower) |
| | | { |
| | | |
| | | bInAttackModeTower.CurrentTowerLevel.SetCanPlace(false); |
| | | bInAttackModeTower = checkTowerPlaceTower; |
| | | bInAttackModeTower.CurrentTowerLevel.SetCanPlace(true); |
| | | } |
| | | } |
| | | } |
| | | m_CurrentTower.transform.position = (m_CurrentArea as TowerPlacementGridEndless).GridToWorld(checkTowerPlaceTower.gridPosition, m_CurrentTower.controller.dimensions); |
| | | } |
| | | } |
| | | else if ((m_CurrentArea as TowerPlacementGridEndless).isFreeAtackPos(m_GridPosition.x, m_GridPosition.y)) |
| | | { |
| | | //Debug.Log("空格子"); |
| | | |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, true, towerToMove.towerName); |
| | | |
| | | m_CurrentTower.transform.position = (m_CurrentArea as TowerPlacementGridEndless).GridToWorld(m_GridPosition, m_CurrentTower.controller.dimensions); |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | //Debug.Log($"上阵区域 m_GridPosition:{m_GridPosition.x} {m_GridPosition.y} m_CurrentTower.controller.gridPosition:{m_CurrentTower.controller.gridPosition.x} {m_CurrentTower.controller.gridPosition.y}"); |
| | | |
| | | if (m_GridPosition == towerToMove.gridPosition) |
| | | { |
| | | //Debug.Log("在原来的地方"); |
| | | |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, true, towerToMove.towerName); |
| | | |
| | | m_CurrentTower.transform.position = towerToMove.position; |
| | | } |
| | | else |
| | | { |
| | | //CloseCanPlace(); |
| | | |
| | | //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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | dragTowerPlacement.CloseCanPlace(); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 目标位置是否是可攻击属性的空塔位 |
| | |
| | | Tower sTower = PickTowerInGrid(pointer); |
| | | if (sTower != null) |
| | | { |
| | | |
| | | // if (towerToMove && sTower.currentLevel == dragTowerLevel && sTower.towerName == towerToMove.towerName) |
| | | // { |
| | | // //说明可以合成 |
| | | // return sTower; |
| | | // } |
| | | // else |
| | | // { |
| | | // return null; |
| | | // } |
| | | |
| | | if (towerToMove) |
| | | { |
| | | if (towerToMove.bInAttackMode) |
| | | { |
| | | return sTower; |
| | | } |
| | | else |
| | | { |
| | | if (sTower.currentLevel == dragTowerLevel && sTower.towerName == towerToMove.towerName) |
| | | { |
| | | //说明可以合成 |
| | | return sTower; |
| | | } |
| | | } |
| | | return sTower; |
| | | // if (towerToMove.bInAttackMode) |
| | | // { |
| | | // } |
| | | // else |
| | | // { |
| | | // if (sTower.currentLevel == dragTowerLevel && sTower.towerName == towerToMove.towerName) |
| | | // { |
| | | // //说明可以合成 |
| | | // return sTower; |
| | | // } |
| | | // } |
| | | } |
| | | else |
| | | { |
| | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 推拽结束,如果判断HasTower==true 就强行释放 |
| | | /// </summary> |
| | | public void EndDragCancelPlaceTower() |
| | | { |
| | | Debug.Log("强行释放了m_CurrentTower"); |
| | | CancelPlaceTower(null); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 拖动一个Tower之后,松开鼠标或者EndDrag. |
| | | /// 1: 目标点可合成,则直接合成。 |
| | | /// 2: 目标点不管是空白,还是不能放置Tower,都要让当前的Tower返回到原来的TowerPlace |
| | |
| | | /// <param name="pointerInfo"></param> |
| | | public void onEndTowerDrag(PointerInfo pointerInfo) |
| | | { |
| | | bool bSkill = false; |
| | | if (temporaryMat != null) |
| | | { |
| | | //移动虚像隐藏 |
| | |
| | | } |
| | | |
| | | if (m_CurrentTower.controller.towerFeature != EFeatureTower.NULL) |
| | | bSkill = true; |
| | | |
| | | { |
| | | Debug.LogError("只能移动3种塔"); |
| | | return; |
| | | } |
| | | if (GameConfig.IsNewbie) |
| | | { |
| | | bool isCanChange = false; |
| | |
| | | } |
| | | else |
| | | { |
| | | GuideCtrl.Ins.EndDrag11_1(); |
| | | GuideCtrl.Ins.EndDrag5_1(); |
| | | CancelPlaceTower(pointerInfo); |
| | | Debug.Log("没有放置在火塔上"); |
| | | } |
| | |
| | | // 判断目标位置是否有Tower且类型和等级一致,如果没有,则GhostTower删除,原Tower显示。 |
| | | if (isValidateCombineTarget(pointerInfo)) |
| | | { |
| | | //Debug.Log("isValidateCombineTarget"); |
| | | TryPlaceTower(pointerInfo); |
| | | EndlessRandomTower.instance.UpdateDescDisplay(); |
| | | } |
| | | else if (isFreeAttackGrid(pointerInfo) && !bSkill) |
| | | else if (isFreeAttackGrid(pointerInfo)) |
| | | { |
| | | if (!TryPlaceTower(pointerInfo, false, true)) |
| | | //Debug.Log("isFreeAttackGrid:" + m_GridPosition); |
| | | |
| | | if (!TryPlaceTower(pointerInfo, false)) |
| | | { |
| | | CancelPlaceTower(pointerInfo); |
| | | Debug.Log("这里需要返回原位"); |
| | |
| | | towerToMove.Sell(); |
| | | towerToMove = null; |
| | | } |
| | | if (m_CurrentTower != null && m_CurrentTower.controller != null) |
| | | Destroy(m_CurrentTower.controller.gameObject); |
| | | } |
| | | else if (EndlessLevelManager.instanceExists && IsSubstitute(pointerInfo)) |
| | | { |
| | | CheckCanChangePos(pointerInfo); |
| | | } |
| | | // 当前是Skill塔位的状态. |
| | | else if (bSkill) |
| | | { |
| | | if (SkillPlayEndDrag(pointerInfo)) |
| | | { |
| | | // 先释放掉当前的Ghost塔防. |
| | | CancelGhostPlacement(); |
| | | //Debug.Log("IsSubstitute"); |
| | | |
| | | // 删除towerToMove,确保塔防数据不再出现多个 |
| | | if (towerToMove != null) |
| | | { |
| | | delTower(towerToMove); |
| | | towerToMove.showTower(true); |
| | | towerToMove.Sell(); |
| | | towerToMove = null; |
| | | } |
| | | } |
| | | else |
| | | CancelPlaceTower(pointerInfo); |
| | | CheckCanChangePos(pointerInfo); |
| | | } |
| | | else |
| | | CancelPlaceTower(pointerInfo); |
| | |
| | | if (sTower == null) |
| | | return false; |
| | | |
| | | if (sTower.bInAttackMode == towerToMove.bInAttackMode) |
| | | //Debug.Log("开始检测是否可以交换塔"); |
| | | //if (sTower.bInAttackMode == towerToMove.bInAttackMode) |
| | | { |
| | | IntVector2 v1 = new IntVector2(towerToMove.gridPosition.x, towerToMove.gridPosition.y); |
| | | IntVector2 v2 = new IntVector2(sTower.gridPosition.x, sTower.gridPosition.y); |
| | |
| | | //强制交换塔的时候检查自身充能条 |
| | | newTower1.CheckCtrl(); |
| | | newTower2.CheckCtrl(); |
| | | //Debug.Log($"newTower1:{newTower1.towerName} newTower2:{newTower2.towerName}"); |
| | | |
| | | TowerPlacementGridEndless.instance.PlayPutPs(newTower2.gridPosition.x, newTower2.gridPosition.y); |
| | | return true; |
| | | } |
| | | } |
| | |
| | | Tower controller = currentTower.controller; |
| | | Tower createdTower = Instantiate(controller); |
| | | createdTower.PlayWaveLineFlash = playEffect; |
| | | createdTower.Initialize(m_CurrentArea, pos); |
| | | createdTower.SetLevel(level - 1); |
| | | createdTower.Initialize(m_CurrentArea, pos, level - 1); |
| | | |
| | | if (playEffect) |
| | | PlayUpgradeEffect(createdTower); |
| | |
| | | ray = m_Camera.ScreenPointToRay(tp.currentPosition) |
| | | }; |
| | | |
| | | int sId = towerToMove.attributeId; |
| | | int sId = towerToMove.ElfId; |
| | | int sLevel = towerToMove.currentLevel; |
| | | |
| | | // 火是列攻击: |
| | |
| | | /// Attempt to position a tower at the given location |
| | | /// </summary> |
| | | /// <param name="pointerInfo">The pointer we're using to position the tower</param> |
| | | public bool TryPlaceTower(PointerInfo pointerInfo, bool force = false, bool zeroCost = false) |
| | | public bool TryPlaceTower(PointerInfo pointerInfo, bool force = false) |
| | | { |
| | | UIPointer pointer = WrapPointer(pointerInfo); |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | return BuyTower(pointer, force, zeroCost); |
| | | return BuyTower(pointer, force); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return controller; |
| | | } |
| | | |
| | | private Vector2 dragOffect = new Vector2(0, -55f); |
| | | /// <summary> |
| | | /// Position the ghost tower at the given pointer |
| | | /// </summary> |
| | |
| | | return; |
| | | //throw new InvalidOperationException("Trying to move the tower ghost when we don't have one"); |
| | | } |
| | | // 我操,终于可以了!ATTENTION TO OPP: |
| | | PointerInfo tp = new PointerActionInfo(); |
| | | tp.currentPosition = pointerInfo.currentPosition + dragOffect; |
| | | tp.previousPosition = pointerInfo.previousPosition; |
| | | tp.delta = pointerInfo.delta; |
| | | tp.startedOverUI = pointerInfo.startedOverUI; |
| | | |
| | | UIPointer pointer = WrapPointer(pointerInfo); |
| | | UIPointer npt = new UIPointer |
| | | { |
| | | overUI = false, |
| | | pointer = tp, |
| | | overWaveLine = false, |
| | | ray = m_Camera.ScreenPointToRay(tp.currentPosition) |
| | | }; |
| | | |
| | | //UIPointer pointer = WrapPointer(tp); |
| | | // Do nothing if we're over UI |
| | | if (pointer.overUI && hideWhenInvalid) |
| | | if (npt.overUI && hideWhenInvalid) |
| | | { |
| | | m_CurrentTower.Hide(); |
| | | return; |
| | | } |
| | | MoveGhost(pointer, hideWhenInvalid); |
| | | MoveGhost(npt, hideWhenInvalid); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | throw new InvalidOperationException("Selected Tower is null"); |
| | | } |
| | | if (currentSelectedTower.isAtMaxLevel) |
| | | if (currentSelectedTower.IsMaxLevel) |
| | | { |
| | | return; |
| | | } |
| | | int upgradeCost = currentSelectedTower.GetCostForNextLevel(); |
| | | bool successfulUpgrade = EndlessLevelManager.instance.Currency.TryPurchase(upgradeCost); |
| | | if (successfulUpgrade) |
| | | { |
| | | currentSelectedTower.UpgradeTower(); |
| | | } |
| | | currentSelectedTower.UpgradeTower(); |
| | | DeselectTower(); |
| | | } |
| | | |
| | |
| | | { |
| | | throw new InvalidOperationException("Selected Tower is null"); |
| | | } |
| | | if (currentSelectedTower.isAtMaxLevel) |
| | | if (currentSelectedTower.IsMaxLevel) |
| | | return false; |
| | | |
| | | // 直接随机升级,零成本。 |
| | | // 1:记录当前Tower的Level,删除当前的Tower. 2:从TowerLib中随机找一个高一级别的Tower. |
| | | string towerName = currentSelectedTower.towerName; |
| | | if (currentSelectedTower.towerFeature == EFeatureTower.NULL) |
| | | |
| | | if (currentSelectedTower.towerFeature == EFeatureTower.NULL && GameConfig.CreateRandomTower) |
| | | towerName = ""; |
| | | int towerLvl = currentSelectedTower.currentLevel + 1; |
| | | int posx = currentSelectedTower.gridPosition.x; |
| | |
| | | { |
| | | throw new InvalidOperationException("Selected Tower is null"); |
| | | } |
| | | int sellValue = currentSelectedTower.GetSellLevel(); |
| | | if (EndlessLevelManager.instanceExists && sellValue > 0) |
| | | { |
| | | EndlessLevelManager.instance.Currency.AddCurrency(sellValue); |
| | | currentSelectedTower.Sell(); |
| | | currentSelectedTower.Sell(); |
| | | |
| | | // 从列表中删除Tower. |
| | | delTower(currentSelectedTower); |
| | | } |
| | | // 从列表中删除Tower. |
| | | delTower(currentSelectedTower); |
| | | DeselectTower(); |
| | | } |
| | | |
| | |
| | | { |
| | | return; |
| | | } |
| | | int cost = m_CurrentTower.controller.purchaseCost; |
| | | bool successfulPurchase = EndlessLevelManager.instance.Currency.TryPurchase(cost); |
| | | if (successfulPurchase) |
| | | { |
| | | PlaceTower(); |
| | | } |
| | | PlaceTower(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// Throws exception when not in a build mode or when tower is not a valid position |
| | | /// </exception> |
| | | /// </summary> |
| | | public bool BuyTower(UIPointer pointer, bool force = false, bool zeroCost = false) |
| | | public bool BuyTower(UIPointer pointer, bool force = false) |
| | | { |
| | | if (!isBuilding) return false; |
| | | |
| | | //Debug.Log("开始造塔" + m_GridPosition); |
| | | // 判断是否格子上重复放置塔防 |
| | | if (!m_CurrentTower || !IsGhostAtValidPosition()) |
| | | { |
| | |
| | | CancelGhostPlacement(); |
| | | return false; |
| | | } |
| | | |
| | | PlaceGhost(pointer); |
| | | } |
| | | return true; |
| | |
| | | return false; |
| | | } |
| | | |
| | | int cost = m_CurrentTower.controller.purchaseCost; |
| | | if (zeroCost) |
| | | cost = 0; |
| | | bool successfulPurchase = EndlessLevelManager.instance.Currency.TryPurchase(cost); |
| | | bool successfulPurchase = EndlessLevelManager.instance.Currency.TryPurchase(0); |
| | | if (successfulPurchase) |
| | | { |
| | | PlaceGhost(pointer); |
| | |
| | | /// <param name="worldPos"></param> |
| | | public void PlayUpgradeEffect(Tower newTower) |
| | | { |
| | | newTower.currentTowerLevel.PlayUpGradeEffect(); |
| | | // GameObject effect = TowerUpgradeEffectPrefab; |
| | | |
| | | // if (newTower.towerFeature == EFeatureTower.NULL) |
| | | // { |
| | | // string path = $"UI/ToBattle_{newTower.attributeId}"; |
| | | // GameObject prefab = Resources.Load<GameObject>(path); |
| | | // effect = Instantiate(prefab); |
| | | // } |
| | | |
| | | // // 在sTower的位置播放升级特效 |
| | | // GameObject obj = Instantiate(effect); |
| | | // obj.transform.position = newTower.transform.position; |
| | | // Vector3 pos = obj.transform.position; |
| | | // pos.y += 5f; |
| | | // obj.transform.position = pos; |
| | | // ParticleSystem ps = obj.GetComponent<ParticleSystem>(); |
| | | |
| | | // if (ps == null) |
| | | // ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | // ps.Play(); |
| | | // Destroy(obj, ps.main.duration); |
| | | newTower.CurrentTowerLevel.PlayUpGradeEffect(); |
| | | AudioSourceManager.Ins.Play(AudioEnum.Upgrade); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | if (m_CurrentTower == null || m_CurrentArea == null) |
| | | return false; |
| | | |
| | | return EndlessLevelManager.instance.Currency.CanAfford(m_CurrentTower.controller.purchaseCost); |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | //火元素 |
| | | 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) || |
| | |
| | | } |
| | | if (tm) |
| | | { |
| | | tm.GetComponent<Transform>().SetParent(GameObject.Find("MainUI").GetComponent<Transform>(), true); |
| | | string bloodStr = ""; |
| | | if (doubleHit) |
| | | bloodStr += "Dble!"; |
| | | if (crit) |
| | | bloodStr += "Crt!"; |
| | | bloodStr += "-"; |
| | | tm.GetComponent<Transform>().SetParent(GameObject.Find("MainUI/TextPanel").GetComponent<Transform>(), true); |
| | | string bloodStr = "-"; |
| | | bloodStr += ((Int64)val).ToString(); |
| | | |
| | | tm.moveBloodText(spos.x, spos.y, bloodStr, crit); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 减速飘字 |
| | | /// </summary> |
| | | public void FloatSlowDownWord(Vector3 worldPos) |
| | | { |
| | | Vector3 screenPos = m_Camera.WorldToScreenPoint(worldPos); |
| | | GameObject obj = Instantiate(SlowDownWord.gameObject); |
| | | obj.GetComponent<Transform>().SetParent(GameObject.Find("MainUI/TextPanel").GetComponent<Transform>(), false); |
| | | obj.GetComponent<TextMoveDoTween>().FloatSlowDownWord(screenPos.x, screenPos.y); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 暴击飘字 |
| | | /// </summary> |
| | | public void FloatCritWord(Vector3 worldPos) |
| | | { |
| | | Vector3 screenPos = m_Camera.WorldToScreenPoint(worldPos); |
| | | GameObject obj = Instantiate(CritWord.gameObject); |
| | | obj.GetComponent<Transform>().SetParent(GameObject.Find("MainUI/TextPanel").GetComponent<Transform>(), false); |
| | | obj.GetComponent<TextMoveDoTween>().FloatCritWord(screenPos.x, screenPos.y); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 冰冻飘字 |
| | | /// </summary> |
| | | /// <param name="worldPos"></param> |
| | | public void FloatFrostWord(Vector3 worldPos) |
| | | { |
| | | Vector3 screenPos = m_Camera.WorldToScreenPoint(worldPos); |
| | | GameObject obj = Instantiate(FrostWord.gameObject); |
| | | obj.GetComponent<Transform>().SetParent(GameObject.Find("MainUI/TextPanel").GetComponent<Transform>(), false); |
| | | obj.GetComponent<TextMoveDoTween>().FloatFrostWord(screenPos.x, screenPos.y); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 克制飘字 |
| | | /// </summary> |
| | | /// <param name="worldPos"></param> |
| | | public void FloatRestrainWord(Vector3 worldPos) |
| | | { |
| | | Vector3 screenPos = m_Camera.WorldToScreenPoint(worldPos); |
| | | GameObject obj = Instantiate(RestrainWord.gameObject); |
| | | obj.GetComponent<Transform>().SetParent(GameObject.Find("MainUI/TextPanel").GetComponent<Transform>(), false); |
| | | obj.GetComponent<TextMoveDoTween>().FloatRestrainWord(screenPos.x, screenPos.y); |
| | | } |
| | | |
| | | private void Start() |
| | |
| | | m_CurrentArea = placeObj.GetComponent<IPlacementArea>(); |
| | | dragTowerPlacement = placeObj.GetComponent<IPlacementArea>() as TowerPlacementGridEndless; |
| | | } |
| | | placeObj = GameObject.FindGameObjectWithTag("PlaceTowerOpponent"); |
| | | //placeObj = GameObject.FindGameObjectWithTag("PlaceTowerOpponent"); |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.EndlessHeartAllLose, AllHeartLose); |
| | | } |
| | | |
| | |
| | | bool successfulPurchase = EndlessLevelManager.instance.Currency.TryPurchase(cost); |
| | | if (!successfulPurchase) return false; |
| | | |
| | | EndlessRandomTower.instance.UpdateDescDisplay(); |
| | | SetUpGhostTower(tow); |
| | | //Debug.Log("设置影子塔防."); |
| | | m_CurrentTower.Show(); |
| | |
| | | RaycastHit output; |
| | | // River: Raycast的碰撞是游戏内物品的Collider进行碰撞检测的 |
| | | bool hasHit = Physics.Raycast(uiPointer.ray, out output, float.MaxValue, towerSelectionLayer); |
| | | if (!hasHit)//|| uiPointer.overUI) |
| | | if (!hasHit || uiPointer.overUI) |
| | | { |
| | | //Debug.Log("没有点中或者点中了UI:" + hasHit.ToString() + "," + uiPointer.overUI.ToString()); |
| | | return; |
| | | } |
| | | var controller = output.collider.GetComponent<Tower>(); |
| | | Tower controller = output.collider.GetComponent<Tower>(); |
| | | if (controller != null) |
| | | { |
| | | // 泡泡禁锢状态不允许拖动 |
| | | if (controller.IsStartBondage) return; |
| | | |
| | | SelectTower(controller); |
| | | } |
| | | |
| | |
| | | CalSelTowerScreenOffset(info, controller); |
| | | } |
| | | |
| | | public void OnPressed(PointerInfo info) |
| | | { |
| | | UIPointer uiPointer = WrapPointer(info); |
| | | RaycastHit output; |
| | | bool hasHit = Physics.Raycast(uiPointer.ray, out output, float.MaxValue, towerSelectionLayer); |
| | | |
| | | if (uiPointer.overUI) return; |
| | | |
| | | if (hasHit) |
| | | { |
| | | Tower controller = output.collider.GetComponent<Tower>(); |
| | | if (controller != null) |
| | | controller.OnPressed(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 鼠标选中一个Tower的时候,计算当前鼠标位置与当前Tower位置在屏幕上坐标位置的偏移量。 |
| | |
| | | |
| | | state = State.Normal; |
| | | m_Camera = GameObject.Find("SceneCamera3D").GetComponent<Camera>(); |
| | | //m_Camera = GameObject.Find("BackCamera").GetComponent<Camera>(); |
| | | |
| | | //m_Camera = GetComponent<Camera>(); |
| | | TowerDestroyArr = new bool[5, AttackRowNumbers]; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 战场内所有的Tower实例都需要升级相关的数据. |
| | | /// 找到相同类型的所有Tower,然后进行局内升级的修改。 |
| | | /// </summary> |
| | | /// <param name="td"></param> |
| | | protected void towerUpgradeInBattle(TowerLevelUp tlu) |
| | | { |
| | | foreach (Tower tower in m_listTower) |
| | | { |
| | | if (tlu.towerName != tower.towerName) |
| | | continue; |
| | | tower.upGradeInSceneTL(); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | // WORK START: 从这里开始,移动的时候与场景内的WaveSelEffect射线做碰撞。 |
| | | // Raycast onto placement layer |
| | | PlacementAreaRaycast(ref npt); |
| | | |
| | | //Debug.Log("npt.raycast:" + npt.raycast); |
| | | if (npt.raycast != null) |
| | | { |
| | | MoveGhostWithRaycastHit(npt.raycast.Value); |
| | | } |
| | | else |
| | | { |
| | | MoveGhostOntoWorld(npt.ray, hideWhenInvalid); |
| | | |
| | | return; |
| | | // 根据技能塔的类型,来碰撞不同的数据: |
| | | // 火是列攻击: |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Fire) |
| | |
| | | m_CurrentTower.fadeOutAttackArea(); |
| | | } |
| | | |
| | | MoveGhostOntoWorld(npt.ray, hideWhenInvalid); |
| | | } |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | { |
| | | RaycastHit hit; |
| | | |
| | | Physics.Raycast(ray, out hit, float.MaxValue); |
| | | // check against all layers that the ghost can be on |
| | | Physics.SphereCast(ray, sphereCastRadius, out hit, float.MaxValue, ghostWorldPlacementMask); |
| | | //Physics.SphereCast(ray, sphereCastRadius, out hit, float.MaxValue, ghostWorldPlacementMask); |
| | | if (hit.collider == null) |
| | | { |
| | | return; |
| | |
| | | /// <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) |
| | |
| | | // Place the ghost |
| | | Tower controller = m_CurrentTower.controller; |
| | | Tower createdTower = Instantiate(controller); |
| | | createdTower.Initialize(m_CurrentArea, m_GridPosition); |
| | | createdTower.SetLevel(dragTowerLevel); |
| | | createdTower.Initialize(m_CurrentArea, m_GridPosition, dragTowerLevel); |
| | | |
| | | // ATTENTION TO FIX:是否应该加入List: |
| | | addTower(createdTower); |
| | | PlayToAttackEffect(createdTower.attributeId, createdTower.transform.position); |
| | | PlayToAttackEffect(createdTower.ElfId, createdTower.transform.position); |
| | | dragTowerLevel = 0; |
| | | CancelGhostPlacement(); |
| | | } |
| | |
| | | /// <summary> |
| | | /// 播放宝石上阵特效 |
| | | /// </summary> |
| | | /// <param name="attributeId">101 火,105 水,109 木</param> |
| | | /// <param name="ElfId">101 火,201 水,301 木</param> |
| | | /// <param name="worldPos">世界坐标</param> |
| | | public void PlayToAttackEffect(int attributeId, Vector3 worldPos) |
| | | public void PlayToAttackEffect(int ElfId, Vector3 worldPos) |
| | | { |
| | | string path = ""; |
| | | if (attributeId == 101) |
| | | { |
| | | path = "UI/Effect_Elf_Huo_DengChang_101"; |
| | | } |
| | | else if (attributeId == 105) |
| | | { |
| | | path = "UI/Effect_Elf_Shui_DengChang_105"; |
| | | } |
| | | else if (attributeId == 109) |
| | | { |
| | | path = "UI/Effect_Elf_Mu_DengChang_109"; |
| | | } |
| | | string path = $"UI/DengChang_{ElfId}"; |
| | | |
| | | GameObject prefab = Resources.Load<GameObject>(path); |
| | | GameObject obj = Instantiate(prefab); |