-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell.cs
More file actions
109 lines (89 loc) · 3.57 KB
/
Copy pathCell.cs
File metadata and controls
109 lines (89 loc) · 3.57 KB
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
using System.Diagnostics;
namespace finalProjectJA_2025
{
public enum Roles
{
Empty,
Wall,
Begining,
End,
Path
};
internal class Cell
{
Dictionary<string, Color> borderColor = new Dictionary<string, Color>();
Dictionary<string, Color> roleColor = new Dictionary<string, Color>();
Size[] neighbors = new Size[4];
int distanceFromStart = -1;
int distanceFromEnd = -1;
int totalDistance = -1;
Rectangle rectangle;
Size parent;
Roles role;
public Cell()
{
SetColor(); //Debug.Write(" :" + + "\n");
Parent = new Size(-1, -1);
Rectangle = new Rectangle(0, 0, 50, 50);
Neighbors[0] = new Size(-1, -1);//left
Neighbors[1] = new Size(-1, -1);//right
Neighbors[2] = new Size(-1, -1);//top
Neighbors[3] = new Size(-1, -1);//bottom
}
public Cell(Size newParent, Rectangle newRectangle)
{
SetColor();
Parent = newParent;
Neighbors[0] = new Size(-1, -1);
Neighbors[1] = new Size(-1, -1);
Neighbors[2] = new Size(-1, -1);
Neighbors[3] = new Size(-1, -1);
this.rectangle = newRectangle;
}
public Cell(int newParentX, int newParentY, Rectangle newRectangle)
{
Parent = new Size(newParentX, newParentY);
this.rectangle = newRectangle;
SetColor();
}
private void SetColor()
{
RoleColor.Add(Roles.Empty.ToString(), Color.White);
RoleColor.Add(Roles.Wall.ToString(), Color.DarkGray);
RoleColor.Add(Roles.Begining.ToString(), Color.DarkRed);
RoleColor.Add(Roles.End.ToString(), Color.DarkBlue);
RoleColor.Add(Roles.Path.ToString(), Color.Firebrick);
BorderColor.Add(Roles.Empty.ToString(), Color.Black);
BorderColor.Add(Roles.Wall.ToString(), Color.Black);
BorderColor.Add(Roles.Begining.ToString(), Color.Black);
BorderColor.Add(Roles.End.ToString(), Color.Black);
BorderColor.Add(Roles.Path.ToString(), Color.Black);
}
public Color GetRoleColor(string name)
{
if(!RoleColor.ContainsKey(name))
{
return Color.White;
}
return RoleColor[name];
}
public Point[] NeighborsToPoint()
{
Point[] toReturn = new Point[4];
for(int i = 0; i < Neighbors.Length;i++)
{
toReturn[i] = (Point)Neighbors[i];
}
return toReturn;
}
public Dictionary<string, Color> BorderColor { get => borderColor; set => borderColor = value; }
public Dictionary<string, Color> RoleColor { get => roleColor; set => roleColor = value; }
public int DistanceFromStart { get => distanceFromStart; set => distanceFromStart = value; }
public int DistanceFromEnd { get => distanceFromEnd; set => distanceFromEnd = value; }
public int TotalDistance { get => totalDistance; set => totalDistance = value; }
public Rectangle Rectangle { get => rectangle; set => rectangle = value; }
public Size[] Neighbors { get => neighbors; set => neighbors = value; }
public Size Parent { get => parent; set => parent = value; }
public Roles Role { get => role; set => role = value; }
}
}