示例#1
0
    void displayVertices()
    {
        baseGraphData baseGraph = new baseGraphData();

        baseGraph.size = this.size;

        for (int i = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                GameObject vertex = Instantiate(vertexGO, new Vector3(transform.position.x + j, transform.position.y - i, 0), Quaternion.identity);
                vertex.name             = graphNo + " - " + i + "," + j;
                vertex.transform.parent = gameObject.transform;
                vertexScript vs = vertex.GetComponent <vertexScript>();
                if ((graphNo == 1) && (i == 0 || i == size - 1 || j == 0 || j == size - 1))
                {
                    if (!startingPointSet && UnityEngine.Random.Range(0f, 1f) <= 0.5f)
                    {
                        vs.setStartingPoint(true);
                        startingPointSet    = true;
                        startingPointGO     = vs.gameObject;
                        startingPoingScript = vs;
                    }
                    borderVertices.Add(vs);
                }
                vs.setName(vertexNumbering);
                vertexNumbering++;
            }
        }
    }