Esempio n. 1
0
        private void initializeAllLightNodeNeighbors()
        {
            for (var i = 0; i < Grid.Count; i++)
            {
                List <LightNode> column = Grid[i];

                for (var j = 0; j < column.Count; j++)
                {
                    LightNode node = column[j];

                    initializeLightNodeNeighbors(node);
                }
            }
        }
Esempio n. 2
0
        private void initializeLightNodeNeighbors(LightNode node)
        {
            for (short xOffset = -1; xOffset <= 1; xOffset++)
            {
                for (short yOffset = -1; yOffset <= 1; yOffset++)
                {
                    if (Math.Abs(xOffset) == Math.Abs(yOffset))
                    {
                        continue;
                    }

                    Vec2 <short> offset   = new Vec2 <short>(xOffset, yOffset);
                    Vec2 <short> position = node.position.ConvertMemberType <short>();

                    Vec2 <short>         potentialNeighborPosition = position - offset;
                    Optional <LightNode> possibleNeighbor          = getNodeAt(potentialNeighborPosition);

                    if (possibleNeighbor.HasValue)
                    {
                        node.LateralNeighbors.Add(possibleNeighbor.Value);
                    }
                }
            }
        }