| | |
| | | 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> |
| | | /// 购买塔防按钮上的Text. |
| | | /// </summary> |
| | | protected TextMeshProUGUI towerPriceText; |
| | | |
| | | //protected TextMeshProUGUI towerPriceText1; |
| | | |
| | | protected bool tdBuyDisable = false; |
| | | |
| | |
| | | SetToDragMode(newT); |
| | | |
| | | if (towerOld.towerFeature == EFeatureTower.Skill_Bomb) |
| | | m_CurrentTower.SetAttackArea(dragTowerLevel, towerOld.attributeId); |
| | | m_CurrentTower.SetAttackArea(dragTowerLevel, towerOld.ElfId); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | if (!m_CurrentTower || !IsGhostAtValidPosition()) |
| | | { |
| | | // 最大级别的Tower不能再合并了. |
| | | if (towerToMove.isAtMaxLevel) |
| | | if (towerToMove.IsMaxLevel) |
| | | return false; |
| | | |
| | | // 判断格子上的塔防: |
| | | UIPointer pointer = WrapPointer(pinfo); |
| | | Tower sTower = PickTowerInGrid(pointer); |
| | | |
| | | // 泡泡禁锢状态不允许合并 |
| | | if (sTower.IsBondage) return false; |
| | | |
| | | if (sTower && sTower != towerToMove) |
| | | { |
| | | int testLvl = dragTowerLevel; |
| | |
| | | // 判断格子上的塔防: |
| | | UIPointer pointer = WrapPointer(pinfo); |
| | | Tower sTower = PickTowerInGrid(pointer); |
| | | |
| | | // 泡泡禁锢状态不允许置换 |
| | | if (sTower.IsBondage) return false; |
| | | |
| | | if (sTower && sTower != towerToMove) |
| | | { |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | |
| | | dragTowerPlacement.CloseCanPlace(); |
| | | if (bInAttackModeTower != null) |
| | | { |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(false); |
| | | bInAttackModeTower.CurrentTowerLevel.SetCanPlace(false); |
| | | bInAttackModeTower = null; |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | GuideCtrl.Ins.EndDrag11_1(); |
| | | GuideCtrl.Ins.EndDrag5_1(); |
| | | CancelPlaceTower(pointerInfo); |
| | | Debug.Log("没有放置在火塔上"); |
| | | } |
| | |
| | | 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; |
| | | |
| | | // 火是列攻击: |
| | |
| | | { |
| | | throw new InvalidOperationException("Selected Tower is null"); |
| | | } |
| | | if (currentSelectedTower.isAtMaxLevel) |
| | | if (currentSelectedTower.IsMaxLevel) |
| | | { |
| | | return; |
| | | } |
| | |
| | | { |
| | | throw new InvalidOperationException("Selected Tower is null"); |
| | | } |
| | | if (currentSelectedTower.isAtMaxLevel) |
| | | if (currentSelectedTower.IsMaxLevel) |
| | | return false; |
| | | |
| | | // 直接随机升级,零成本。 |
| | |
| | | /// <param name="worldPos"></param> |
| | | public void PlayUpgradeEffect(Tower newTower) |
| | | { |
| | | newTower.currentTowerLevel.PlayUpGradeEffect(); |
| | | newTower.CurrentTowerLevel.PlayUpGradeEffect(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | if (tm) |
| | | { |
| | | tm.GetComponent<Transform>().SetParent(GameObject.Find("MainUI/TextPanel").GetComponent<Transform>(), true); |
| | | string bloodStr = ""; |
| | | if (doubleHit) |
| | | bloodStr += "Dble!"; |
| | | if (crit) |
| | | bloodStr += "Crt!"; |
| | | bloodStr += "-"; |
| | | 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); |
| | | } |
| | | |
| | | private void Start() |
| | |
| | | var controller = output.collider.GetComponent<Tower>(); |
| | | if (controller != null) |
| | | { |
| | | // 泡泡禁锢状态不允许拖动 |
| | | if (controller.IsBondage) 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位置在屏幕上坐标位置的偏移量。 |
| | |
| | | m_Camera = GameObject.Find("SceneCamera3D").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> |
| | |
| | | // 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 = $"UI/DengChang_{attributeId}"; |
| | | string path = $"UI/DengChang_{ElfId}"; |
| | | |
| | | GameObject prefab = Resources.Load<GameObject>(path); |
| | | GameObject obj = Instantiate(prefab); |