/// <summary>
    /// Initializes this instance.
    /// </summary>
    public void Initialize(CharacterSelectUI charSelectUI, UIScrollItem scrollItem,
                           Character character, bool isUsed, bool isOwned, float ownedCharRotSpeed,
                           float normalCharScale, float focusCharScale,
                           float focusAnimTime, Vector3 focusPos,
                           NewCharWinAnimator newCharWinAnim,
                           Animator newCharAnimReference)
    {
        // Store references to character select classes
        m_charSelectUI = charSelectUI;
        m_scrollItem   = scrollItem;
        m_character    = character;

        SetUsed(isUsed);
        SetOwned(isOwned);
        SetOwnedCharRotSpeed(ownedCharRotSpeed);
        SetCharScale(normalCharScale, focusCharScale);
        SetFocusPos(focusPos);
        SetFocusAnimTime(focusAnimTime);

        m_newCharWinAnim = newCharWinAnim;

        // Store reference to animator to follow for new/unused characters
        m_newCharAnimReference = newCharAnimReference;

        // Store the character's starting transform properties
        m_originalRot  = m_character.transform.localEulerAngles;
        m_originalPosZ = m_character.transform.localPosition.z;

        // Set the initialized flag
        m_isInitialized = true;
    }
Example #2
0
                } // end DragUp

                private void DragDown(float value) {
                    if (index <= indexGap + 1) return;
                    // end if
                    if (value < (index - indexGap - 1) * gap) {
                        UIScrollItem item = itemQueue.DequeueRev();
                        item.SetTop();
                        item.ResetItem(index.ToString(), null, (index - indexGap - 2).ToString());
                        itemQueue.EnqueueRev(item);
                        index--;
                    } // end if
                } // end DragDown
Example #3
0
                } // end OnClickItem

                private void DragUp(float value) {
                    if (index >= maxIndex) return;
                    // end if
                    if (value > (index - indexGap) * gap) {
                        UIScrollItem item = itemQueue.Dequeue();
                        item.SetBotton();
                        item.ResetItem(index.ToString(), null, index.ToString());
                        itemQueue.Enqueue(item);
                        index++;
                    } // end if
                } // end DragUp
Example #4
0
    /// <summary>
    /// Initializes the character scroll panel.
    /// </summary>
    private void InitializeCharacterScrollPanel(GameSceneMaster sceneMaster)
    {
        // Initialize scroll panel
        m_characterSelectPanel.Initialize(false, false);
        // Populate character list
        GameObject[] prefabs = m_characterResource.GetCharacterPrefabs();
        for (int index = 0; index < prefabs.Length; ++index)
        {
            // Instantiate character
            Character character = m_characterResource.CreateCharacter((CharacterType)index);
            // Create scroll item
            UIScrollItem newItem = m_characterSelectPanel.CreateScrollItem();
            // Child character under scroll item
            character.transform.parent = newItem.transform;
            // Position character "behind" the scroll item
            character.transform.localPosition = new Vector3(0.0f, 0.0f, m_normalCharLocalPosZ);
            // Set initial rotation
            character.transform.eulerAngles = m_initialRotation;
            // Set normal scale
            character.transform.localScale = Vector3.one * m_normalCharScale;
            // Add scroll item to scroll panel
            m_characterSelectPanel.AddScrollItem(newItem);

            // Set the character layer and sorting layer to UI
            character.ModelRenderer.gameObject.layer = LayerMask.NameToLayer(m_scrollItemLayer);
            character.ModelRenderer.sortingLayerName = m_scrollItemSortingLayer;
            character.ModelRenderer.sortingOrder     = m_scrollItemSortingOrder;

            // Attach a CharacterSelectItem component to allow handling from CharacterSelectUI
            CharacterSelectItem charSelectItem = newItem.gameObject.AddComponentNoDupe <CharacterSelectItem>();
            bool isUsed  = sceneMaster.IsUsed((CharacterType)index);
            bool isOwned = sceneMaster.IsOwned((CharacterType)index);
            charSelectItem.Initialize(this, newItem, character, isUsed, isOwned,
                                      m_ownedCharRotSpeed, m_normalCharScale, m_focusCharScale,
                                      m_focusCharAnimTime, m_focusCharPosition, m_newCharWinAnim,
                                      m_newCharAnimReference);
            if (!m_charSelectItemList.Contains(charSelectItem))
            {
                m_charSelectItemList.Add(charSelectItem);
            }
            // Update the number of used characters (those that have been equipped by the player at least once)
            if (isUsed)
            {
                m_usedCharCount++;
            }
            // Update the number of owned characters
            if (isOwned)
            {
                m_ownedCharCount++;
            }
        }
    }
