| | |
| | | /// </summary> |
| | | Camera m_Camera; |
| | | |
| | | //Camera m_CameraBG; |
| | | |
| | | |
| | | /// <summary> |
| | | /// Current tower placeholder. Will be null if not in the <see cref="State.Building" /> state. |
| | | /// </summary> |
| | |
| | | |
| | | //首次购买宝石特效 |
| | | public GameObject fireAppearEffect1; |
| | | public GameObject fireAppearEffect2; |
| | | //public GameObject fireAppearEffect2; |
| | | |
| | | public GameObject waterAppearEffect1; |
| | | public GameObject waterAppearEffect2; |
| | | //public GameObject waterAppearEffect2; |
| | | public GameObject woodAppearEffect1; |
| | | public GameObject woodAppearEffect2; |
| | | //public GameObject woodAppearEffect2; |
| | | /// <summary> |
| | | /// 保存所有生成或合成的塔的最小等级 |
| | | /// </summary> |
| | |
| | | return lt; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据塔位索引位置,查找位置上是否有对应的塔防数据。 |
| | | /// </summary> |
| | | /// <param name="x"></param> |
| | | /// <param name="y"></param> |
| | | /// <returns></returns> |
| | | public int GetTowerNum() |
| | | { |
| | | int num = 0; |
| | | foreach (Tower lt in m_listTower) |
| | | { |
| | | if (lt.gridPosition.y == 0 || lt.gridPosition.y == 1) |
| | | { |
| | | num++; |
| | | } |
| | | } |
| | | return num; |
| | | } |
| | | |
| | | public bool towerInList(Tower t) |
| | |
| | | { |
| | | return; |
| | | } |
| | | if (state == State.GameOver) |
| | | { |
| | | CommonDebugHelper.DebugError("已经游戏结束了,为什么还在修改状态"); |
| | | return; |
| | | } |
| | | CommonDebugHelper.Debug($"设置了状态 state:{state} newState:{newState} "); |
| | | |
| | | State oldState = state; |
| | | if (oldState == State.Paused || oldState == State.GameOver) |
| | | { |
| | |
| | | /// </summary> |
| | | public void GameOver() |
| | | { |
| | | CommonDebugHelper.Debug("游戏结束了"); |
| | | |
| | | SetState(State.GameOver); |
| | | } |
| | | |
| | |
| | | PlayUpgradeEffect(m_listTower[i]); |
| | | } |
| | | } |
| | | GameConfig.IsUpgradeTowerLevel = true; |
| | | UpdateMinLevelArr(); |
| | | EndlessRandomTower.instance.UpdateDescDisplay(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | else if (m_GridPosition.y == 2 || m_GridPosition.y == 3) |
| | | { |
| | | //Debug.Log("已上阵区域,如果是空格子就强行吸附,先判断是否有塔"); |
| | | |
| | | //pointerInfo.currentPosition += new Vector2(0, -25f); |
| | | checkTowerPlaceTower = isFreeAttackGridOnDrag(pointerInfo); |
| | | |
| | | if (checkTowerPlaceTower != null) |
| | | { |
| | | Debug.Log(checkTowerPlaceTower.name); |
| | | //Debug.Log(checkTowerPlaceTower.name); |
| | | //Debug.Log($"checkTowerPlaceTower.name:{checkTowerPlaceTower.name} m_GridPosition:{m_GridPosition}"); |
| | | |
| | | if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL) |
| | | { |
| | | if (checkTowerPlaceTower.bInAttackMode) |
| | | { |
| | | //Debug.Log("检测到了塔"); |
| | | //鼠标检测到了塔 |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, false, ""); |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(checkTowerPlaceTower.gridPosition.x, checkTowerPlaceTower.gridPosition.y, false, ""); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | CloseCanPlace(); |
| | | //CloseCanPlace(); |
| | | |
| | | //Debug.Log("上阵区域,没有开放的塔位"); |
| | | |
| | | (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, true, ""); |
| | | |
| | | m_CurrentTower.transform.position = (m_CurrentArea as TowerPlacementGridEndless).GridToWorld(m_GridPosition, m_CurrentTower.controller.dimensions); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (sTower == null) |
| | | return false; |
| | | |
| | | Debug.Log("开始检测是否可以交换塔"); |
| | | //Debug.Log("开始检测是否可以交换塔"); |
| | | //if (sTower.bInAttackMode == towerToMove.bInAttackMode) |
| | | { |
| | | IntVector2 v1 = new IntVector2(towerToMove.gridPosition.x, towerToMove.gridPosition.y); |
| | |
| | | return controller; |
| | | } |
| | | |
| | | private Vector2 dragOffect = new Vector2(0, -55f); |
| | | /// <summary> |
| | | /// Position the ghost tower at the given pointer |
| | | /// </summary> |
| | |
| | | return; |
| | | //throw new InvalidOperationException("Trying to move the tower ghost when we don't have one"); |
| | | } |
| | | // 我操,终于可以了!ATTENTION TO OPP: |
| | | PointerInfo tp = new PointerActionInfo(); |
| | | tp.currentPosition = pointerInfo.currentPosition + dragOffect; |
| | | tp.previousPosition = pointerInfo.previousPosition; |
| | | tp.delta = pointerInfo.delta; |
| | | tp.startedOverUI = pointerInfo.startedOverUI; |
| | | |
| | | UIPointer pointer = WrapPointer(pointerInfo); |
| | | UIPointer npt = new UIPointer |
| | | { |
| | | overUI = false, |
| | | pointer = tp, |
| | | overWaveLine = false, |
| | | ray = m_Camera.ScreenPointToRay(tp.currentPosition) |
| | | }; |
| | | |
| | | //UIPointer pointer = WrapPointer(tp); |
| | | // Do nothing if we're over UI |
| | | if (pointer.overUI && hideWhenInvalid) |
| | | if (npt.overUI && hideWhenInvalid) |
| | | { |
| | | m_CurrentTower.Hide(); |
| | | return; |
| | | } |
| | | MoveGhost(pointer, hideWhenInvalid); |
| | | MoveGhost(npt, hideWhenInvalid); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | CancelGhostPlacement(); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | PlaceGhost(pointer); |
| | | } |
| | | return true; |
| | |
| | | { |
| | | //火元素 |
| | | PlayAppearEffect(worldPos, fireAppearEffect1); |
| | | PlayAppearEffect(worldPos, fireAppearEffect2); |
| | | //PlayAppearEffect(worldPos, fireAppearEffect2); |
| | | if (Application.platform == RuntimePlatform.WindowsEditor) |
| | | { |
| | | //UnityEditor.EditorApplication.isPaused = true; |
| | |
| | | { |
| | | //木元素 |
| | | PlayAppearEffect(worldPos, woodAppearEffect1); |
| | | PlayAppearEffect(worldPos, woodAppearEffect2); |
| | | //PlayAppearEffect(worldPos, woodAppearEffect2); |
| | | |
| | | } |
| | | else if (towerName.StartsWith("CopyCatTower")) |
| | | { |
| | | //水元素 |
| | | PlayAppearEffect(worldPos, waterAppearEffect1); |
| | | PlayAppearEffect(worldPos, waterAppearEffect2); |
| | | //PlayAppearEffect(worldPos, waterAppearEffect2); |
| | | } |
| | | } |
| | | void PlayAppearEffect(Vector3 worldPos, GameObject prefab) |
| | |
| | | bool successfulPurchase = EndlessLevelManager.instance.Currency.TryPurchase(cost); |
| | | if (!successfulPurchase) return false; |
| | | |
| | | EndlessRandomTower.instance.UpdateDescDisplay(); |
| | | SetUpGhostTower(tow); |
| | | //Debug.Log("设置影子塔防."); |
| | | m_CurrentTower.Show(); |
| | |
| | | |
| | | state = State.Normal; |
| | | m_Camera = GameObject.Find("SceneCamera3D").GetComponent<Camera>(); |
| | | //m_Camera = GameObject.Find("BackCamera").GetComponent<Camera>(); |
| | | |
| | | //m_Camera = GetComponent<Camera>(); |
| | | TowerDestroyArr = new bool[5, AttackRowNumbers]; |
| | | } |
| | |
| | | // WORK START: 从这里开始,移动的时候与场景内的WaveSelEffect射线做碰撞。 |
| | | // Raycast onto placement layer |
| | | PlacementAreaRaycast(ref npt); |
| | | |
| | | //Debug.Log("npt.raycast:" + npt.raycast); |
| | | if (npt.raycast != null) |
| | | { |
| | | MoveGhostWithRaycastHit(npt.raycast.Value); |