Exemple #1
0
        private NavMenu GetNavMenu(string framework)
        {
            var navMenuItems = new List <NavMenuItem>(_navMenuItems);

            if (framework == "Knockout")
            {
                navMenuItems.RemoveAt(1); // Remove "Data Flow Pattern".
                navMenuItems[4] = new NavGroup
                {
                    Label  = "Further Examples",
                    Routes = new NavRoute[]
                    {
                        new NavRoute("Composite View", this.GetRoute(nameof(Route.CompositeView))),
                        new NavRoute("Book Store", this.GetRoute(nameof(Route.BookStore)))
                    },
                    IsExpanded = false
                };
                navMenuItems[5] = new NavGroup
                {
                    Label      = "API Reference",
                    Routes     = (navMenuItems[5] as NavGroup).Routes.Where(x => x.Label != "LocalMode").ToArray(),
                    IsExpanded = false
                };
            }
            return(new NavMenu(navMenuItems.ToArray()));
        }
Exemple #2
0
    private bool Initialize()
    {
        if (mState != null)
        {
            mState.Exit();
        }

        mState = null;

        NavManagerProvider provider =
            (NavManagerProvider)FindObjectOfType(typeof(NavManagerProvider));

        if (provider == null)
        {
            Debug.LogError(string.Format("{0}: There is no {1} in the scene."
                                         , name, typeof(NavManagerProvider).Name));

            return(false);
        }

        NavManager manager = provider.CreateManager();

        if (manager == null)
        {
            Debug.LogError(string.Format("{0}: Could not get the navigation manager.", name));

            return(false);
        }

        mHelper = manager.NavGroup;

        return(true);
    }
        // GET: Footer
        public ActionResult Index()
        {
            // TODO: should point to the /Home/Resources folder
            var footerFolder = Sitecore.Context.Database.GetItem("/sitecore/content/Home");
            
            IEnumerable<NavItem> GetNavItems(Item navRoot)
            {
                var items = new List<Item> { navRoot };
                ID contentItemId = new Sitecore.Data.ID("{77E1B420-FABC-4CA7-BEBF-B0BEA60BB92E}");
                items.AddRange(navRoot.Children.Where( item => item.DescendsFrom(contentItemId)));
                var navItems = items.Skip(1).Select( item => new NavItem
                {
                    Item = item,
                    Url = LinkManager.GetItemUrl(item),
                });
                return navItems;
            }

            var footerLinks = new NavGroup
            {
                RootItem = footerFolder,
                RootUrl = LinkManager.GetItemUrl(footerFolder),
                NavItems = GetNavItems(footerFolder)
            };

            return View(footerLinks);
        }
Exemple #4
0
    void Start()
    {
        NavManagerProvider provider = (NavManagerProvider)FindObjectOfType(typeof(NavManagerProvider));

        if (provider == null)
        {
            Debug.LogError(string.Format("{0}: There is no {1} in the scene."
                                         , name, typeof(NavManagerProvider).Name));

            enabled = false;
            return;
        }

        NavManager.ActiveManager = provider.CreateManager();  // Provides error reporting.

        if (NavManager.ActiveManager == null)
        {
            enabled = false;
            return;
        }

        mManager = NavManager.ActiveManager;
        mNav     = mManager.NavGroup;

        SimGUIUtil.contextHelpText = string.Format(
            "Agent: Add: [{0}], Select: [{1}], Move Selected: [{2}]"
            , StdButtons.SetA, StdButtons.SelectB, StdButtons.SelectA);

        SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight + SimGUIUtil.Margin;
        SimGUIUtil.contextActive             = true;
    }
