Exemplo n.º 1
0
        public void DoStuff()
        {
            var go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;

            g.root           = go.transform;      // set the root so the scan will turn it into nodes
            g.maxDistance    = maxDistance.Value; // set max distance for connection
            g.initialPenalty = (uint)cost.Value;
            g.name           = name.Value;
            AstarPathExtensions.ScanGraph(g);              // turn the gameObjects into ndoes.

            Nodes.Value = FsmConverter.SetNodes(FsmConverter.NodeListToArray(g.nodes));
            AstarPath.active.FloodFill();
            return;
        }
Exemplo n.º 2
0
        public void DoStuff()
        {
            var a = g.CreateNodes(number.Value);

            nodes.Value = new FsmNodes();

            (nodes.Value as FsmNodes).Value = (List <Node>)FsmConverter.NodeListToArray(a);

            //	g.nodes += a;

            //	AstarPath.active.NodeCountChanged() ;

            AstarPathExtensions.ScanGraph(g);
        }
        public void DoStuff()
        {
            var go = graph.Value as FsmNavGraph;

            if (go.Value == null)
            {
                Finish();
                return;
            }

            g = FsmConverter.GetNavGraph(graph);

            guid.Value           = g.guid.ToString();
            drawGizmos.Value     = g.drawGizmos;
            infoScreenOpen.Value = g.infoScreenOpen;
            initialPenalty.Value = (int)g.initialPenalty;
            name.Value           = g.name;

            nodes.Value = FsmConverter.SetNodes(FsmConverter.NodeListToArray(g.nodes)) as FsmNodes;              // everywhere else it's saved as a generic list, only here it is an array, so it needs extra conversion
            open.Value  = g.open;

            if (graphType == GraphType.pointGraph && g as PointGraph != null)
            {
                autoLinkNodes.Value      = (g as PointGraph).autoLinkNodes;
                limits.Value             = (g as PointGraph).limits;
                mask.Value               = (g as PointGraph).mask;
                maxDistance.Value        = (g as PointGraph).maxDistance;
                raycast.Value            = (g as PointGraph).raycast;
                recursive.Value          = (g as PointGraph).recursive;
                root.Value               = (g as PointGraph).root.gameObject;
                searchTag.Value          = (g as PointGraph).searchTag;
                thickRaycast.Value       = (g as PointGraph).thickRaycast;
                thickRaycastRadius.Value = (g as PointGraph).thickRaycastRadius;
            }

            if (graphType == GraphType.gridGraph && g as GridGraph != null)
            {
                getNearestForceOverlap.Value = (g as GridGraph).getNearestForceOverlap;
                scans.Value = (g as GridGraph).scans;
                size.Value  = (g as GridGraph).size;
            }
        }
