| | |
| | | //UpgradeSelectedTower(); |
| | | // 新的代码,合并升级为随机塔防类型. |
| | | randomUpgradeTower(); |
| | | // 在sTower的位置播放升级特效 |
| | | GameObject obj = Instantiate(TowerUpgradeEffect); |
| | | obj.transform.position = sTower.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); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | PlaceGhost(pointer); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放升级特效 |
| | | /// </summary> |
| | | /// <param name="worldPos"></param> |
| | | public void PlayUpgradeEffect(Tower newTower) |
| | | { |
| | | GameObject effect = TowerUpgradeEffect; |
| | | |
| | | 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> |
| | |
| | | /// <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 opponent = false, bool isUpgrade = false) |
| | | { |
| | | if (!isBuilding) |
| | | throw new InvalidOperationException("Trying to place tower when not in a Build Mode"); |
| | |
| | | addTower(createdTower); |
| | | |
| | | CancelGhostPlacement(); |
| | | |
| | | if (!opponent) |
| | | { |
| | | if (!isUpgrade) |
| | | PlayAppearEffect(createdTower.transform.position); |
| | | else |
| | | PlayUpgradeEffect(createdTower); |
| | | } |
| | | |
| | | PlayAppearEffect(createdTower.transform.position); |
| | | |
| | |
| | | /// 直接在IPlaceArea上随机放置一个Tower。这是随机放置塔防的入口类。这是入口的塔防类。 |
| | | /// </summary> |
| | | /// <param name="tow"></param> |
| | | public void RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0) |
| | | public void RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0, bool isUpgrade = false) |
| | | { |
| | | // 获取IPlaceArea. |
| | | if (m_CurrentArea == null) |
| | |
| | | OnSuccessBuyTower(); |
| | | SetState(State.Building); |
| | | |
| | | PlaceTower(lvl); |
| | | PlaceTower(lvl, false, isUpgrade); |
| | | } |
| | | } |
| | | |