Пример #1
0
    public void InitializeStartingPath()
    {
        int seed = (int)(System.DateTime.Now - new System.DateTime(2017, 1, 1)).TotalSeconds;

        //int seed = 33923864;
        Random.InitState(seed);
        //Debug.Log(seed);

        PathGraph graph = FindObjectOfType <PathGraph>();

        if (graph.finishNode)
        {
            SetCoreMat(graph.finishNode.gameObject, coreMaterial);
        }
        PathGraph.RandomPath randomPath = graph.GetRandomPath(targetPathLength);
        graph.startNode  = randomPath.startNode;
        graph.finishNode = randomPath.finishNode;
        // Debug.Log("CanReachFinish: " + graph.CanReachFinish());
        // Debug.Log("pathEdges: " + randomPath.pathEdges.Count);
        foreach (PathEdge edge in graph.edges)
        {
            edge.tendril.gameObject.SetActive(true);
            edge.tendril.SetTraversable(false);
        }

        foreach (PathEdge edge in randomPath.pathEdges)
        {
            edge.tendril.SetTraversable(true);
        }

        SetCoreMat(graph.finishNode.gameObject, finishLineCoreMaterial);

        EventBus.PublishEvent(new GraphConfiguredEvent(graph));
    }