Exemplo n.º 4
0
        public void DoStuff()
        {
            var doo = ((node as FsmObject).Value as FsmNode).Value as Node;

            nodeIndex.Value  = doo.GetNodeIndex();
            penalty.Value    = (int)doo.penalty;
            area.Value       = doo.area;
            tags.Value       = doo.tags;
            walkable.Value   = doo.walkable;
            graphIndex.Value = doo.graphIndex;
            position.Value   = new Vector3(doo.position.x, doo.position.y, doo.position.z);
            position.Value  *= Int3.PrecisionFactor;

            if (!connectedNodes.IsNone)
            {
                (connectedNodes.Value as FsmNodes).Value = (List <Node>)FsmConverter.NodeListToArray(doo.connections);
            }

            var loo = new FsmNavGraph();

            loo.Value   = AstarPath.active.graphs[doo.graphIndex];
            graph.Value = loo;
        }
        public void DoStuff()
        {
            var go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;

            g.root           = go.transform; // set the root so the scan will turn it into nodes
            g.maxDistance    = -1;           // no autoconnect
            g.initialPenalty = (uint)cost.Value;
            g.name           = name.Value;
            AstarPathExtensions.ScanGraph(g);              // turn the gameObjects into ndoes.

            if (width.Value <= 1)
            {
                for (var i = 1; i < g.nodes.Length; i++)
                {
                    // connect the node with the previously created node
                    g.nodes[i].AddConnection(g.nodes[i - 1], cost.Value);
                    g.nodes[i - 1].AddConnection(g.nodes[i], cost.Value);
                }

                if (connectStart.Value || connectEnd.Value)
                {
                    // You would want to use an NNConstraint to ignore this graph when searching (graphMask)
                    // Since it currently will find g.nodes[0] when searching
                    nnc = NNConstraint.Default;
                    var nncSave = nnc.graphMask;
                    var index   = AstarPath.active.astarData.GetGraphIndex(g);
                    nnc.graphMask = ~(1 << index);

                    if (connectStart.Value)
                    {
                        connectEm(0);
                    }
                    if (connectEnd.Value)
                    {
                        connectEm(g.nodes.Length - 1);
                    }
                    nnc.graphMask = nncSave;
                }
            }
            else
            {
                for (var i = 0; i < g.nodes.Length; i++)
                {
                    // connect the node with the previously created node
                    //g.nodes[i].AddConnection(g.nodes[i-1], cost.Value);
                    //g.nodes[i-1].AddConnection(g.nodes[i], cost.Value);
                    //if(i + width.Value <= g.nodes.Length)
                    //{
                    //connect the node with the next node in line
                    //g.nodes[i-1].AddConnection(g.nodes[i-1+width.Value], cost.Value);
                    //g.nodes[i-1+width.Value].AddConnection(g.nodes[i-1], cost.Value);
                    //}

                    // there are 3 scenarios: Either a node is in the middle or at either of the ends of the row.
                    if (i % width.Value == width.Value - 1)                     //2
                    {
                        if (i + width.Value < g.nodes.Length)
                        {
                            g.nodes[i].AddConnection(g.nodes[i + width.Value], cost.Value);
                            g.nodes[i + width.Value].AddConnection(g.nodes[i], cost.Value);
                        }

                        if (i + width.Value - 1 < g.nodes.Length)
                        {
                            g.nodes[i].AddConnection(g.nodes[i + width.Value - 1], cost.Value);
                            g.nodes[i + width.Value - 1].AddConnection(g.nodes[i], cost.Value);
                        }
                    }
                    else if (i == 0 || 0 == i % width.Value)                 //1 // if i is 0 or a multiple of width
                    {
                        if (i + width.Value < g.nodes.Length)
                        {
                            g.nodes[i].AddConnection(g.nodes[i + width.Value], cost.Value);
                            g.nodes[i + width.Value].AddConnection(g.nodes[i], cost.Value);
                        }
                        if (i + 1 < g.nodes.Length)
                        {
                            g.nodes[i].AddConnection(g.nodes[i + 1], cost.Value);
                            g.nodes[i + 1].AddConnection(g.nodes[i], cost.Value);
                        }
                        if (i + width.Value + 1 < g.nodes.Length)
                        {
                            g.nodes[i].AddConnection(g.nodes[i + width.Value + 1], cost.Value);
                            g.nodes[i + width.Value + 1].AddConnection(g.nodes[i], cost.Value);
                        }
                    }
                    else                     //3
                    {
                        if (i + width.Value < g.nodes.Length)
                        {
                            g.nodes[i].AddConnection(g.nodes[i + width.Value], cost.Value);
                            g.nodes[i + width.Value].AddConnection(g.nodes[i], cost.Value);
                        }

                        if (i + 1 < g.nodes.Length)
                        {
                            g.nodes[i].AddConnection(g.nodes[i + 1], cost.Value);
                            g.nodes[i + 1].AddConnection(g.nodes[i], cost.Value);
                        }

                        if (i + width.Value + 1 < g.nodes.Length)
                        {
                            g.nodes[i].AddConnection(g.nodes[i + width.Value + 1], cost.Value);
                            g.nodes[i + width.Value + 1].AddConnection(g.nodes[i], cost.Value);
                        }

                        if (i + width.Value - 1 < g.nodes.Length)
                        {
                            g.nodes[i].AddConnection(g.nodes[i + width.Value - 1], cost.Value);
                            g.nodes[i + width.Value - 1].AddConnection(g.nodes[i], cost.Value);
                        }
                    }
                }

                if (connectStart.Value || connectEnd.Value)
                {
                    // You would want to use an NNConstraint to ignore this graph when searching (graphMask)
                    // Since it currently will find g.nodes[0] when searching
                    nnc = NNConstraint.Default;
                    var nncSave = nnc.graphMask;
                    var index   = AstarPath.active.astarData.GetGraphIndex(g);
                    nnc.graphMask = ~(1 << index);

                    if (connectStart.Value)
                    {
                        connectEm(0);
                    }
                    if (connectEnd.Value)
                    {
                        connectEm(g.nodes.Length - width.Value);
                    }

                    nnc.graphMask = nncSave;
                }
            }

            Nodes.Value = FsmConverter.SetNodes(FsmConverter.NodeListToArray(g.nodes));

            //Required since the graph connections have been updated
            AstarPath.active.FloodFill();

            //g.AddChildren(Count, go.transform);
            return;
        }