Exemple #5
0
 public NavHandleData(NavigationRequest req, NavEntity targetEntity)
 {
     entity           = targetEntity;
     sourceRequest    = req;
     entityID         = targetEntity.entityID;
     _movementRequest = new MovementRequest
     {
         entityID = entityID
     };
     isGroup = targetEntity.navEntityType == ENavEntityType.Group;
     if (isGroup)
     {
         _childEntityDataList = new List <NavHandleData>();
         NavGroup group = (NavGroup)targetEntity;
         for (int i = 0; i < group.individualList.Count; i++)
         {
             _childEntityDataList.Add(new NavHandleData(req, group.individualList[i]));
             // 将成员添加进RVO的模拟列表中
             Simulator.Instance.addAgent(
                 group.individualList[i].controlledAgent.GetCurrentPosition().ToRVOVec2()
                 , ENTITY_COLLIDER_RADIUS, 8, 1f, 2f, 1f, NavEntity.GetMaxSpeed(group.individualList[i].entityID), new RVO.Vector2(0, 0));
         }
     }
     destination   = req.destination;
     startPosition = targetEntity.controlledAgent.GetCurrentPosition();
 }
        // GET: Navigation
        public ActionResult Index()
        {
            Item homeItem = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.StartPath);

            IEnumerable <NavItem> GetNavItems(Item navRoot)
            {
                var items = new List <Item> {
                    navRoot
                };
                ID contentItemId = new Sitecore.Data.ID("{77E1B420-FABC-4CA7-BEBF-B0BEA60BB92E}");

                items.AddRange(navRoot.Children.Where(item => item.DescendsFrom(contentItemId)));
                var navItems = items.Select(item => new NavItem
                {
                    Item = item,
                    Url  = LinkManager.GetItemUrl(item),
                });

                return(navItems);
            }

            var navLinks = new NavGroup
            {
                RootItem = homeItem,
                RootUrl  = LinkManager.GetItemUrl(homeItem),
                NavItems = GetNavItems(homeItem)
            };

            return(View(navLinks));
        }
Exemple #7
0
    void Awake()
    {
        NavManagerProvider provider = (NavManagerProvider)FindObjectOfType(typeof(NavManagerProvider));

        if (provider == null)
        {
            Debug.LogError(string.Format("{0}: There is no {1} in the scene."
                                         , name, typeof(NavManagerProvider).Name));

            return;
        }


        NavManager manager = provider.CreateManager();

        if (manager == null)
        {
            Debug.LogError(string.Format("{0}: Could not get the navigation manager.", name));

            return;
        }

        mHelper = manager.NavGroup;

        //mPath = new BufferHandler<uint>();

        isInit = true;
    }
Exemple #8
0
        private NavMenu GetNavMenu(string framework)
        {
            var navMenuItems = new List <NavMenuItem>(_navMenuItems);

            if (framework == "Knockout")
            {
                navMenuItems.RemoveAt(navMenuItems.FindIndex(x => (x as NavRoute)?.Route.TemplateId == nameof(Route.DataFlow)));

                int idx = navMenuItems.FindIndex(x => x.Label == "Further Examples");
                navMenuItems[idx] = new NavGroup
                {
                    Label  = "Further Examples",
                    Routes = new NavRoute[]
                    {
                        new NavRoute("Composite View", this.GetRoute(nameof(Route.CompositeView))),
                        new NavRoute("Book Store", this.GetRoute(nameof(Route.BookStore)))
                    },
                    IsExpanded = false
                };

                idx = navMenuItems.FindIndex(x => x.Label == "API Reference");
                navMenuItems[idx] = new NavGroup
                {
                    Label      = "API Reference",
                    Routes     = (navMenuItems[idx] as NavGroup).Routes.Where(x => x.Label != "Local Mode").ToArray(),
                    IsExpanded = false
                };
            }
            return(new NavMenu(navMenuItems.ToArray()));
        }
Exemple #9
0
        /// <summary>
        /// Provides a standard way detecting where the current
        /// <see cref="hitPosition"/> is on the navigation mesh.
        /// </summary>
        public static SearchResult HandleStandardPolySearch(NavGroup helper
                                                            , out Vector3 geomPoint
                                                            , out NavmeshPoint navPoint
                                                            , out string message)
        {
            if (!hasHit)
            {
                message   = "Outside source geometry.";
                navPoint  = new NavmeshPoint();
                geomPoint = Vector3.zero;
                return(SearchResult.Failed);
            }

            geomPoint = hitPosition;

            NavStatus status =
                helper.query.GetNearestPoint(geomPoint, helper.extents, helper.filter, out navPoint);

            message = "GetNearestPoint: " + status.ToString();

            if (NavUtil.Failed(status))
            {
                return(SearchResult.HitGeometry);
            }

            if (navPoint.polyRef == 0)
            {
                message = "Too far from navmesh: GetNearestPoint: " + status.ToString();
                return(SearchResult.HitGeometry);
            }

            return(SearchResult.HitNavmesh);
        }
