예제 #1
0
        public void ClearSearchMask(List <SearchNode> search, BT.BinaryTree unsearch)
        {
            foreach (SearchNode n in search)
            {
                mgr.RemoveSearchMark(n.v);
            }
            search.Clear();
            SearchNode no = (SearchNode)unsearch.Pop();

            while (true)
            {
                if (no == null)
                {
                    break;
                }
                mgr.RemoveSearchMark(no.v);
                no = (SearchNode)unsearch.Pop();
            }
            unsearch.Clear();
        }
예제 #2
0
        bool WalkHoneycomb(Coord vend, Vector3 endPos, List <SearchNode> search, BT.BinaryTree unsearch)
        {
            int count = 0;

            while (true)
            {
                SearchNode node = (SearchNode)unsearch.Pop();
                if (node == null)
                {
                    return(false);
                }
                search.Add(node);

                if (node.v.Equal(vend))
                {
                    return(true);
                }
                ushort currentData = mgr.GetHeight(node.v);
                int    current     = currentData & Tile.HeightMask;

                Coord[] varray   = node.v.Neighbour();
                int     newchild = 0;

                for (int i = 0; i < varray.Length; i++)
                {
                    Coord c = varray[i];
                    if (!mgr.IsCoordValid(c))
                    {
                        continue;
                    }
                    int layerCount = mgr.GetTileLayerCount(c);
                    for (int layer = 0; layer < layerCount; layer++)
                    {
                        Coord newC = new Coord();
                        newC.x = c.x;
                        newC.y = layer;
                        newC.z = c.z;
                        //c.y = layer;


                        ushort by = mgr.GetHeight(newC);

                        if ((by & Tile.Walkable) == 0)
                        {
                            continue;
                        }
                        if ((by & Tile.HasSearch) != 0)
                        {
                            continue;
                        }
                        //if (!newC.Equal(vend))
                        //{
                        //    if ((by & Tile.HasPlayer) != 0)
                        //    {
                        //        continue;
                        //    }
                        //}

                        int   height        = by & Tile.HeightMask;
                        float fHeightOffset = (height - current) * mgr.GetLayerHeight();
                        if (fHeightOffset > 0.5f || fHeightOffset < -0.5f)
                        {
                            continue;
                        }

                        SearchNode n = NewSearchNode(newC, endPos);
                        n.parent = node;
                        n.SetStepWeight(CalcWeight(n, endPos, currentData, by));
                        count++;

                        newchild++;
                        unsearch.Push(n.weight(), n);
                        mgr.AddSearchMark(n.v);
                    }
                }
            }
            return(false);
        }