Example #5
0
    private void InitItem()
    {
        for (int i = 0; i < (int)UserLevelData.MAX_REF_COUNT; i++)
        {
            GameObject obj = MonoBehaviour.Instantiate(m_itemObj) as GameObject;
            obj.transform.parent        = m_scrollGrid.transform;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = Vector3.zero;

            UIScrollItem item = new UIScrollItem(obj);
            m_itemList.Add(item);
        }
    }
Example #6
0
 public UIScrollView(ScrollRect scrollRect) {
     index = 0;
     lastDrag = 0;
     maxIndex = 100;
     this.scrollRect = scrollRect;
     itemQueue = new TWQueue<UIScrollItem>();
     scrollRect.content.sizeDelta = new Vector2(383, maxIndex * 125);
     int count = Mathf.Clamp(maxIndex, 0, 4);
     indexGap = count - 1;
     for (int i = 0; i < count; i++) {
         UIScrollItem item = new UIScrollItem(scrollRect.content, 
             new Vector3(0, -62.5f - i * 125f, 0), OnClickItem);
         item.ResetItem(index.ToString(), null, index.ToString());
         itemQueue.Enqueue(item);
         index++;
     } // end for
     scrollRect.verticalScrollbar.onValueChanged.AddListener(delegate (float value) { OnDrag(value); });
 } // end Start
Example #7
0
    /// <summary>
    /// Detects and sets focus on the character currently in the center of the screen.
    /// </summary>
    private void UpdateFocusedCharacter()
    {
        // If character select is hidden, do not do any focusing
        if (!m_characterSelectRoot.activeInHierarchy)
        {
            return;
        }
        Vector3      focusAreaCenter   = m_characterSelectPanel.ScrollBounds.center;
        UIScrollItem nearestScrollItem = m_characterSelectPanel.GetItemNearestToPosition(focusAreaCenter);

        if (nearestScrollItem == null)
        {
            return;
        }

        // Scroll item should be within slot-size distance of the focus area
        // If character panel is scrolled out too far from the focus area,
        //  do not focus on any character
        if (Mathf.Abs(nearestScrollItem.transform.position.x - focusAreaCenter.x) > m_characterSelectPanel.SlotSize.x)
        {
            // If there was a focused item, remove focus
            if (m_focusedItem != null)
            {
                m_focusedItem.SetFocus(false);
                m_focusedItem = null;
                UpdateFocusAreaFields();
            }
        }
        else
        {
            // If new focused item, unfocus the old one and focus on the new one
            CharacterSelectItem nearestItem = nearestScrollItem.GetComponent <CharacterSelectItem>();
            if (m_focusedItem != nearestItem)
            {
                RemoveFocus(true);
                nearestItem.SetFocus(true);
                m_focusedItem = nearestItem;
                UpdateFocusAreaFields();

                // Play the character select sound
                Locator.GetSoundManager().PlayOneShot(SoundInfo.SFXID.CharacterSelect);
            }
        }
    }
Example #8
0
    private void UpdateList()
    {
        ReleaseAllCardItem();

        UserLevelInfo info = WorldManager.instance.m_dataManager.
                             m_userLevelData.GetLevelInfo(WorldManager.instance.m_player.m_level);

        InGameNotification.instance.SetLevelUpUnlockNotification(info.levelUpRefArray);

        for (int i = 0; i < info.levelUpRefArray.Length; i++)
        {
            UIScrollItem item = GetItem(i);
            if (info.levelUpRefArray[i].index.Equals(0) == false)
            {
                item.Init(info.levelUpRefArray[i]);
            }
        }

        UpdateItemPosition();
    }