Exemple #10
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mPolyRefs = new BufferHandler <uint>("Search Buffer Size"
                                                 , 1, QEUtil.SmallBufferInit, 1, QEUtil.SmallBufferMax);

            int size = mPolyRefs.MaxElementCount;

            mParentRefs = new uint[size];
            mCosts      = new float[size];
            mCentroids  = new Vector3[size];

            mResultCount = 0;
            mHasPosition = false;

            SimGUIUtil.contextHelpText = string.Format(
                "Scale Search: [{0}] [{1}], Translate Search Y: [{2}] [{3}]"
                , StdButtons.AdjustXZMinus, StdButtons.AdjustXZPlus
                , StdButtons.AdjustYMinus, StdButtons.AdjustYPlus);

            SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight * 2.5f;
            SimGUIUtil.contextActive             = true;
        }
    public override void ProcessStep()
    {
        _childData = navHandleData.GetChildNavData();
        if (_childData != null)
        {
            NavGroup group = (NavGroup)navHandleData.entity;
            for (int i = 0; i < _childData.Count; i++)
            {
                _slotInfo = group.GetSlotInfoByEntityID(_childData[i].entityID);
                if (_slotInfo == null)
                {
                    continue;
                }

                float speed    = _childData[i].entity.maxSpeed;
                float distance = Vector3.Distance(NavEntity.GetCurrentPosition(_childData[i].entityID), _slotInfo.slotWorldPosition) *
                                 (1f / NavHandleData.NAV_TICK_TIME);
                // 例如 一秒内距离小于3 速度为3 则速度为初始最大不变
                // 若距离大于3 例如6 则为两倍速
                if (distance > speed)
                {
                    speed = (distance / speed) * speed;
                }

                _childData[i].realVelocity = (_slotInfo.slotWorldPosition - NavEntity.GetCurrentPosition(_childData[i].entityID)).normalized * speed;
                Simulator.Instance.setAgentPrefVelocity(i, _childData[i].realVelocity.ToRVOVec2());
                //var dir = navHandleData.destination.XZ() - NavEntity.GetCurrentPosition(_childData[i].entityID).XZ();
                //Simulator.Instance.setAgentPrefVelocity(i, RVOMath.normalize(dir.ToRVOVec2()));
            }
        }
    }
Exemple #12
0
 //----------------------------方法部分------------------------------//
 public NavAgent(Transform theTransform, NavGroup theGroup, NavAgentGroups theAgentGroup)
 {
     this.agentGroup  = theAgentGroup;
     this.navGroup    = new NavGroup(theGroup, false);
     this.transform   = theTransform;
     this.wideExtents = this.navGroup.extents * 10f;
     RevertToAgentGroup();
 }
Exemple #13
0
    private bool FindPath(
        NavGroup helper
        , ref Vector3 start
        , ref Vector3 end
        )
    {
        NavmeshPoint startPoint, endPoint;

        helper.query.GetNearestPoint(start, helper.extents, helper.filter, out startPoint);
        helper.query.GetNearestPoint(end, helper.extents, helper.filter, out endPoint);

        float   hitPar;
        int     hitCount;
        Vector3 hitNor;

        helper.query.Raycast(startPoint, end, helper.filter, out hitPar, out hitNor, mPath, out hitCount);

        if (hitNor.x != 0f || hitNor.y != 0f)
        {
            //  多路径
            helper.query.FindPath(ref startPoint, ref endPoint, helper.extents, helper.filter, mPath, out hitCount);
            helper.query.GetStraightPath(start, end, mPath, 0, hitCount, mStraightPath, null, null, out mStraightCount);
            mStraightIndex = 0;

            while (mStraightIndex < mStraightCount &&
                   (Mathf.Abs(mStraightPath[mStraightIndex].x - start.x) < 0.001f &&
                    Mathf.Abs(mStraightPath[mStraightIndex].y - start.y) < 0.001f))
            {
                mStraightIndex++;
            }

            //if (mStraightIndex < mStraightCount)
            //{

            //}
            //else
            //{

            //}
        }
        else
        {
            //  单一路经
            mStraightCount   = 1;
            mStraightIndex   = 0;
            mStraightPath[0] = end;
        }


        return(true);
        //resultPath = new uint[] { };
        //NavStatus status = helper.query.FindPath(ref startPoint, ref endPoint, helper.extents, helper.filter, mPath, out count);

        //if (NavUtil.Failed(status))
        //    return SearchResult.HitGeometry;

        //return SearchResult.HitNavmesh;
    }
