| | |
| | | { |
| | | foreach (Tower tower in m_listTower) |
| | | { |
| | | tower.bInAttackMode = canAttack; |
| | | tower.CanAttack = canAttack; |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | else if (isFreeAttackGrid(pointerInfo) && !bSkill) |
| | | { |
| | | if (!TryPlaceTower(pointerInfo, false, true)) |
| | | if (!TryPlaceTower(pointerInfo, false)) |
| | | { |
| | | CancelPlaceTower(pointerInfo); |
| | | Debug.Log("这里需要返回原位"); |
| | |
| | | /// 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; |
| | | } |
| | | 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"); |
| | | } |
| | | 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; |
| | | |
| | |
| | | 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); |
| | |
| | | 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> |
| | |
| | | if (m_CurrentTower == null || m_CurrentArea == null) |
| | | return false; |
| | | |
| | | return EndlessLevelManager.instance.Currency.CanAfford(m_CurrentTower.controller.purchaseCost); |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | if (tm) |
| | | { |
| | | tm.GetComponent<Transform>().SetParent(GameObject.Find("MainUI").GetComponent<Transform>(), true); |
| | | tm.GetComponent<Transform>().SetParent(GameObject.Find("MainUI/TextPanel").GetComponent<Transform>(), true); |
| | | string bloodStr = ""; |
| | | if (doubleHit) |
| | | bloodStr += "Dble!"; |
| | |
| | | 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; |
| | |
| | | /// <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"; |
| | | } |
| | | string path = $"UI/DengChang_{attributeId}"; |
| | | |
| | | GameObject prefab = Resources.Load<GameObject>(path); |
| | | GameObject obj = Instantiate(prefab); |