The "HexagonMatrix" object is a hexagonal matrix, where x, y and z are the coordinates of the cells. If we talk about the matrix in more detail, then at least 1 value of x, y or z must be equal to or less than the value 0;
How the matrix works:
-
To determine the coordinates, we use 3 parameters x, y and z. Also, we have a Radius that is equal to the maximum value of x, y and z;
-
In the usual representation, the hexagon matrix looks like this:
-
For convenient storage, we need to divide it into 7 sectors:
-
As a result, we get 3 square matrices, 3 arrays and an object in the center, the coordinates of which will be x <= 0; y <= 0; z <= 0;
-
These examples show how to take data from a hexagonal matrix:
-
Getting data from a square matrix
obj.Get(2, 3, 0);
obj.GetXY(2, 3);
//this function call will not be an error
obj.Get(2, 3, -1);
Also works with "Set" methods. 8) Getting data from an array
obj.Get(0, 0, 3);
obj.GetZ(3);
//this function call will not be an error
obj.Get(-2, -1, 3);
Also works with "Set" methods. 9) Getting the central data
obj.Get(0, 0, 0);
obj.GetCenter();
//this function call will not be an error
obj.Get(-2, 0, -1);
Also works with "Set" methods.
11) The example uses Radius 4.
12) If x, y and z all have values greater than 0 or greater than the "Radius" value, then the "Get" method will return "null", and the "Set" method will return "false".