Exemple #14
0
        //构造方法,最后被直接调用生成
        //原有的架构使用静态共有方法包装了一层
        public NavManager(int maxAgents, NavGroup navGroup, Dictionary <byte, NavAgentGroups> agentGroups)
        {
            maxAgents = UnityEngine.Mathf.Max(1, maxAgents);

            mPlanners    = new NavState[maxAgents];
            mMovers      = new NavState[maxAgents];
            mNavGroup    = navGroup;
            mAgentGroups = new Dictionary <byte, NavAgentGroups>(agentGroups);
        }
Exemple #15
0
        public override void Enter(NavGroup helper)
        {
            base.Enter(helper);

            mTarget.polyRef = 0;
            mStraightCount  = 0;
            mStraightPath   = new BufferHandler <Vector3>("Straight Path Buffer"
                                                          , 1, QEUtil.SmallBufferInit, 1, QEUtil.SmallBufferMax);

            SimGUIUtil.contextControlZone.height += SimGUIUtil.LineHeight * 2.5f;
        }
Exemple #16
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mSelectedPoly[0] = 0;
            mSegmentCount    = 0;

            SimGUIUtil.contextHelpText           = "";
            SimGUIUtil.contextControlZone.height = 0;
            SimGUIUtil.contextActive             = true;
        }
Exemple #17
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mHasPosition = false;
            mHasHeight   = false;

            SimGUIUtil.contextHelpText           = string.Format("Select Poly: [{0}]", StdButtons.SelectA);
            SimGUIUtil.contextControlZone.height = 0;
            SimGUIUtil.contextActive             = true;
        }
Exemple #18
0
 public ActionResult Delete(int id, bool isGroup)
 {
     if (isGroup)
     {
         NavGroup headernav = _navGroupRepo.Get(id);
         return(View(headernav));
     }
     else
     {
         NavItem item = _navItemRepo.Get(id);
         return(View("DeleteItem", item));
     }
 }
Exemple #19
0
        public static NavManager Create(int maxAgents, NavGroup navGroup, Dictionary <byte, NavAgentGroups> agentGroups)
        {
            if (navGroup.crowd == null || navGroup.crowd.IsDisposed ||
                navGroup.mesh == null || navGroup.mesh.IsDisposed ||
                navGroup.query == null || navGroup.query.IsDisposed ||
                agentGroups == null || agentGroups.Count == 0)
            {
                Debug.LogError(" NavManager Create navGroup.mesh == " + (navGroup.mesh == null));
                return(null);
            }

            return(new NavManager(maxAgents, navGroup, agentGroups));
        }
Exemple #20
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mHasPosition = false;
            mHasWallHit  = false;

            SimGUIUtil.contextHelpText = string.Format("Scale Search Radius: [{0}] [{1}]"
                                                       , StdButtons.AdjustXZMinus, StdButtons.AdjustXZPlus);

            SimGUIUtil.contextActive = true;
        }
Exemple #21
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mHasSearchPoint = false;
            mFoundPoly      = false;

            SimGUIUtil.contextHelpText = string.Format("Scale Search: [{0}] [{1}] [{2}] [{3}]"
                                                       , StdButtons.AdjustXZMinus, StdButtons.AdjustXZPlus
                                                       , StdButtons.AdjustYMinus, StdButtons.AdjustYPlus);

            SimGUIUtil.contextActive = true;
        }
Exemple #22
0
        public ActionResult Create(NavGroup headernav, int parentId)
        {
            if (ModelState.IsValid)
            {
                if (parentId != -1)
                {
                    headernav.Parent = _navGroupRepo.Get(parentId);
                }
                _navGroupRepo.Add(headernav);
                _navGroupRepo.Save();
                return(RedirectToAction("Index"));
            }

            return(View(headernav));
        }
Exemple #23
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;
            SimGUIUtil.BuildLabelRegion(false);

            mHasPosition     = false;
            mHasNearestPoint = false;

            SimGUIUtil.contextHelpText = string.Format(
                "Select Poly: [{0}], Translate Y: [{1}] [{2}]"
                , StdButtons.SelectA, StdButtons.AdjustYMinus, StdButtons.AdjustYPlus);

            SimGUIUtil.contextControlZone.height = 0;
            SimGUIUtil.contextActive             = true;
        }
