Beispiel #1
0
    private void print_diamond(GameNode SW_corner)
    {
        string   diamond_output = "";
        GameNode curr_node      = SW_corner;

        while (curr_node.north_node != null)
        {
            diamond_output += "N" + curr_node.GetID();
            curr_node       = curr_node.north_node;
        }
        while (curr_node.east_node != null)
        {
            diamond_output += "E" + curr_node.GetID();
            curr_node       = curr_node.east_node;
        }
        while (curr_node.south_node != null)
        {
            diamond_output += "S" + curr_node.GetID();
            curr_node       = curr_node.south_node;
        }
        while (curr_node.west_node != null)
        {
            diamond_output += "W" + curr_node.GetID();
            curr_node       = curr_node.west_node;
        }

        Debug.Log(diamond_output);
    }
Beispiel #2
0
    private void diamond_rec(GameNode east, GameNode north, int side_length)
    {
        int end_len = (side_length * 2) - 2;



        if (end_len == east.GetID() && end_len == north.GetID())
        {
            GameNode end_node = new GameNode(east.GetID() + 1);
            east.north_node = end_node;
            north.east_node = end_node;
        }

        else if (side_length <= east.GetID() && side_length <= north.GetID())
        {
            east.north_node = new GameNode(east.GetID() + 1);
            north.east_node = new GameNode(north.GetID() + 1);
            diamond_rec(east.north_node, north.east_node, side_length);
        }

        else
        {
            east.east_node   = new GameNode(east.GetID() + 1);
            north.north_node = new GameNode(north.GetID() + 1);
            diamond_rec(east.east_node, north.north_node, side_length);
        }
    }