WithInArrayRange() public static method

With in array range. (Array)
public static WithInArrayRange ( int index, Array arr ) : bool
index int
arr Array
return bool
        /// <summary>
        /// Remove linked node from the managed list.
        /// </summary>
        /// <param name="n"> Number of linked object to remove. </param>
        /// <param name="startIndex"> Starting index to remove. </param>
        /// <returns> List of removed linked object. </returns>
        public List <JCS_TransformLinkedObject> RemoveLinked(int n = 1, int startIndex = 0)
        {
            if (!JCS_Util.WithInArrayRange(startIndex, mManagedList))
            {
                JCS_Debug.LogReminder("Can't remove linked node with index lower than 0");
                return(null);
            }

            var lst = new List <JCS_TransformLinkedObject>();

            int        maxIndex = startIndex + n;
            List <int> ids      = new List <int>();

            for (int index = startIndex; index < mManagedList.Count && index < maxIndex; ++index)
            {
                JCS_TransformLinkedObject node = mManagedList[index];

                ids.Add(index); // First record it down.
                lst.Add(node);  // Added to the remove list, and ready to return.
            }

            for (int index = 0; index < ids.Count; ++index)
            {
                int id = ids[index];

                JCS_TransformLinkedObject node = mManagedList[id];
                Destroy(node.gameObject);

                mManagedList.RemoveAt(id);
            }

            OrganizedLinked();

            return(lst);
        }
Beispiel #2
0
        /// <summary>
        /// Light the indicator that corresponds to the PAGE.
        /// </summary>
        /// <param name="page"> Target page we want the indicator to notify the user. </param>
        public void SetPage(int page)
        {
            SetSprite(mInactiveSprite);

            if (!JCS_Util.WithInArrayRange(page, mIndicators))
            {
                JCS_Debug.LogWarning("Page indicators out of range exception");
                return;
            }

            mIndicators[page].sprite = mActiveSprite;
        }
Beispiel #3
0
        /// <summary>
        /// Selection this selection.
        /// </summary>
        /// <param name="selectionIndex"> index to select. </param>
        public void SelectSelection(int selectionIndex, bool hoverCheck = false)
        {
            if (hoverCheck)
            {
                if (JCS_Util.WithInArrayRange(selectionIndex, mSelections))
                {
                    if (mSelections[selectionIndex].Skip)
                    {
                        return;
                    }
                }
            }

            // no need to do anything.
            if (mCurrentSelectIndex == selectionIndex)
            {
                return;
            }

            if (JCS_Util.WithInArrayRange(mCurrentSelectIndex, mSelections))
            {
                // disable current active selection.
                mSelections[mCurrentSelectIndex].Active = false;
            }

            this.mCurrentSelectIndex = selectionIndex;

            this.mCurrentSelectIndex = JCS_Util.LoopInArray(this.mCurrentSelectIndex, mSelections);

            // active the new active selection.
            mSelections[mCurrentSelectIndex].Active = true;

            if (selectionChanged != null)
            {
                selectionChanged.Invoke();
            }
        }