Beispiel #1
0
        private static NodeWalkable GetPlayerStartNode(Node[] gridNodes, int gridSize)
        {
            Vector3Int playerStartNodeCoordinates = new Vector3Int(gridSize / 2, gridSize / 2, 0);
            int        playerStartNodeIndex       = WorldGridUtil.ConvertNodeCoordinatesToIndex(playerStartNodeCoordinates, gridSize);

            NodeWalkable playerStartNode = gridNodes[playerStartNodeIndex] as NodeWalkable;

            Debug.Assert(playerStartNode != null, "Invalid player start node!");

            return(playerStartNode);
        }
Beispiel #2
0
        private Node TryGetNodeAtCoordinates(Vector3Int nodeCoordinates)
        {
            Node node = default;

            if (CheckIfNodeCoordinatesAreValid(nodeCoordinates) == true)
            {
                int nodeIndex = WorldGridUtil.ConvertNodeCoordinatesToIndex(nodeCoordinates, GridSize);
                node = m_GridNodes[nodeIndex];
            }

            return(node);
        }