Пример #1
0
    // Handles construction of graph. Performed once on initialization of terrain.
    public void ConstructGraph()
    {
        for (int x = 0; x < controller.GridSizeX; x++)
        {
            for (int z = 0; z < controller.GridSizeZ; z++)
            {
                GroundTileController tileController = controller.FindGroundTileControllerByXZ(x, z);
                Node node = new Node(tileController);
                nodeList[x * controller.GridSizeZ + z] = node;

                if (z > 0)
                {
                    node.southNode = nodeList[x * controller.GridSizeZ + z - 1];
                    nodeList[x * controller.GridSizeZ + z - 1].northNode = node;
                }
                if (x > 0)
                {
                    node.westNode = nodeList[(x - 1) * controller.GridSizeZ + z];
                    nodeList[(x - 1) * controller.GridSizeZ + z].eastNode = node;
                }
            }
        }
    }