Esempio n. 1
0
        public void CheckGlobalCollision(Road road)
        {
            //Debug.Log("CheckGlobalCollision");
            var grid = forest.GetGrid();

            for (int d = 0; d < grid.Length; d++)
            {
                for (int x = 0; x < grid[d].trees.Length; x++)
                {
                    var tree = grid[d].trees[x];
                    if (tree.isActive)
                    {
                        float sdist = road.GetDistance(tree.position);
                        float dist  = Mathf.Abs(sdist);
                        tree.isActive = dist <-halfRoadWidth || dist> halfRoadWidth;
                        if (!tree.isActive && tree.treeObject != null)
                        {
                            tree.treeObject.mainTransform.position += Vector3.down * 16;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        // 通路を延々探して繋ぐ
        void SearchOneway(string node_name, HashSet <Tuple <string, string> > hash, Road road, Dictionary <string, NodeMap.NodeData> nodes)
        {
            var node = nodes[node_name];

            road.Positions.Add(node.Position);

            // 行き止まり or 交差点ならここで調査終了
            if (node.Graph.Count != 2)
            {
                return;
            }

            // ハッシュに登録して次へ
            foreach (var n in node.Graph)
            {
                var key = GetUniqueHash(node_name, n);

                if (!hash.Contains(key))
                {
                    hash.Add(key);
                    SearchOneway(n, hash, road, nodes);
                }
            }
        }