private bool ProcessNext(int startIdx)
 {
     for (int i = startIdx; i < switchableIconCount; i++)
     {
         if (handler.IsDeckSelectable(i, (i < decks.Length) ? decks[i] : null))
         {
             currentIdx = i;
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
        protected void Init(ManagerBase manager, DeckModel[] srcDecks, CommonDeckSwitchHandler handler, KeyControl keyController, bool otherEnabled, int currentIdx, int horizontalIconMargin)
        {
            this.decks                = srcDecks;
            this.handler              = handler;
            this.keyController        = keyController;
            this.currentIdx           = currentIdx;
            this.otherEnabled         = otherEnabled;
            this.horizontalIconMargin = horizontalIconMargin;
            int deckCount = manager.UserInfo.DeckCount;

            this.keyControlEnable = true;
            int           num          = deckCount + ((!otherEnabled) ? 0 : 1);
            int           num2         = -(num - 1) * horizontalIconMargin / 2;
            HashSet <int> validIndices = new HashSet <int>();

            this.decks.ForEach(delegate(DeckModel e)
            {
                validIndices.Add(e.Id - 1);
            });
            if (otherEnabled)
            {
                validIndices.Add(num - 1);
            }
            for (int i = 0; i < num; i++)
            {
                GameObject gameObject = Util.Instantiate(this.templateSprite.get_gameObject(), base.get_gameObject(), false, false);
                gameObject.get_transform().localPosition(new Vector3((float)(num2 + horizontalIconMargin * i), 0f, 0f));
                UISprite component = gameObject.GetComponent <UISprite>();
                if (validIndices.Contains(i))
                {
                    this.switchableIconSprites.Add(component);
                }
                else
                {
                    component.spriteName = "pin_none";
                }
            }
            this.templateSprite.SetActive(false);
            if (!handler.IsDeckSelectable(currentIdx, this.currentDeck))
            {
                this.ProcessNext(0);
            }
            handler.OnDeckChange(this.currentDeck);
            this.RefleshIcons();
        }