示例#1
0
    /// <summary>
    /// Recursivly follows the drawpath instructions in order to render the tiles
    /// </summary>
    /// <param name="dpi"></param>
    /// <param name="oldPosition"></param>
    /// <param name="oldNode"></param>
    private void HandleDPI(DrawPathInstruction dpi, Vector2Int oldPosition, Node oldNode, bool grayout)
    {
        //If our map does not have a node in the instruction dir, we cannot render in that dir
        //if (oldNode.GetConnectionFromDir(dpi.dir) == null) {
        if (oldNode[(int)dpi.dir] < 0)                  // if this does not point to a node
        {
            return;
        }

        Vector2Int position = oldPosition + dpi.dir.offset();
        RenderTile tile     = renderLayers[dpi.dir.renderLayer()][position.x, position.y];

        grayout = grayout || GameManager.gameplay.map.disjoint(oldNode, dpi.dir);               // gray-out if disjoint, or previos node was grayed-out
        Node node = GameManager.gameplay.map[oldNode[(int)dpi.dir]];

        //Draw the node, regarless of if it is null (null node is handled by the drawer)
        tile.DrawFullNode(node, dpi.dir, position, grayout);
        //If the node is not null, then we continue on with the instructions
        if (node != null)
        {
            //Add it to the list of drawn nodes
            if (visibleNodes.Contains(node) == false)
            {
                visibleNodes.Add(node);
            }
            //Follow instructions on the next node
            foreach (DrawPathInstruction nDpi in dpi.nextInstructions)
            {
                HandleDPI(nDpi, position, node, grayout);
            }
        }
    }
示例#2
0
    private void HandleDPI(DrawPathInstruction dpi, Vector2Int oldPosition, Node oldNode)
    {
        //If our map does not have a node in the instruction dir, we cannot render in that dir
        if (oldNode.GetConnectionFromDir(dpi.dir) == null)
        {
            return;
        }

        Vector2Int position = oldPosition + dpi.dir.offset();
        RenderTile tile     = renderLayers[dpi.dir.renderLayer()][position.x, position.y];
        Node       node     = GameManager.instance.map[(int)oldNode.GetConnectionFromDir(dpi.dir)];

        //Draw the node, regarless of if it is null (null node is handled by the drawer)
        tile.DrawFullNode(node);
        //If the node is not null, then we continue on with the instructions
        if (node != null)
        {
            //Add it to the list of drawn nodes
            if (visibleNodes.Contains(node) == false)
            {
                visibleNodes.Add(node);
            }
            //Follow instructions on the next node
            foreach (DrawPathInstruction nDpi in dpi.nextInstructions)
            {
                HandleDPI(nDpi, position, node);
            }
        }
    }