Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        // if the RVG is null, then we nned to define it.
        if (rvg is null)
        {
            var level = FindObjectOfType <LevelManager>();
            rvg = level.rvg;
            UnityEngine.Assertions.Assert.IsTrue(level != null, "level initialization is null");
        }

        // I will use this to set color for each agent
        if (count < colors.Length)
        {
            Renderer.color = colors[count];
        }
        else
        {
            var color = Random.ColorHSV();
            color.a        = 1;
            Renderer.color = color;
        }
        showDest = Instantiate(destPrefab);
        // new add
        var position = Helper.chooseRandomPos(shape);

        position.z = Helper.ZValueOfAgent;
        dest       = position;
        showDest.transform.position = dest;
        showDest.GetComponent <Renderer>().material.color = Renderer.color;
        count++;
        moveAlongPath();
    }
    void buildRVG()
    {
        // construct our graph
        rvg = new RVG(editorVertices);
        // show the vertices
        foreach (var node in rvg.vertices)
        {
            Instantiate(pointPrefab, node.Position, Quaternion.identity);
        }

        // show the edges
        foreach (var(a, b) in rvg.edges)
        {
            Line line = Instantiate(linePrefab);
            line.SetVertices(a.Position, b.Position);
        }
    }