| | |
| | | protected Tower towerToMove = null; |
| | | |
| | | /// <summary> |
| | | /// UI界面对应的进度 |
| | | /// </summary> |
| | | protected int uiCtlProgresss = 0; |
| | | |
| | | /// <summary> |
| | | /// 宝石升级特效 |
| | | /// </summary> |
| | | public GameObject TowerUpgradeEffect; |
| | | |
| | | /// <summary> |
| | | /// 宝石出现特效 |
| | | /// </summary> |
| | | public GameObject TowerAppearEffect; |
| | | |
| | | /// <summary> |
| | | /// Fires when the <see cref="State"/> changes |
| | | /// should only allow firing when TouchUI is used |
| | | /// </summary> |
| | |
| | | |
| | | public void delTower(Tower t) |
| | | { |
| | | // 删除Tower之前去掉充能条数据. |
| | | if( t.bInAttackMode) |
| | | t.DisableTowerUICtrl(); |
| | | |
| | | // 删除Tower有可能对应的Timer. |
| | | foreach (var tdata in towerTimeDic) |
| | | { |
| | |
| | | break; |
| | | } |
| | | |
| | | // |
| | | // 重设界面数据 |
| | | uiCtlProgresss = 0; |
| | | |
| | | // 从列表中删除Tower.并破坏Tower的外形。 |
| | | dragTowerLevel = towerOld.currentLevel; |
| | | // 尝试不再删除原来的Tower,而是尝试在合成成功后再删除原来的Tower |
| | | towerOld.showTower(false); |
| | | towerToMove = towerOld; |
| | | |
| | | if( towerOld.bInAttackMode) |
| | | { |
| | | int pro = towerOld.GetTowerUICtrlProgress(); |
| | | uiCtlProgresss = pro; |
| | | } |
| | | |
| | | // 先删除,再设置移动相关。 |
| | | SetToDragMode(newT); |
| | |
| | | // 开启相应的兵线: |
| | | Tower tw = FindTowerWithGridIdx(m_GridPosition.x, m_GridPosition.y); |
| | | if (tw != null) |
| | | { |
| | | LevelManager.instance.startWaveLine(m_GridPosition.x, false, tw.attributeId); |
| | | |
| | | // 顺便设置界面的进展 |
| | | if (uiCtlProgresss > 0) |
| | | { |
| | | tw.SetTowerUICtlProcess(uiCtlProgresss); |
| | | Debug.Log("设置当前的进度:" + uiCtlProgresss); |
| | | uiCtlProgresss = 0; |
| | | } |
| | | } |
| | | } |
| | | // 当前是Skill塔位的状态. |
| | | else if (bSkill) |
| | |
| | | //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 |
| | |
| | | |
| | | CancelGhostPlacement(); |
| | | |
| | | PlayAppearEffect(createdTower.transform.position); |
| | | |
| | | // 处理成长骰子,复制骰子等等功能. |
| | | if (lvl == 0) |
| | | { |
| | | ProcessFeatureTower(createdTower); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放宝石出现特效 |
| | | /// </summary> |
| | | public void PlayAppearEffect(Vector3 worldPos) |
| | | { |
| | | GameObject obj = Instantiate(TowerAppearEffect); |
| | | 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> |
| | |
| | | addTower(createdTower); |
| | | dragTowerLevel = 0; |
| | | CancelGhostPlacement(); |
| | | PlayToAttackEffect(createdTower.attributeId, createdTower.transform.position); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放宝石上阵特效 |
| | | /// </summary> |
| | | /// <param name="attributeId">101 火,105 水,109 木</param> |
| | | /// <param name="worldPos">世界坐标</param> |
| | | public void PlayToAttackEffect(int attributeId, Vector3 worldPos) |
| | | { |
| | | string path = $"UI/ToBattle_{attributeId}"; |
| | | 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> |
| | | /// Raycast onto tower placement areas |
| | | /// </summary> |
| | | /// <param name="pointer">The pointer we're testing</param> |