| | |
| | | public State state { get; private set; } |
| | | |
| | | /// <summary> |
| | | /// 局内塔防类型的升级数据 |
| | | /// </summary> |
| | | public List<SceneTowerLvl> sceneTowerLvlList; |
| | | |
| | | /// <summary> |
| | | /// The currently selected tower |
| | | /// </summary> |
| | | public LayerMask placementAreaMask; |
| | |
| | | SetToDragMode(newT); |
| | | |
| | | if (towerOld.towerFeature == EFeatureTower.Skill_Bomb) |
| | | m_CurrentTower.SetAttackArea(dragTowerLevel, towerOld.attributeId); |
| | | m_CurrentTower.SetAttackArea(dragTowerLevel, towerOld.ElfId); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | if (m_CurrentTower == null || !IsGhostAtValidPosition()) |
| | | { |
| | | // 最大级别的Tower不能再合并了. |
| | | if (towerToMove.isAtMaxLevel) |
| | | if (towerToMove.IsMaxLevel) |
| | | return false; |
| | | |
| | | // 判断格子上的塔防: |
| | |
| | | Tower tw = FindTowerWithGridIdx(m_GridPosition.x, m_GridPosition.y); |
| | | if (tw != null) |
| | | { |
| | | LevelManager.instance.startWaveLine(m_GridPosition.x, false, tw.attributeId); |
| | | LevelManager.instance.startWaveLine(m_GridPosition.x, false, tw.ElfId); |
| | | |
| | | // 顺便设置界面的进展 |
| | | if (uiCtlProgresss > 0) |
| | |
| | | ray = m_Camera.ScreenPointToRay(tp.currentPosition) |
| | | }; |
| | | |
| | | int sId = towerToMove.attributeId; |
| | | int sId = towerToMove.ElfId; |
| | | int sLevel = towerToMove.currentLevel; |
| | | |
| | | // 火是列攻击: |
| | |
| | | { |
| | | throw new InvalidOperationException("Selected Tower is null"); |
| | | } |
| | | if (currentSelectedTower.isAtMaxLevel) |
| | | if (currentSelectedTower.IsMaxLevel) |
| | | { |
| | | return; |
| | | } |
| | |
| | | { |
| | | throw new InvalidOperationException("Selected Tower is null"); |
| | | } |
| | | if (currentSelectedTower.isAtMaxLevel) |
| | | if (currentSelectedTower.IsMaxLevel) |
| | | return false; |
| | | |
| | | // 直接随机升级,零成本。 |
| | |
| | | |
| | | if (newTower.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | string path = $"UI/ToBattle_{newTower.attributeId}"; |
| | | string path = $"UI/ToBattle_{newTower.ElfId}"; |
| | | GameObject prefab = Resources.Load<GameObject>(path); |
| | | effect = Instantiate(prefab); |
| | | } |
| | |
| | | if (lvl == 0) |
| | | { |
| | | Tower tw = OpponentMgr.instance.getTower(tposx, tposy); |
| | | LevelManager.instance.startWaveLine(tposx, true, tw.attributeId); |
| | | LevelManager.instance.startWaveLine(tposx, true, tw.ElfId); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 战场内所有的Tower实例都需要升级相关的数据. |
| | | /// 找到相同类型的所有Tower,然后进行局内升级的修改。 |
| | | /// </summary> |
| | | /// <param name="td"></param> |
| | | protected void towerUpgradeInBattle(TowerLevelUp tlu) |
| | | { |
| | | foreach (Tower tower in m_listTower) |
| | | { |
| | | if (tlu.towerName != tower.towerName) |
| | | continue; |
| | | tower.upGradeInSceneTL(); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Reset TimeScale if game is paused |
| | | /// </summary> |
| | | protected override void OnDestroy() |
| | |
| | | Tower controller = m_CurrentTower.controller; |
| | | |
| | | Tower createdTower = Instantiate(controller); |
| | | createdTower.Initialize(m_CurrentArea, m_GridPosition); |
| | | createdTower.SetLevel(dragTowerLevel); |
| | | createdTower.Initialize(m_CurrentArea, m_GridPosition, dragTowerLevel); |
| | | |
| | | // ATTENTION TO FIX:是否应该加入List: |
| | | addTower(createdTower); |
| | | dragTowerLevel = 0; |
| | | CancelGhostPlacement(); |
| | | PlayToAttackEffect(createdTower.attributeId, createdTower.transform.position); |
| | | PlayToAttackEffect(createdTower.ElfId, createdTower.transform.position); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <summary> |
| | | /// 播放宝石上阵特效 |
| | | /// </summary> |
| | | /// <param name="attributeId">101 火,105 水,109 木</param> |
| | | /// <param name="ElfId">101 火,201 水,301 木</param> |
| | | /// <param name="worldPos">世界坐标</param> |
| | | public void PlayToAttackEffect(int attributeId, Vector3 worldPos) |
| | | public void PlayToAttackEffect(int ElfId, Vector3 worldPos) |
| | | { |
| | | string path = $"UI/ToBattle_{attributeId}"; |
| | | string path = $"UI/ToBattle_{ElfId}"; |
| | | GameObject prefab = Resources.Load<GameObject>(path); |
| | | GameObject obj = Instantiate(prefab); |
| | | obj.transform.position = worldPos; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新每一个 |
| | | /// </summary> |
| | | protected void updateSceneTowerUpgradeStatus() |
| | | { |
| | | bool zeroTower = m_listTower.Count == 0; |
| | | int tlen = sceneTowerLvlList.Count; |
| | | /* for( int ti = 0;ti<tlen;ti ++) |
| | | { |
| | | SceneTowerLvl stl = sceneTowerLvlList[ti]; |
| | | bool cashEnable = LevelManager.instance.currency.currentCurrency >= stl.upgradeCash; |
| | | if (zeroTower) |
| | | cashEnable = false; |
| | | if( cashEnable != stl.canInteract) |
| | | { |
| | | stl.enableSceneTower(cashEnable); |
| | | } |
| | | }*/ |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Modifies the valid rendering of the ghost tower once there is enough currency |
| | | /// </summary> |
| | | protected virtual void OnCurrencyChanged() |
| | |
| | | var tpMgr = TowerPrice.instance; |
| | | if (tpMgr.currentTowerPrice > LevelManager.instance.currency.currentCurrency) |
| | | disableRandomTowerBtn(); |
| | | |
| | | // 处理场景内升级相关的内容 |
| | | updateSceneTowerUpgradeStatus(); |
| | | |
| | | |
| | | if (!isBuilding || m_CurrentTower == null || m_CurrentArea == null) |
| | | { |