Exemple #24
0
        public void Enter(NavGroup helper)
        {
            mHelper           = helper;
            mPosition.polyRef = 0;
            mGoal.polyRef     = 0;

            SimGUIUtil.BuildLabelRegion(false);

            mPolyRefs = new BufferHandler <uint>("Buffer size"
                                                 , 1, QEUtil.SmallBufferInit, 1, QEUtil.SmallBufferMax);

            mResultCount = 0;

            SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight * 2.5f;
            SimGUIUtil.contextActive             = true;
        }
Exemple #25
0
        private void RemoveAllChildren(NavGroup group)
        {
            if (group != null)
            {
                var subitems = _navItemRepo.GetAll().Where(e => e.Group.Id == group.Id);
                _navItemRepo.DeleteAll(subitems);

                var subgroups = _navGroupRepo.GetAll().Where(e => e.Parent.Id == group.Id);
                foreach (var g in subgroups)
                {
                    RemoveAllChildren(g);
                }

                _navGroupRepo.Delete(group);
            }
        }
Exemple #26
0
        private static IList <MenuItem> GetSubItems(NavGroup group)
        {
            var pages = group.Items.Select(e => new MenuItem {
                Type = MenuItem.ItemType.Page, Id = e.Id, Url = e.Link, MenuOrder = e.Index, Title = e.Text
            }).OrderBy(e => e.MenuOrder).ToList();
            var nodes = group.SubGroups.Select(e =>
            {
                var item = new MenuItem {
                    Type = MenuItem.ItemType.Section, Id = e.Id, Url = e.Link, MenuOrder = e.Index, Title = e.Title, SubItems = GetSubItems(e)
                };

                return(item);
            }).ToList();

            return(pages.Union(nodes).OrderBy(e => e.MenuOrder).ToList());
        }
Exemple #27
0
        public void Enter(NavGroup helper)
        {
            this.mHelper      = helper;
            mPosition.polyRef = 0;
            mGoal.polyRef     = 0;

            SimGUIUtil.BuildLabelRegion(false);

            mPolyRefs = new BufferHandler <uint>("Visited Buffer Size"
                                                 , 1, QEUtil.SmallBufferInit, 1, QEUtil.SmallBufferMax);

            mStraightPath = new Vector3[mPolyRefs.MaxElementCount];

            SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight * 2.5f;
            SimGUIUtil.contextActive             = true;
        }
Exemple #28
0
 public ActionResult Edit(NavGroup headernav, NavItem item, int parentId, bool isGroup)
 {
     if (isGroup)
     {
         headernav.Parent = _navGroupRepo.Get(parentId);
         _navGroupRepo.Update(headernav);
         _navGroupRepo.Save();
         return(RedirectToAction("Index"));
     }
     else
     {
         item.Group = _navGroupRepo.Get(parentId);
         _navItemRepo.Update(item);
         _navItemRepo.Save();
         return(RedirectToAction("Items", new { id = parentId }));
     }
 }
Exemple #29
0
        public ActionResult DeleteConfirmed(int id, bool isGroup)
        {
            if (isGroup)
            {
                NavGroup group = _navGroupRepo.Get(id);
                RemoveAllChildren(group);
            }
            else
            {
                NavItem item = _navItemRepo.Get(id);
                _navItemRepo.Delete(item);
            }

            // Transaction problem?
            _navItemRepo.Save();
            _navGroupRepo.Save();
            return(RedirectToAction("Index"));
        }
Exemple #30
0
        public void Enter(NavGroup helper)
        {
            mHelper = helper;

            SimGUIUtil.BuildLabelRegion(false);

            mPolyRefs = new BufferHandler <uint>("Search Buffer"
                                                 , 1, QEUtil.SmallBufferInit, 1, QEUtil.SmallBufferMax);

            mResultCount = 0;

            SimGUIUtil.contextHelpText = string.Format("Scale Search: [{0}] [{1}] [{2}] [{3}]"
                                                       , StdButtons.AdjustXZMinus, StdButtons.AdjustXZPlus
                                                       , StdButtons.AdjustYMinus, StdButtons.AdjustYPlus);

            SimGUIUtil.contextControlZone.height = SimGUIUtil.LineHeight * 2.5f;
            SimGUIUtil.contextActive             = true;
        }