/// <summary> /// Position the ghost tower at the given pointer /// </summary> /// <param name="pointerInfo">The pointer we're using to position the tower</param> /// <param name="hideWhenInvalid">Optional parameter for configuring if the ghost is hidden when in an invalid location</param> public void TryMoveGhost(PointerInfo pointerInfo, bool hideWhenInvalid = true) { if (m_CurrentTower == null) { throw new InvalidOperationException("Trying to move the tower ghost when we don't have one"); } UIPointer pointer = WrapPointer(pointerInfo); // Do nothing if we're over UI if (pointer.overUI && hideWhenInvalid) { m_CurrentTower.Hide(); return; } MoveGhost(pointer, hideWhenInvalid); }
/// <summary> /// Position the ghost tower at the given pointer /// </summary> /// <param name="pointerInfo">The pointer we're using to position the tower</param> /// <param name="hideWhenInvalid">Optional parameter for configuring if the ghost is hidden when in an invalid location</param> public void TryMoveGhost(PointerInfo info, bool hideWhenInvalid = true) { if (m_CurrentTower == null) { throw new InvalidOperationException("Trying to move the tower ghost when we don't have one"); } UIPointer pointer = WrapPointer(info); /* * LineRenderer lineRenderer = GetComponentInChildren<LineRenderer>(); * lineRenderer.SetPosition(0, pointer.ray.origin); * lineRenderer.SetPosition(1, pointer.ray.direction * 1000); */ // Do nothing if we're over UI if (pointer.overUI && hideWhenInvalid) { m_CurrentTower.Hide(); return; } MoveGhost(pointer, hideWhenInvalid); }
/// <summary> /// Creates and hides the tower and shows the buildInfoUI /// </summary> /// <exception cref="ArgumentNullException"> /// Throws exception if the <paramref name="towerToBuild"/> is null /// </exception> void SetUpGhostTower([NotNull] Tower towerToBuild) { if (towerToBuild == null) { throw new ArgumentNullException("towerToBuild"); } m_CurrentTower = Instantiate(towerToBuild.towerGhostPrefab); m_CurrentTower.Initialize(towerToBuild); m_CurrentTower.Hide(); //activate build info if (buildInfoUI != null) { buildInfoUI.Show(towerToBuild); } }