Example #1
0
        public static NodeMap FilterByGroup(this NodeMap @self, int group)
        {
            var groupDict = new NodeMap.GroupDict();

            NodeMap.Group(@self, out groupDict);
            var objs = groupDict.Where((obj) => obj.Value == group);
            var res  = new Dictionary <string, NodeMap.NodeData>();

            foreach (var obj in objs)
            {
                res[obj.Key] = @self.nodeMap[obj.Key];
            }

            @self.nodeMap = res;
            return(@self);
        }
Example #2
0
        /// <summary>
        /// _transform にランダムな道を歩かせる.
        /// </summary>
        /// <param name="_transform">Transform.</param>
        public void Test(Transform _transform)
        {
            nextNode         = null;
            _targetTransForm = _transform;
            var groupDict  = new NodeMap.GroupDict();
            var groupCount = NodeMap.Group(nodeMap, out groupDict);

            groupDict.Dump();
            var sameGroup = groupDict.Where((obj) =>
            {
                return(obj.Value == 0);
            }).ToList();
            int start     = Random.Range(0, sameGroup.Count);
            int goal      = Random.Range(0, sameGroup.Count);
            var nodeNames = sameGroup.Select((arg) => arg.Key).ToArray();

            Debug.Log(sameGroup.Count);
            NodeMap.CostDict    keyValuePairs;
            LinkedList <string> route;
            var pathCount = NodeMap.GetShortestRoute(nodeMap, nodeNames[start], nodeNames[goal], 10000, out keyValuePairs, out route);

            Debug.Log(string.Format("道を探します : start : {0} {1}", nodeNames[start], nodeNames[goal]));

            if (route == null)
            {
                Debug.Log("道が遠すぎたため停止します");
                currentRoute = null;
                return;
            }

            foreach (var nodeName in route)
            {
                Debug.Log("route : " + nodeName + " : " + nodeMap.nodeMap[nodeName].Position);
            }

            currentRoute = route;
        }