Repository navigation
Expand file tree
/
Copy pathCellWithOrientation.cs
More file actions
68 lines (59 loc) · 1.86 KB
/
Copy pathCellWithOrientation.cs
File metadata and controls
68 lines (59 loc) · 1.86 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class CellWithOrientation
{
#region Declarations
public int Id { get; private set; }
public int Orientation { get; private set; }
public int X { get; private set; }
public int Y { get; private set; }
public short CompressedValue { get; private set; }
#endregion
#region Public method
public CellWithOrientation(int id, int x, int y)
{
X = x;
Y = y;
Id = id;
}
public void SetOrientation(CellWithOrientation nextCell)
{
if (nextCell.X == X)
{
if (nextCell.Y == Y + 1)
Orientation = 7;
else if (nextCell.Y == Y - 1)
Orientation = 3;
}
else if (nextCell.Y == Y)
{
if (nextCell.X == X + 1)
Orientation = 1;
else if (nextCell.X == X - 1)
Orientation = 5;
}
else
{
if (nextCell.X == X + 1 && nextCell.Y == Y + 1)
Orientation = 0;
else if (nextCell.X == X + 1 && nextCell.Y == Y - 1)
Orientation = 2;
else if (nextCell.X == X - 1 && nextCell.Y == Y - 1)
Orientation = 4;
else if (nextCell.X == X - 1 && nextCell.Y == Y + 1)
Orientation = 6;
}
}
public void SetOrientation(int orientation)
{
Orientation = orientation;
}
public void GetCompressedValue()
{
CompressedValue = (short)(((int)Orientation & 7) << 12 | Id & 4095);
}
#endregion
}