private void DrawPath(QuadTile target) { if (target == oldTarget) { return; } oldTarget = target; List <QuadTile> path = target.Path(); Clear(PathfindingClear.Path); Arrow.gameObject.SetActive(true); Arrow.transform.position = path[path.Count - 1].PositionWithHeight; Arrow.transform.SetParent(path[path.Count - 1].transform); Arrow.UpdateSegment(path[path.Count - 1].pathFindingData.cameFrom.PositionWithHeight, Vector3.zero); for (int i = 0; i < path.Count - 1; i++) { LineSegment segment = GetLineSegmentFromPool(); segment.transform.position = path[i].PositionWithHeight; segment.transform.SetParent(path[i].transform); segment.name = "Segment " + i; segment.UpdateSegment(path[i].pathFindingData.cameFrom.PositionWithHeight, path[i + 1].PositionWithHeight); } }
public IEnumerator Move() { ShowMove(); ToggleWindow(false, false); QuadTile target = null; // Wait for click while (!target) { if (Input.GetButtonDown("Fire1")) { target = QuadTileMap.GetTarget(LayerMask.GetMask("Viable Marker")); } yield return(null); } mover.StopUpdatingPath = true; ConfirmationDialog dialog = Instantiate(dialogPrefab, transform.parent); // Wait for dialog input while (dialog.Result == DialogResult.None) { yield return(null); } if (dialog.Result == DialogResult.Yes) { Destroy(dialog.gameObject); CharacterData data = turnManager.CurrentCharacter.Data; MoveParams moveParams = moved ? data.rushParams : data.moveParams; yield return(StartCoroutine(mover.Move(turnManager.CurrentCharacter, target.Path(), moveParams, data.jumpParams))); turnManager.CurrentCharacter.LoseActionPoints(moveCost); moveCost++; if (moved) { MoveButton.interactable = false; } moved = true; } else { Destroy(dialog.gameObject); } mover.Clear(PathfindingClear.Both); ToggleWindow(true, false); }