-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpathfindingController.cs
116 lines (78 loc) · 1.95 KB
/
pathfindingController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;
public enum pf
{
E,
A_star,
Dijkstra,
Greedy,
BFS
}
public class pathfindingController : pathfinding
{
public Button[] butt;
public GameObject panel;
private bool setPanel;
int index;
public int method
{
set { index = value; }
get { return index; }
}
// The topics that has been covered:
// delegeate method that takes fucntions as a parameter Actio,UnityAction and etc
// lambda expression ()=>
// Unity Action and Unity Event
void Start()
{
setPanel = false;
}
public void openPanel()
{
setPanel = !setPanel;
panel.SetActive(setPanel);
}
public void switcher()
{
for (int i = 0; i < butt.Length; i++)
{
func(i);
}
}
private void func(int index)
{
butt[index].onClick.AddListener( ()=> method = index+1);
}
public void selectPathfinding(int index, Vector3 start, Vector3 target)
{
switch ((pf)index)
{
case pf.E:
print("DEFAULT");
break;
case pf.A_star:
print("a star");
A_Star(start, target);
break;
case pf.Dijkstra:
print("Dijkstra");
Dijkstra(start, target);
break;
case pf.Greedy:
print("Greedy");
Greedy(start, target);
break;
case pf.BFS:
print(" BreadthFirstSearch");
BreadthFirstSearch(start, target);
break;
default:
print("CHOOSE PATHFINDING METHOD");
break;
}
}
}