private void Awake() { _requestManager = GetComponent <PathRequestManager>(); _grid = GetComponent <Grid>(); switch (_pathType) { case PathType.AStar: _pathAlgorithm = new AStar(_grid); break; case PathType.ATethaStar: _pathAlgorithm = new ATethaStar(_grid); break; } }
public void LoadAlgorithm() { switch (algorithmType) { case PathAlgorithm.SingleBezier: pathAlgorithm = new SingleBezierAlgorithm(true, Points); break; case PathAlgorithm.BezierSplines: pathAlgorithm = new BezierSplinesAlgorithm(true, Points); break; case PathAlgorithm.SingleBezierUnclamped: pathAlgorithm = new SingleBezierAlgorithm(false, Points); break; case PathAlgorithm.BezierSplinesUnclamped: pathAlgorithm = new BezierSplinesAlgorithm(false, Points); break; default: throw new NotImplementedException($"Algorithm {algorithmType} is not implemented yet."); } }
public PathController(IMapRepository mapRepository, IPathAlgorithm pathAlgorithm) { _mapRepository = mapRepository; _pathAlgorithm = pathAlgorithm; }
private void btnRun_Click(object sender, EventArgs e) { if (cboAlgo.SelectedIndex > -1) { switch (cboAlgo.SelectedItem.ToString()) { case "A*": if (activeUc is UserControls.AStarUC && (activeUc as UserControls.AStarUC).FormValid) { AStarPathAlgorithm aStar = new AStarPathAlgorithm(cellGrid, start, goal); aStar.H = (activeUc as UserControls.AStarUC).Heuristic; PathAlgorithm = aStar; this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("Missing data"); } break; case "Weighted A*": if (activeUc is UserControls.WeightedAStarUC && (activeUc as UserControls.WeightedAStarUC).FormValid) { decimal w = (activeUc as UserControls.WeightedAStarUC).Weight; WeightedAStarPathAlgorithm waStar = new WeightedAStarPathAlgorithm(cellGrid, start, goal, w); waStar.H = (activeUc as UserControls.WeightedAStarUC).Heuristic; PathAlgorithm = waStar; this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("Missing data"); } break; case "Uniform Cost": UniformCostSearchPathAlgorithm ucs = new UniformCostSearchPathAlgorithm(cellGrid, start, goal); PathAlgorithm = ucs; this.DialogResult = DialogResult.OK; this.Close(); break; case "Sequential A*": if (activeUc is UserControls.SequentialAStarUC && (activeUc as UserControls.SequentialAStarUC).FormValid) { UserControls.SequentialAStarUC ucseq = activeUc as UserControls.SequentialAStarUC; Delegates.HDelegate anchor = ucseq.AnchorHeuristic; List <Delegates.HDelegate> h = ucseq.AdditionalHeuristics; h.Insert(0, anchor); decimal w1 = ucseq.Weight1; decimal w2 = ucseq.Weight2; AStarSequentialHeuristic astarseq = new AStarSequentialHeuristic(cellGrid, start, goal, h.Count, w1, w2); astarseq.Heuristics = h.ToArray(); PathAlgorithm = astarseq; this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("Missing data"); } break; case "Integrated A*": if (activeUc is UserControls.SequentialAStarUC && (activeUc as UserControls.SequentialAStarUC).FormValid) { UserControls.SequentialAStarUC ucseq = activeUc as UserControls.SequentialAStarUC; Delegates.HDelegate anchor = ucseq.AnchorHeuristic; List <Delegates.HDelegate> h = ucseq.AdditionalHeuristics; h.Insert(0, anchor); decimal w1 = ucseq.Weight1; decimal w2 = ucseq.Weight2; AStarIntegratedAlgorithm astarin = new AStarIntegratedAlgorithm(cellGrid, start, goal, h.Count, w1, w2); astarin.Heuristics = h.ToArray(); PathAlgorithm = astarin; this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("Missing data"); } break; default: MessageBox.Show("Invalid selection"); break; } } }