Esempio n. 1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateWithCursor(ICursorState pCursor)
        {
            bool       allowSelect    = (pCursor.IsInputAvailable && DisplayStrength > 0);
            Vector3?   cursorWorldPos = (allowSelect ? pCursor.GetWorldPosition() : (Vector3?)null);
            CursorType cursorType     = pCursor.Type;
            float      nearestDist    = float.MaxValue;

            NearestItem = null;

            foreach (BaseItemState item in vAllItems)
            {
                item.UpdateWithCursor(cursorType, cursorWorldPos);

                if (!allowSelect)
                {
                    continue;
                }

                float itemDist = item.GetHighlightDistance(cursorType);

                if (itemDist >= nearestDist)
                {
                    continue;
                }

                NearestItem = item;
                nearestDist = itemDist;
            }

            foreach (BaseItemState item in vAllItems)
            {
                item.SetAsNearestItem(cursorType, (item == NearestItem));
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateProjection(ProjectionState pProj)
        {
            ICursorState cursor         = pProj.Cursor;
            CursorType   cursorType     = cursor.Type;
            bool         allowSelect    = (cursor.IsInputAvailable && pProj.IsActive);
            Vector3?     cursorWorldPos = (allowSelect ? cursor.GetWorldPosition() : (Vector3?)null);
            ItemTree     nearestTree    = new ItemTree();
            float        nearestDist    = float.MaxValue;

            foreach (ItemTree itemTree in vAllItems)
            {
                itemTree.Item.UpdateWithCursor(cursorType, cursorWorldPos);

                if (!allowSelect)
                {
                    continue;
                }

                float itemDist = itemTree.Item.GetHighlightDistance(cursorType);

                if (itemDist >= nearestDist)
                {
                    continue;
                }

                nearestTree = itemTree;
                nearestDist = itemDist;
            }

            foreach (ItemTree itemTree in vAllItems)
            {
                BaseItemState item = itemTree.Item;
                item.SetAsNearestItem(cursorType, (item == nearestTree.Item));
            }

            if (nearestTree.Panel == null || nearestTree.Item.MaxHighlightProgress <= 0)
            {
                pProj.SetNearestPanelTransform(null);
                pProj.NearestItemHighlightProgress = 0;
                return;
            }

            GameObject panelObj = (GameObject)nearestTree.Panel.ItemPanel.DisplayContainer;

            pProj.SetNearestPanelTransform(panelObj.transform);
            pProj.NearestItemHighlightProgress = nearestTree.Item.GetHighlightProgress(cursorType);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateWithCursor(ICursorState pCursor)
        {
            bool allowSelect = (pCursor.IsInputAvailable && DisplayStrength > 0);
            Vector3? cursorWorldPos = (allowSelect ? pCursor.GetWorldPosition() : (Vector3?)null);
            CursorType cursorType = pCursor.Type;
            float nearestDist = float.MaxValue;

            NearestItem = null;

            foreach ( BaseItemState item in vAllItems ) {
                item.UpdateWithCursor(cursorType, cursorWorldPos);

                if ( !allowSelect ) {
                    continue;
                }

                float itemDist = item.GetHighlightDistance(cursorType);

                if ( itemDist >= nearestDist ) {
                    continue;
                }

                NearestItem = item;
                nearestDist = itemDist;
            }

            foreach ( BaseItemState item in vAllItems ) {
                item.SetAsNearestItem(cursorType, (item == NearestItem));
            }
        }