| | |
| | | using Core.Health; |
| | | using System.Globalization; |
| | | 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 |
| | | { |
| | |
| | | /// </summary> |
| | | public Button randomTowerBtn; |
| | | |
| | | public Button SkillTowerBtn; |
| | | |
| | | /// <summary> |
| | | /// 飘血数字对应的prefab. |
| | | /// </summary> |
| | |
| | | /// 购买塔防按钮上的Text. |
| | | /// </summary> |
| | | protected TextMeshProUGUI towerPriceText; |
| | | |
| | | protected TextMeshProUGUI towerPriceText1; |
| | | |
| | | protected bool tdBuyDisable = false; |
| | | |
| | |
| | | /// </summary> |
| | | TowerPlacementGhost m_CurrentTower; |
| | | |
| | | public bool HasTower |
| | | { |
| | | get |
| | | { |
| | | return m_CurrentTower != null; |
| | | } |
| | | } |
| | | |
| | | // TowerList用于简单记录相关的数据 |
| | | protected List<Tower> m_listTower = new List<Tower>(); |
| | | |
| | |
| | | |
| | | // 测试屏幕显示相关的倒计时. |
| | | protected bool bLoaded = false; |
| | | |
| | | private Timer overTimer; |
| | | |
| | | /// <summary> |
| | | /// 总兵线数 |
| | |
| | | /// </summary> |
| | | private bool[,] TowerDestroyArr; |
| | | |
| | | public event Action GameOverEvent; |
| | | |
| | | /// <summary> |
| | | /// 塔升级特效预制体 |
| | | /// </summary> |
| | | public GameObject TowerUpgradeEffectPrefab; |
| | | |
| | | /// <summary> |
| | | /// 宝石出现特效预制体 |
| | | /// </summary> |
| | | public GameObject TowerAppearEffectPrefab; |
| | | |
| | | public GameObject TowerUpgradeEffectPrefabGuide;//新手导航特效Layer是UI |
| | | public GameObject TowerAppearEffectPrefabGuide;//新手导航特效Layer是UI |
| | | |
| | | |
| | | //首次购买宝石特效 |
| | | public GameObject fireAppearEffect1; |
| | | public GameObject fireAppearEffect2; |
| | | |
| | | public GameObject waterAppearEffect1; |
| | | public GameObject waterAppearEffect2; |
| | | public GameObject woodAppearEffect1; |
| | | public GameObject woodAppearEffect2; |
| | | /// <summary> |
| | | /// 保存所有生成或合成的塔的最小等级,索引0 -> 火木水塔 索引1 -> 技能塔 |
| | | /// </summary> |
| | | /// <value></value> |
| | | public int MinLevel; |
| | | |
| | | public IPlacementArea selfTowerPlaceArea |
| | | { |
| | | get |
| | |
| | | } |
| | | } |
| | | |
| | | private void UpdateMinLevelArr() |
| | | { |
| | | int min = -1; |
| | | |
| | | for (int i = 0; i < m_listTower.Count; ++i) |
| | | { |
| | | if (min == -1 || m_listTower[i].currentLevel < min) |
| | | min = m_listTower[i].currentLevel; |
| | | } |
| | | |
| | | MinLevel = Mathf.Max(min, 0); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 增加一个防塔的数据结构,测试数据 |
| | | /// </summary> |
| | |
| | | public void addTower(Tower t) |
| | | { |
| | | m_listTower.Add(t); |
| | | UpdateMinLevelArr(); |
| | | |
| | | // 当前所在的位置是否攻击位置,随手瞎写:2 或者 3也就是前两排是上阵的 |
| | | if (t.gridPosition.y >= 2) |
| | |
| | | public bool towerInList(Tower t) |
| | | { |
| | | return m_listTower.Contains(t); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置已经上阵的所有塔的攻击状态,是否可以攻击 |
| | | /// </summary> |
| | | /// <param name="canAttack"></param> |
| | | public void SetAttackingTowerState(bool canAttack) |
| | | { |
| | | foreach (Tower tower in m_listTower) |
| | | { |
| | | tower.bInAttackMode = canAttack; |
| | | } |
| | | } |
| | | |
| | | public void delTower(Tower t) |
| | |
| | | break; |
| | | case State.Paused: |
| | | case State.GameOver: |
| | | // if (oldState == State.Building) |
| | | // { |
| | | // CancelGhostPlacement(); |
| | | // } |
| | | // Time.timeScale = 0f; |
| | | Debug.Log("--------------------- game over !!! ---------------------"); |
| | | if (oldState == State.Building) |
| | | CancelGhostPlacement(); |
| | | Time.timeScale = 1f; |
| | | break; |
| | | default: |
| | | throw new ArgumentOutOfRangeException("newState", newState, null); |
| | |
| | | UIPointer pointer = WrapPointer(pinfo); |
| | | Tower sTower = PickTowerInGrid(pointer); |
| | | if (sTower != null) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | if ((m_GridPosition.x >= 0) && (m_GridPosition.y >= 0)) |
| | | { |
| | | if (m_CurrentArea.isFreeAtackPos(m_GridPosition.x, m_GridPosition.y)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断是否有不同类型的Tower,可以发生置换,仅限于火木水之间发生 |
| | | /// </summary> |
| | | /// <param name="pinfo"></param> |
| | | /// <returns></returns> |
| | | protected bool IsSubstitute(PointerInfo pinfo) |
| | | { |
| | | if (!m_CurrentTower || !IsGhostAtValidPosition()) |
| | | { |
| | | // 判断格子上的塔防: |
| | | UIPointer pointer = WrapPointer(pinfo); |
| | | Tower sTower = PickTowerInGrid(pointer); |
| | | |
| | | if (sTower && sTower != towerToMove) |
| | | { |
| | | if (towerToMove && sTower.towerFeature == EFeatureTower.NULL && towerToMove.towerFeature == EFeatureTower.NULL && sTower.bInAttackMode == towerToMove.bInAttackMode) |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取目标格子上的塔防的名字数据 |
| | | /// </summary> |
| | | /// <param name="pinfo"></param> |
| | |
| | | /// <param name="tower"></param> |
| | | protected void growUpTower(Tower tower) |
| | | { |
| | | Tower newTower = EndlessRandomTower.instance.GetRandomTower(false); |
| | | Tower newTower = EndlessRandomTower.instance.GetRandomTower(EFeatureTower.NULL, true); |
| | | |
| | | // 所有的Tower不能升级成为FeatureTower. |
| | | int maxLoop = 20; |
| | | while (newTower.towerFeature != EFeatureTower.NULL) |
| | | { |
| | | newTower = EndlessRandomTower.instance.GetRandomTower(false); |
| | | newTower = EndlessRandomTower.instance.GetRandomTower(EFeatureTower.NULL, true); |
| | | maxLoop--; |
| | | if (maxLoop <= 0) |
| | | { |
| | |
| | | /// <param name="opponent"></param> |
| | | public void DestroyTowerGrid(int xidx) |
| | | { |
| | | // 这里的逻辑已经不走了 |
| | | for (int i = 0; i < AttackRowNumbers; ++i) |
| | | { |
| | | if (TowerDestroyArr[xidx, i]) continue; |
| | |
| | | } |
| | | |
| | | TowerDestroyArr[xidx, i] = true; |
| | | Tower tower = FindTowerWithGridIdx(xidx, i); |
| | | Tower tower = FindTowerWithGridIdx(xidx, 3 - i); |
| | | |
| | | if (tower) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | // 红心减少逻辑 |
| | | // HealthHeartState.instance.killHeart(false); |
| | | GameOver(); |
| | | overTimer = new Timer(1.2f, SafelyCallGameOverEvent); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 爱心数量为0,游戏结束 |
| | | /// </summary> |
| | | private void AllHeartLose() |
| | | { |
| | | // 清理技能 |
| | | EndlessBossSkillManager.instance.ClearSkillList(); |
| | | EndlessBossHPManager.instance.SwitchHP(true); |
| | | EndlessBossHPManager.instance.SetCurrentHP(0); |
| | | |
| | | // 停止所有兵线的出兵 |
| | | for (int i = 0; i < TotalWaveLines; ++i) |
| | | { |
| | | EndlessLevelManager.instance.StopWaveLine(i); |
| | | } |
| | | |
| | | // 让所有兵线上已经生成的所有agent播放一个死亡动画然后销毁 |
| | | WaveLineAgentInsMgr[] waveLineAgentIns = AgentInsManager.instance.GetWaveLineList(); |
| | | |
| | | for (int i = 0; i < waveLineAgentIns.Length; ++i) |
| | | { |
| | | while (waveLineAgentIns[i].listAgent.Count > 0) |
| | | { |
| | | waveLineAgentIns[i].listAgent[0].PlayDeath(); |
| | | } |
| | | } |
| | | |
| | | GameOver(); |
| | | overTimer = new Timer(1.2f, SafelyCallGameOverEvent); |
| | | } |
| | | |
| | | private void SafelyCallGameOverEvent() |
| | | { |
| | | if (GameOverEvent != null) |
| | | GameOverEvent(); |
| | | overTimer = null; |
| | | } |
| | | |
| | | #region 拖动时候给塔位一个标识 |
| | | |
| | | public MeshRenderer temporaryMat;//移动时候的虚像材质 |
| | | |
| | | /// <summary> |
| | | /// 查找可以合成的塔 |
| | | /// </summary> |
| | | public void CheckAllCanPlace() |
| | | { |
| | | if (m_CurrentTower != null) |
| | | { |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | List<IntVector2> allTowerP = new List<IntVector2>(); |
| | | List<IntVector2> allPSTowerP = new List<IntVector2>();//需要播放升级动画的 |
| | | |
| | | for (int i = 0; i < m_listTower.Count; i++) |
| | | { |
| | | if (m_listTower[i].bInAttackMode && towerToMove && m_listTower[i].currentLevel == dragTowerLevel && m_listTower[i].towerName == towerToMove.towerName) |
| | | { |
| | | if (towerToMove.gridPosition != m_listTower[i].gridPosition) |
| | | //说明可以合成 |
| | | allPSTowerP.Add(m_listTower[i].gridPosition); |
| | | } |
| | | else |
| | | { |
| | | //把不符合条件的传进去 |
| | | allTowerP.Add(m_listTower[i].gridPosition); |
| | | } |
| | | } |
| | | if (m_CurrentArea != null) |
| | | { |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckAllCanPlace(allTowerP); |
| | | //(m_CurrentArea as TowerPlacementGridEndless).PlayPS(allPSTowerP); |
| | | } |
| | | |
| | | |
| | | } |
| | | else if (m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Fire || m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Bomb) |
| | | { |
| | | //Debug.Log("需要激活兵线下方绿色标识"); |
| | | EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessStartDragSkill, true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 关闭所有标识 |
| | | /// </summary> |
| | | public void CloseCanPlaceRenderer() |
| | | { |
| | | if (m_CurrentTower && m_CurrentTower.controller && m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Fire || m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Bomb) |
| | | { |
| | | EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessStartDragSkill, false); |
| | | } |
| | | |
| | | if (m_CurrentArea != null) |
| | | (m_CurrentArea as TowerPlacementGridEndless).CloseCanPlaceRenderer(); |
| | | else |
| | | { |
| | | GameObject placeObj = GameObject.FindGameObjectWithTag("PlaceTower"); |
| | | if (placeObj != null) |
| | | (placeObj.GetComponent<IPlacementArea>() as TowerPlacementGridEndless).CloseCanPlaceRenderer(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检查符合条件的塔 |
| | | /// </summary> |
| | | /// <param name="pointerInfo"></param> |
| | | public void CheckTowerPlace(PointerInfo pointerInfo) |
| | | { |
| | | //return; |
| | | if (m_CurrentArea != null && m_CurrentArea is TowerPlacementGridEndless) |
| | | { |
| | | //下面是为了设置一个虚拟的塔 |
| | | if (isFreeAttackGridOnDrag(pointerInfo) && m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | //Debug.Log("得到了一个空的塔位"); |
| | | |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, false, ""); |
| | | //if(temporaryMat) |
| | | } |
| | | else if ((m_GridPosition.x >= 0) && (m_GridPosition.y >= 0)) |
| | | { |
| | | if (m_CurrentArea.isFreeAtackPos(m_GridPosition.x, m_GridPosition.y)) |
| | | { |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, true, towerToMove.towerName); |
| | | } |
| | | else |
| | | { |
| | | (m_CurrentArea as TowerPlacementGridEndless).CloseCanPlace(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | (m_CurrentArea as TowerPlacementGridEndless).CloseCanPlace(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //Debug.Log("什么情况"); |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | dragTowerPlacement.CloseCanPlace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | TowerPlacementGridEndless dragTowerPlacement; |
| | | |
| | | /// <summary> |
| | | /// 目标位置是否是可攻击属性的空塔位 |
| | | /// </summary> |
| | | /// <param name="pinfo"></param> |
| | | /// <returns></returns> |
| | | protected bool isFreeAttackGridOnDrag(PointerInfo pinfo) |
| | | { |
| | | // 判断格子上的塔防: |
| | | UIPointer pointer = WrapPointer(pinfo); |
| | | Tower sTower = PickTowerInGrid(pointer); |
| | | if (sTower != null) |
| | | { |
| | | if (sTower.bInAttackMode && towerToMove && sTower.currentLevel == dragTowerLevel && sTower.towerName == towerToMove.towerName) |
| | | { |
| | | //说明可以合成 |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 拖动一个Tower之后,松开鼠标或者EndDrag. |
| | |
| | | public void onEndTowerDrag(PointerInfo pointerInfo) |
| | | { |
| | | bool bSkill = false; |
| | | if (temporaryMat != null) |
| | | { |
| | | //移动虚像隐藏 |
| | | temporaryMat.material = null; |
| | | } |
| | | |
| | | if (!m_CurrentTower || !m_CurrentTower.controller) |
| | | { |
| | | CancelPlaceTower(pointerInfo); |
| | |
| | | TryPlaceTower(pointerInfo); |
| | | else if (isFreeAttackGrid(pointerInfo) && !bSkill) |
| | | { |
| | | if (!TryPlaceTower(pointerInfo, false, true)) return; |
| | | if (!TryPlaceTower(pointerInfo, false, true)) |
| | | { |
| | | CancelPlaceTower(pointerInfo); |
| | | |
| | | Debug.Log("这里需要返回原位"); |
| | | return; |
| | | } |
| | | |
| | | // 删除towerToMove,确保塔防数据不再出现多个 |
| | | if (towerToMove != null) |
| | |
| | | towerToMove.showTower(true); |
| | | towerToMove.Sell(); |
| | | towerToMove = null; |
| | | } |
| | | } |
| | | else if (EndlessLevelManager.instanceExists && IsSubstitute(pointerInfo)) |
| | | { |
| | | // 可以发生置换 |
| | | UIPointer pointer = WrapPointer(pointerInfo); |
| | | // 格子上的塔 |
| | | Tower sTower = PickTowerInGrid(pointer); |
| | | |
| | | 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); |
| | | |
| | | Tower newTower1 = PlaceTowerForce(EndlessRandomTower.instance.getTowerByName(sTower.towerName), v1, sTower.currentLevel + 1, false); |
| | | Tower newTower2 = PlaceTowerForce(m_CurrentTower.controller, v2, towerToMove.currentLevel + 1, false); |
| | | |
| | | if (towerToMove != null) |
| | | { |
| | | delTower(towerToMove); |
| | | towerToMove.showTower(true); |
| | | towerToMove.Sell(); |
| | | towerToMove = null; |
| | | } |
| | | |
| | | delTower(sTower); |
| | | sTower.showTower(true); |
| | | sTower.Sell(); |
| | | sTower = null; |
| | | |
| | | CancelGhostPlacement(); |
| | | |
| | | newTower1.placementArea.Occupy(newTower1.gridPosition, newTower1.dimensions); |
| | | newTower2.placementArea.Occupy(newTower2.gridPosition, newTower2.dimensions); |
| | | } |
| | | } |
| | | // 当前是Skill塔位的状态. |
| | |
| | | } |
| | | else |
| | | CancelPlaceTower(pointerInfo); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 强制放置塔,主要是用于新手 |
| | | /// </summary> |
| | | /// <param name="newTower"></param> |
| | | /// <param name="pos"></param> |
| | | /// <param name="level">塔的等级</param> |
| | | public Tower PlaceTowerForce(Tower newTower, IntVector2 pos, int level, bool playEffect = true) |
| | | { |
| | | TowerPlacementGhost currentTower = Instantiate(newTower.towerGhostPrefab); |
| | | currentTower.Initialize(newTower); |
| | | Tower controller = currentTower.controller; |
| | | Tower createdTower = Instantiate(controller); |
| | | createdTower.PlayWaveLineFlash = playEffect; |
| | | createdTower.Initialize(m_CurrentArea, pos); |
| | | createdTower.SetLevel(level - 1); |
| | | |
| | | if (playEffect) |
| | | PlayUpgradeEffect(createdTower); |
| | | |
| | | addTower(createdTower); |
| | | Destroy(currentTower.gameObject); |
| | | |
| | | return createdTower; |
| | | } |
| | | |
| | | protected bool SkillPlayEndDrag(PointerInfo pointer) |
| | |
| | | // 播放特效,并处理伤害. |
| | | EndlessWaveLineManager.instance.PlayWaveLineEffect(selEff.waveLineId); |
| | | AgentInsManager.instance.ExecWavelineAttack(selEff.waveLineId, sId, sLevel, false); |
| | | ++GameConfig.EndlessPortUseSkillTowerCount; |
| | | return true; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放升级特效 |
| | | /// </summary> |
| | | /// <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); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Deselect the current tower and hides the UI |
| | | /// </summary> |
| | | public void DeselectTower() |
| | |
| | | /// <exception cref="InvalidOperationException"> |
| | | /// Throws exception if not in Build State or <see cref="m_CurrentTower"/> is not at a valid position |
| | | /// </exception> |
| | | public void PlaceTower(int lvl = 0, bool opponent = false) |
| | | public void PlaceTower(int lvl = 0, bool isUpgrade = false, bool opponent = false, bool isFirstAppear = false) |
| | | { |
| | | if (!isBuilding) |
| | | throw new InvalidOperationException("Trying to place tower when not in a Build Mode"); |
| | |
| | | |
| | | // River: 内部缓存数据,用于后期容易找到数据. |
| | | addTower(createdTower); |
| | | |
| | | CancelGhostPlacement(); |
| | | if (isFirstAppear) |
| | | { |
| | | PlayFirstAppearEffect(createdTower.towerName, createdTower.transform.position); |
| | | } |
| | | else if (!isUpgrade) |
| | | { |
| | | PlayAppearEffect(createdTower.transform.position); |
| | | } |
| | | else |
| | | { |
| | | PlayUpgradeEffect(createdTower); |
| | | } |
| | | |
| | | // 处理成长骰子,复制骰子等等功能. |
| | | if (lvl == 0) |
| | | { |
| | | ProcessFeatureTower(createdTower); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放首次宝石出现特效 |
| | | /// </summary> |
| | | public void PlayFirstAppearEffect(string towerName, Vector3 worldPos) |
| | | { |
| | | if (towerName.StartsWith("GrowUpTower")) |
| | | { |
| | | //火元素 |
| | | PlayAppearEffect(worldPos, fireAppearEffect1); |
| | | PlayAppearEffect(worldPos, fireAppearEffect2); |
| | | if (Application.platform == RuntimePlatform.WindowsEditor) |
| | | { |
| | | //UnityEditor.EditorApplication.isPaused = true; |
| | | } |
| | | } |
| | | else if (towerName.StartsWith("BlinkTower")) |
| | | { |
| | | //木元素 |
| | | PlayAppearEffect(worldPos, woodAppearEffect1); |
| | | PlayAppearEffect(worldPos, woodAppearEffect2); |
| | | |
| | | } |
| | | else if (towerName.StartsWith("CopyCatTower")) |
| | | { |
| | | //水元素 |
| | | PlayAppearEffect(worldPos, waterAppearEffect1); |
| | | PlayAppearEffect(worldPos, waterAppearEffect2); |
| | | } |
| | | } |
| | | void PlayAppearEffect(Vector3 worldPos, GameObject prefab) |
| | | { |
| | | GameObject obj = Instantiate(prefab); |
| | | obj.transform.position = worldPos; |
| | | 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); |
| | | } |
| | | |
| | | public void PlayAppearEffectGuide(Vector3 worldPos) |
| | | { |
| | | GameObject obj = Instantiate(TowerAppearEffectPrefabGuide); |
| | | obj.transform.position = worldPos; |
| | | |
| | | 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); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放宝石出现特效 |
| | | /// </summary> |
| | | public void PlayAppearEffect(Vector3 worldPos) |
| | | { |
| | | GameObject obj = Instantiate(TowerAppearEffectPrefab); |
| | | obj.transform.position = worldPos; |
| | | 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); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 播放升级特效 |
| | | /// </summary> |
| | | /// <param name="worldPos"></param> |
| | | public void GuidePlayUpgradeEffect(Vector3 position) |
| | | { |
| | | // 在sTower的位置播放升级特效 |
| | | GameObject obj = Instantiate(TowerUpgradeEffectPrefabGuide); |
| | | obj.transform.position = 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); |
| | | } |
| | | |
| | | protected void ProcessFeatureTower(Tower ctower) |
| | |
| | | if (!towerPriceText) |
| | | { |
| | | towerPriceText = randomTowerBtn.transform.Find("cashText").GetComponent<TextMeshProUGUI>(); |
| | | towerPriceText1 = SkillTowerBtn.transform.Find("cashText").GetComponent<TextMeshProUGUI>(); |
| | | if (towerPriceText) |
| | | towerPriceText.text = tpMgr.currentTowerPrice.ToString(); |
| | | if (towerPriceText1) |
| | | towerPriceText1.text = tpMgr.currentTowerPrice.ToString(); |
| | | } |
| | | else |
| | | { |
| | | towerPriceText.text = tpMgr.currentTowerPrice.ToString(); |
| | | towerPriceText1.text = tpMgr.currentTowerPrice.ToString(); |
| | | } |
| | | |
| | | // 无法支付新的塔防价格,按钮变灰. |
| | |
| | | /// </summary> |
| | | protected void disableRandomTowerBtn() |
| | | { |
| | | randomTowerBtn.interactable = false; |
| | | randomTowerBtn.GetComponent<EndlessRandomTower>().ChangeBtnClick(); |
| | | //randomTowerBtn.interactable = false; |
| | | if (towerPriceText) |
| | | { |
| | | towerPriceText.color = new Color(0.5f, 0.5f, 0.5f); |
| | | towerPriceText1.color = new Color(0.5f, 0.5f, 0.5f); |
| | | } |
| | | tdBuyDisable = true; |
| | | } |
| | |
| | | return; |
| | | |
| | | if (towerPriceText) |
| | | { |
| | | towerPriceText.color = new Color(1.0f, 1.0f, 1.0f); |
| | | towerPriceText1.color = new Color(1.0f, 1.0f, 1.0f); |
| | | } |
| | | |
| | | if (randomTowerBtn) |
| | | randomTowerBtn.interactable = true; |
| | | { |
| | | randomTowerBtn.GetComponent<EndlessRandomTower>().ChangeBtnClickNormal(); |
| | | //randomTowerBtn.interactable = true; |
| | | } |
| | | tdBuyDisable = false; |
| | | } |
| | | |
| | |
| | | if (crit) |
| | | bloodStr += "Crt!"; |
| | | bloodStr += "-"; |
| | | bloodStr += val.ToString(); |
| | | bloodStr += ((Int64)val).ToString(); |
| | | |
| | | tm.moveBloodText(spos.x, spos.y, bloodStr, crit); |
| | | } |
| | |
| | | // 获取相应的放置区域。 |
| | | GameObject placeObj = GameObject.FindGameObjectWithTag("PlaceTower"); |
| | | if (placeObj != null) |
| | | { |
| | | m_CurrentArea = placeObj.GetComponent<IPlacementArea>(); |
| | | dragTowerPlacement = placeObj.GetComponent<IPlacementArea>() as TowerPlacementGridEndless; |
| | | } |
| | | placeObj = GameObject.FindGameObjectWithTag("PlaceTowerOpponent"); |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.EndlessHeartAllLose, AllHeartLose); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// 直接在IPlaceArea上随机放置一个Tower。这是随机放置塔防的入口类。这是入口的塔防类。 |
| | | /// </summary> |
| | | /// <param name="tow"></param> |
| | | public bool RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0, int forceCost = -1) |
| | | public bool RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0, int forceCost = -1, bool isUpgrade = false, bool isFirstAppear = false) |
| | | { |
| | | // 获取IPlaceArea. |
| | | if (m_CurrentArea == null) |
| | |
| | | int cost = TowerPrice.instance.currentTowerPrice; |
| | | if (zeroCost) |
| | | cost = 0; |
| | | |
| | | |
| | | if (forceCost != -1) |
| | | cost = forceCost; |
| | | |
| | |
| | | m_CurrentTower.Show(); |
| | | if (successfulPurchase) |
| | | { |
| | | ++GameConfig.EndlessBuyTowerCount; |
| | | // 删除towerToMove,确保塔防数据不再出现多个 |
| | | if (zeroCost && (towerToMove != null)) |
| | | { |
| | |
| | | OnSuccessBuyTower(); |
| | | SetState(State.Building); |
| | | |
| | | PlaceTower(lvl); |
| | | PlaceTower(lvl, isUpgrade, false, isFirstAppear); |
| | | } |
| | | |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | // 计算偏移值. |
| | | CalSelTowerScreenOffset(info, controller); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 鼠标选中一个Tower的时候,计算当前鼠标位置与当前Tower位置在屏幕上坐标位置的偏移量。 |
| | |
| | | { |
| | | base.Awake(); |
| | | |
| | | randomTowerBtn = transform.Find("BottomCanvas/Panel/TowerBuyBtn").GetComponent<Button>(); |
| | | DOTween.Init(true, true, LogBehaviour.Verbose).SetCapacity(200, 10); |
| | | |
| | | state = State.Normal; |
| | | m_Camera = GetComponent<Camera>(); |
| | | m_Camera = GameObject.Find("SceneCamera3D").GetComponent<Camera>(); |
| | | //m_Camera = GetComponent<Camera>(); |
| | | TowerDestroyArr = new bool[5, AttackRowNumbers]; |
| | | } |
| | | |
| | |
| | | return currentEventSystem.IsPointerOverGameObject(pointerId); |
| | | } |
| | | |
| | | WaveLineSelEffect currentEffect; |
| | | /// <summary> |
| | | /// Move the ghost to the pointer's position |
| | | /// </summary> |
| | |
| | | if (npt.overWaveLine) |
| | | { |
| | | WaveLineSelEffect selEff = npt.wavelineHit.Value.collider.GetComponent<WaveLineSelEffect>(); |
| | | if (selEff) |
| | | selEff.SetWaveLineSel(true); |
| | | if (selEff != currentEffect) |
| | | { |
| | | if (currentEffect != null) |
| | | { |
| | | currentEffect.SetParticleSystem(false); |
| | | } |
| | | currentEffect = selEff; |
| | | currentEffect.SetParticleSystem(true); |
| | | } |
| | | //selEff.SetWaveLineSel(true); |
| | | } |
| | | } |
| | | // 炸弹是区域攻击显示: |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Bomb) |
| | | else if (m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Bomb) |
| | | { |
| | | // 测试代码与战场区域碰撞,碰撞后显示攻击区域: |
| | | BattleAreaRaycast(ref npt); |
| | |
| | | |
| | | // ATTENTION TO FIX:是否应该加入List: |
| | | addTower(createdTower); |
| | | PlayToAttackEffect(createdTower.attributeId, createdTower.transform.position); |
| | | dragTowerLevel = 0; |
| | | CancelGhostPlacement(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放宝石上阵特效 |
| | | /// </summary> |
| | | /// <param name="attributeId">101 火,105 水,109 木</param> |
| | | /// <param name="worldPos">世界坐标</param> |
| | | public void PlayToAttackEffect(int attributeId, 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"; |
| | | } |
| | | |
| | | GameObject prefab = Resources.Load<GameObject>(path); |
| | | GameObject obj = Instantiate(prefab); |
| | | obj.transform.position = worldPos; |
| | | 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); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | private void Update() |
| | | { |
| | | if (overTimer != null) |
| | | overTimer.Tick(Time.deltaTime); |
| | | |
| | | for (int ti = listTowerTimer.Count - 1; ti >= 0; ti--) |
| | | { |
| | | // 如果执行到,会在DelTower函数内删除对应的listTowerTimer. |