| | |
| | | /// </summary> |
| | | public Button randomTowerBtn; |
| | | |
| | | public Button SkillTowerBtn; |
| | | |
| | | /// <summary> |
| | | /// 飘血数字对应的prefab. |
| | | /// </summary> |
| | |
| | | /// 购买塔防按钮上的Text. |
| | | /// </summary> |
| | | protected TextMeshProUGUI towerPriceText; |
| | | |
| | | protected TextMeshProUGUI towerPriceText1; |
| | | |
| | | protected bool tdBuyDisable = false; |
| | | |
| | |
| | | /// </summary> |
| | | public GameObject TowerAppearEffectPrefab; |
| | | |
| | | public GameObject TowerUpgradeEffectPrefabGuide;//新手导航特效Layer是UI |
| | | public GameObject TowerAppearEffectPrefabGuide;//新手导航特效Layer是UI |
| | | |
| | | |
| | | //首次购买宝石特效 |
| | | public GameObject fireAppearEffect1; |
| | | public GameObject fireAppearEffect2; |
| | |
| | | public GameObject woodAppearEffect1; |
| | | public GameObject woodAppearEffect2; |
| | | /// <summary> |
| | | /// 保存所有生成或合成的塔的最小等级,索引0 -> 火木水塔 索引1 -> 技能塔 |
| | | /// 保存所有生成或合成的塔的最小等级 |
| | | /// </summary> |
| | | /// <value></value> |
| | | public int MinLevel; |
| | |
| | | |
| | | if (sTower && sTower != towerToMove) |
| | | { |
| | | if (towerToMove && sTower.towerFeature == EFeatureTower.NULL && towerToMove.towerFeature == EFeatureTower.NULL && sTower.bInAttackMode == towerToMove.bInAttackMode) |
| | | if (towerToMove && sTower.towerFeature == EFeatureTower.NULL && towerToMove.towerFeature == EFeatureTower.NULL && sTower.bInAttackMode && towerToMove.bInAttackMode) |
| | | return true; |
| | | } |
| | | } |
| | |
| | | /// <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) |
| | | { |
| | |
| | | { |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | List<IntVector2> allTowerP = new List<IntVector2>(); |
| | | List<IntVector2> allPSTowerP = new List<IntVector2>();//需要播放升级动画的 |
| | | // if (m_CurrentArea != null && m_CurrentTower.controller.gridPosition.y >= 2) |
| | | // { |
| | | // //修改为只要开启格子都可以放 |
| | | // (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_CurrentTower.controller.gridPosition.x, m_CurrentTower.controller.gridPosition.y, false, ""); |
| | | // //(m_CurrentArea as TowerPlacementGridEndless).PlayPS(allPSTowerP); |
| | | // } |
| | | return; |
| | | List<IntVector2> allTowerP = null;//排除不能合成的 |
| | | // List<IntVector2> allPSTowerP = new List<IntVector2>();//需要播放升级动画的 |
| | | |
| | | for (int i = 0; i < m_listTower.Count; i++) |
| | | if (towerToMove) |
| | | { |
| | | if (m_listTower[i].bInAttackMode && towerToMove && m_listTower[i].currentLevel == dragTowerLevel && m_listTower[i].towerName == towerToMove.towerName) |
| | | if (towerToMove.gridPosition.y == 0 || towerToMove.gridPosition.y == 1) |
| | | { |
| | | if (towerToMove.gridPosition != m_listTower[i].gridPosition) |
| | | //说明可以合成 |
| | | allPSTowerP.Add(m_listTower[i].gridPosition); |
| | | allTowerP = 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); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //把不符合条件的传进去 |
| | | allTowerP.Add(m_listTower[i].gridPosition); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (m_CurrentArea != null) |
| | | { |
| | | //修改为只要开启格子都可以放 |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckAllCanPlace(allTowerP); |
| | | (m_CurrentArea as TowerPlacementGridEndless).PlayPS(allPSTowerP); |
| | | //(m_CurrentArea as TowerPlacementGridEndless).PlayPS(allPSTowerP); |
| | | } |
| | | |
| | | |
| | | } |
| | | else if (m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Fire || m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Bomb) |
| | |
| | | } |
| | | } |
| | | |
| | | Tower checkTowerPlaceTower;//移动时候查看鼠标是否检测到有塔 |
| | | Tower bInAttackModeTower;//在合成区的塔 |
| | | /// <summary> |
| | | /// 检查符合条件的塔 |
| | | /// </summary> |
| | |
| | | //return; |
| | | if (m_CurrentArea != null && m_CurrentArea is TowerPlacementGridEndless) |
| | | { |
| | | checkTowerPlaceTower = isFreeAttackGridOnDrag(pointerInfo); |
| | | //下面是为了设置一个虚拟的塔 |
| | | if (isFreeAttackGridOnDrag(pointerInfo) && m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | if (checkTowerPlaceTower != null) |
| | | { |
| | | //Debug.Log("得到了一个空的塔位"); |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | if (checkTowerPlaceTower.bInAttackMode) |
| | | { |
| | | //鼠标检测到了塔 |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, false, ""); |
| | | } |
| | | else |
| | | { |
| | | if (!towerToMove.bInAttackMode) |
| | | { |
| | | //没有上阵 |
| | | if (bInAttackModeTower == null) |
| | | { |
| | | bInAttackModeTower = checkTowerPlaceTower; |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(true); |
| | | } |
| | | else if (bInAttackModeTower != checkTowerPlaceTower) |
| | | { |
| | | |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, false, ""); |
| | | //if(temporaryMat) |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(false); |
| | | bInAttackModeTower = checkTowerPlaceTower; |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | 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); |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | //空格子 |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, true, towerToMove.towerName); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | (m_CurrentArea as TowerPlacementGridEndless).CloseCanPlace(); |
| | | CloseCanPlace(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | (m_CurrentArea as TowerPlacementGridEndless).CloseCanPlace(); |
| | | CloseCanPlace(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //Debug.Log("什么情况"); |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | dragTowerPlacement.CloseCanPlace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void CloseCanPlace() |
| | | { |
| | | dragTowerPlacement.CloseCanPlace(); |
| | | if (bInAttackModeTower != null) |
| | | { |
| | | bInAttackModeTower.currentTowerLevel.SetCanPlace(false); |
| | | bInAttackModeTower = null; |
| | | } |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | /// <param name="pinfo"></param> |
| | | /// <returns></returns> |
| | | protected bool isFreeAttackGridOnDrag(PointerInfo pinfo) |
| | | protected Tower 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) |
| | | |
| | | // if (towerToMove && sTower.currentLevel == dragTowerLevel && sTower.towerName == towerToMove.towerName) |
| | | // { |
| | | // //说明可以合成 |
| | | // return sTower; |
| | | // } |
| | | // else |
| | | // { |
| | | // return null; |
| | | // } |
| | | |
| | | if (towerToMove) |
| | | { |
| | | //说明可以合成 |
| | | return true; |
| | | if (towerToMove.bInAttackMode) |
| | | { |
| | | return sTower; |
| | | } |
| | | else |
| | | { |
| | | if (sTower.currentLevel == dragTowerLevel && sTower.towerName == towerToMove.towerName) |
| | | { |
| | | //说明可以合成 |
| | | return sTower; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | return null; |
| | | } |
| | | } |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | #endregion |
| | |
| | | |
| | | // 判断目标位置是否有Tower且类型和等级一致,如果没有,则GhostTower删除,原Tower显示。 |
| | | if (isValidateCombineTarget(pointerInfo)) |
| | | { |
| | | TryPlaceTower(pointerInfo); |
| | | EndlessRandomTower.instance.UpdateDescDisplay(); |
| | | } |
| | | else if (isFreeAttackGrid(pointerInfo) && !bSkill) |
| | | { |
| | | if (!TryPlaceTower(pointerInfo, false, true)) |
| | | { |
| | | CancelPlaceTower(pointerInfo); |
| | | |
| | | CancelPlaceTower(pointerInfo); |
| | | Debug.Log("这里需要返回原位"); |
| | | return; |
| | | } |
| | |
| | | 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) |
| | | if (m_CurrentArea == null) |
| | | { |
| | | delTower(towerToMove); |
| | | CancelGhostPlacement(); |
| | | towerToMove.showTower(true); |
| | | towerToMove.Sell(); |
| | | towerToMove = null; |
| | | } |
| | | else |
| | | { |
| | | Tower newTower1 = PlaceTowerForce(EndlessRandomTower.instance.getTowerByName(sTower.towerName), v1, sTower.currentLevel + 1, false); |
| | | Tower newTower2 = PlaceTowerForce(m_CurrentTower.controller, v2, towerToMove.currentLevel + 1, false); |
| | | |
| | | delTower(sTower); |
| | | sTower.showTower(true); |
| | | sTower.Sell(); |
| | | sTower = null; |
| | | if (towerToMove != null) |
| | | { |
| | | delTower(towerToMove); |
| | | towerToMove.showTower(true); |
| | | towerToMove.Sell(); |
| | | towerToMove = null; |
| | | } |
| | | |
| | | CancelGhostPlacement(); |
| | | delTower(sTower); |
| | | sTower.showTower(true); |
| | | sTower.Sell(); |
| | | sTower = null; |
| | | |
| | | newTower1.placementArea.Occupy(newTower1.gridPosition, newTower1.dimensions); |
| | | newTower2.placementArea.Occupy(newTower2.gridPosition, newTower2.dimensions); |
| | | CancelGhostPlacement(); |
| | | |
| | | newTower1.placementArea.Occupy(newTower1.gridPosition, newTower1.dimensions); |
| | | newTower2.placementArea.Occupy(newTower2.gridPosition, newTower2.dimensions); |
| | | |
| | | //强制交换塔的时候检查自身充能条 |
| | | newTower1.CheckCtrl(); |
| | | newTower2.CheckCtrl(); |
| | | } |
| | | } |
| | | } |
| | | // 当前是Skill塔位的状态. |
| | |
| | | |
| | | if (playEffect) |
| | | PlayUpgradeEffect(createdTower); |
| | | |
| | | addTower(createdTower); |
| | | Destroy(currentTower.gameObject); |
| | | |
| | |
| | | if (towerToMove) |
| | | { |
| | | towerToMove.showTower(true); |
| | | towerToMove.CheckCtrl(); |
| | | |
| | | // 处理复制骰子: |
| | | if (towerToMove.towerFeature == EFeatureTower.CopyCat) |
| | |
| | | return false; |
| | | } |
| | | |
| | | BuyTower(pointer, force, zeroCost); |
| | | |
| | | return true; |
| | | return BuyTower(pointer, force, zeroCost); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// Throws exception when not in a build mode or when tower is not a valid position |
| | | /// </exception> |
| | | /// </summary> |
| | | public void BuyTower(UIPointer pointer, bool force = false, bool zeroCost = false) |
| | | public bool BuyTower(UIPointer pointer, bool force = false, bool zeroCost = false) |
| | | { |
| | | if (!isBuilding) return; |
| | | if (!isBuilding) return false; |
| | | |
| | | // 判断是否格子上重复放置塔防 |
| | | if (!m_CurrentTower || !IsGhostAtValidPosition()) |
| | |
| | | if (!pointer.raycast.HasValue || pointer.raycast.Value.collider == null) |
| | | { |
| | | CancelGhostPlacement(); |
| | | return; |
| | | return false; |
| | | } |
| | | PlaceGhost(pointer); |
| | | } |
| | | return; |
| | | return true; |
| | | } |
| | | |
| | | // 这是判断是否超出了格子 |
| | |
| | | if (!pointer.raycast.HasValue || pointer.raycast.Value.collider == null) |
| | | { |
| | | CancelGhostPlacement(); |
| | | return; |
| | | return false; |
| | | } |
| | | |
| | | int cost = m_CurrentTower.controller.purchaseCost; |
| | |
| | | { |
| | | PlaceGhost(pointer); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | 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> |
| | |
| | | Destroy(obj, ps.main.duration); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 播放升级特效 |
| | | /// </summary> |
| | | /// <param name="worldPos"></param> |
| | | public void GuidePlayUpgradeEffect(Vector3 position) |
| | | { |
| | | GameObject effect = TowerUpgradeEffectPrefab; |
| | | |
| | | // 在sTower的位置播放升级特效 |
| | | GameObject obj = Instantiate(effect); |
| | | GameObject obj = Instantiate(TowerUpgradeEffectPrefabGuide); |
| | | obj.transform.position = position; |
| | | |
| | | Vector3 pos = obj.transform.position; |
| | | pos.y += 5f; |
| | | obj.transform.position = pos; |
| | |
| | | |
| | | if (ps == null) |
| | | ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | |
| | | ps.Play(); |
| | | Destroy(obj, ps.main.duration); |
| | | } |
| | |
| | | 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(); |
| | | } |
| | | |
| | | // 无法支付新的塔防价格,按钮变灰. |
| | |
| | | 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) |
| | | { |
| | |
| | | /// <param name="val"></param> |
| | | public void generateBloodText(Vector3 wpos, float val, bool crit = false, bool doubleHit = false, bool poison = false) |
| | | { |
| | | if (Mathf.FloorToInt(val) == 0) return; |
| | | |
| | | Vector3 spos = m_Camera.WorldToScreenPoint(wpos); |
| | | TextMoveDoTween tm; |
| | | if (crit) |
| | |
| | | bool successfulPurchase = EndlessLevelManager.instance.Currency.TryPurchase(cost); |
| | | if (!successfulPurchase) return false; |
| | | |
| | | EndlessRandomTower.instance.UpdateDescDisplay(); |
| | | SetUpGhostTower(tow); |
| | | //Debug.Log("设置影子塔防."); |
| | | m_CurrentTower.Show(); |
| | |
| | | base.Awake(); |
| | | |
| | | randomTowerBtn = transform.Find("BottomCanvas/Panel/TowerBuyBtn").GetComponent<Button>(); |
| | | DOTween.Init(true, true, LogBehaviour.Verbose).SetCapacity(200, 10); |
| | | //DOTween.Init(true, true, LogBehaviour.Verbose).SetCapacity(200, 10); |
| | | |
| | | state = State.Normal; |
| | | m_Camera = GameObject.Find("SceneCamera3D").GetComponent<Camera>(); |
| | |
| | | } |
| | | //selEff.SetWaveLineSel(true); |
| | | } |
| | | else |
| | | { |
| | | if (currentEffect != null) |
| | | { |
| | | currentEffect.SetParticleSystem(false); |
| | | currentEffect = null; |
| | | } |
| | | } |
| | | } |
| | | // 炸弹是区域攻击显示: |
| | | else if (m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Bomb) |