| | |
| | | public void delTower(Tower t) |
| | | { |
| | | // 删除Tower之前去掉充能条数据. |
| | | if( t.bInAttackMode) |
| | | if (t.bInAttackMode) |
| | | t.DisableTowerUICtrl(); |
| | | |
| | | // 删除Tower有可能对应的Timer. |
| | |
| | | towerOld.showTower(false); |
| | | towerToMove = towerOld; |
| | | |
| | | if( towerOld.bInAttackMode) |
| | | if (towerOld.bInAttackMode) |
| | | { |
| | | int pro = towerOld.GetTowerUICtrlProgress(); |
| | | uiCtlProgresss = pro; |
| | |
| | | if (tw != null) |
| | | { |
| | | LevelManager.instance.startWaveLine(m_GridPosition.x, false, tw.attributeId); |
| | | |
| | | |
| | | // 顺便设置界面的进展 |
| | | if (uiCtlProgresss > 0) |
| | | { |
| | |
| | | //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"); |
| | |
| | | |
| | | CancelGhostPlacement(); |
| | | |
| | | PlayAppearEffect(createdTower.transform.position); |
| | | if (!opponent) |
| | | { |
| | | if (!isUpgrade) |
| | | PlayAppearEffect(createdTower.transform.position); |
| | | else |
| | | PlayUpgradeEffect(createdTower); |
| | | } |
| | | |
| | | // 处理成长骰子,复制骰子等等功能. |
| | | if (lvl == 0) |
| | |
| | | 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); |
| | | } |
| | |
| | | /// <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) |
| | |
| | | /// 直接在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); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (ps == null) |
| | | ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | |
| | | |
| | | ps.Play(); |
| | | Destroy(obj, ps.main.duration); |
| | | } |