예제 #1
0
        /// <summary>
        /// Selection this selection.
        ///
        /// ATTENTION(jenchieh): this can only use by the 'Event
        /// Trigger' component.
        /// </summary>
        /// <param name="selection"> selection to select. </param>
        public void SelectSelection(JCS_ButtonSelection selection, bool hoverCheck = false)
        {
            if (selection == null)
            {
                return;
            }

            /*
             * Time complexity: O(n)
             *
             * NOTE(jenchieh): might need to change this if we there are
             * more than 30 selections.
             */
            for (int index = 0;
                 index < mSelections.Count;
                 ++index)
            {
                JCS_ButtonSelection bs = mSelections[index];

                if (bs == selection)
                {
                    SelectSelection(index, hoverCheck);
                    return;
                }
            }

            JCS_Debug.LogError(@"Try to select a selection, but seems like the 
selection is not in the group...");
        }
예제 #2
0
        /// <summary>
        /// Get the selection depends on the direction.
        /// </summary>
        /// <param name="bs"> Button Selection object to use to find out the actual button selection. </param>
        /// <param name="direction"> Target direction. </param>
        /// <returns>
        /// Button selection in target button selection's up/down/right/left button selection.
        /// </returns>
        public JCS_ButtonSelection GetButtonSelectionByDirection(JCS_ButtonSelection bs, Direction direction)
        {
            switch (direction)
            {
            case Direction.UP: return(bs.UpSelection);

            case Direction.DOWN: return(bs.DownSelection);

            case Direction.RIGHT: return(bs.RightSelection);

            case Direction.LEFT: return(bs.LeftSelection);
            }

            JCS_Debug.Log("Failed to get button selection by direction, this should not happens...");
            return(null);
        }
예제 #3
0
        /// <summary>
        /// Is all the button selection in this direction skip?
        /// </summary>
        /// <param name="bs"> starting button selection. </param>
        /// <param name="direction"> direction to loop to. </param>
        /// <returns>
        /// true: yes, all selections in this direction about this button selection is skip!
        /// false: no, at least on selection is not skip in this direction behind this diection.
        /// </returns>
        private bool IsAllSelectionsIsSkipDirection(JCS_ButtonSelection bs, Direction direction)
        {
            JCS_ButtonSelection newBs = GetButtonSelectionByDirection(bs, direction);

            // if the chain break, meaning all the selections is skip in
            // this direction.
            if (newBs == null)
            {
                return(true);
            }

            // if not skip, break the loop.
            if (!newBs.Skip)
            {
                return(false);
            }

            return(IsAllSelectionsIsSkipDirection(newBs, direction));
        }
예제 #4
0
 /// <summary>
 /// Add Event to Unity's Event Trigger(Script)
 /// </summary>
 /// <param name="te"></param>
 /// <param name="type"></param>
 /// <param name="func"></param>
 public static void AddEventTriggerEvent(EventTrigger te, EventTriggerType type, EventTriggerEventButtonSelection func, JCS_ButtonSelection selection)
 {
     EventTrigger.Entry entry = new EventTrigger.Entry();
     entry.eventID = type;
     entry.callback.AddListener((data) => { func((PointerEventData)data, selection); });
     te.triggers.Add(entry);
 }
예제 #5
0
 /// <summary>
 /// Selection this selection.
 /// </summary>
 /// <param name="selection"> selection to select. </param>
 public void SelectSelection(PointerEventData data, JCS_ButtonSelection selection)
 {
     SelectSelection(selection);
 }
예제 #6
0
 public void SelectSelectionHover(JCS_ButtonSelection selection)
 {
     SelectSelection(selection, true);
 }
예제 #7
0
 /// <summary>
 /// Remove a selection from the list.
 /// </summary>
 /// <param name="selection"></param>
 public void RemoveSelection(JCS_ButtonSelection selection)
 {
     mSelections.Remove(selection);
 }
예제 #8
0
 /// <summary>
 /// Add a selection into list.
 /// </summary>
 /// <param name="selection"></param>
 public void AddSelection(JCS_ButtonSelection selection)
 {
     mSelections.Add(selection);
 }