Exemple #1
0
    private void GenerateInitialNode()
    {
        Vector3 pos    = Vector3.zero;
        float   size_x = map_width;
        float   size_z = map_height;

        var node_obj = Instantiate(node, pos, node.transform.rotation);

        nodes.Add(node_obj.GetComponent <Node>());

        node_obj.GetComponent <Node>().SetDivideCount(divide_count);

        node_obj.transform.parent = node_parent.transform;

        node_obj.GetComponent <Node>().Initialise(Vector3.zero,
                                                  size_x, size_z, positions, show_nodes, max_depth, node, nodes, perlin, 0, 0,
                                                  node_parent.transform);

        Debug.Log("No of Nodes PRE CleanUp: " + nodes.Count);

        for (int i = (nodes.Count - 1); i >= 0; i--)
        {
            if (nodes[i].HasDivided())
            {
                Destroy(nodes[i].gameObject, 0.2f);
                nodes.RemoveAt(i);
                Debug.Log("Removed Node");
            }
        }

        Debug.Log("No of Nodes CleanedUp: " + nodes.Count);

        if (show_pf)
        {
            pathfinding.CreateGrid(map_width, map_height, GetSmallestNode());
        }
    }