private void InitItemList()
    {
        int num = itemFixCount + UnityEngine.Random.Range(0, itemAddCount);

        TcTItem[] rareArray   = tcStatus.GetRareArray();
        TcTItem[] normalArray = tcStatus.GetNormalArray();
        float     num2        = rarePercent + UnityEngine.Random.Range(0f, rareAdd);

        if (normalArray.Length == 0)
        {
            num2 = 100f;
        }
        else if (rareArray.Length == 0)
        {
            num2 = 0f;
        }
        tcTItemList = new TcTItem[num];
        for (int i = 0; i < tcTItemList.Length; i++)
        {
            TcTItem tcTItem = (!(num2 < UnityEngine.Random.Range(0f, 100f))) ? rareArray[UnityEngine.Random.Range(0, rareArray.Length)] : normalArray[UnityEngine.Random.Range(0, normalArray.Length)];
            tcTItemList[i] = tcTItem;
        }
        if (tcTItemList.Length > 3)
        {
            tcTItemList[tcTItemList.Length - 3].code  = code;
            tcTItemList[tcTItemList.Length - 3].isKey = wasKey;
            tcTItemList[tcTItemList.Length - 3].opt   = amount;
        }
        destPosition = (float)(tcTItemList.Length - 4) * itemScroll.offSetX;
    }
 public TcTItem GetFirstRare()
 {
     foreach (TcTItem listTItem in listTItems)
     {
         TcTItem current = listTItem;
         if (current.isKey)
         {
             return(current);
         }
     }
     return(default(TcTItem));
 }
    public TcTItem[] GetRareArray()
    {
        List <TcTItem> list = new List <TcTItem>();

        foreach (TcTItem listTItem in listTItems)
        {
            TcTItem current = listTItem;
            if (current.isKey)
            {
                list.Add(current);
            }
        }
        return(list.ToArray());
    }
    public TcTItem[] GetArraySorted()
    {
        List <TcTItem> list = new List <TcTItem>();

        foreach (TcTItem listTItem in listTItems)
        {
            TcTItem current = listTItem;
            if (current.isKey)
            {
                list.Add(current);
            }
        }
        foreach (TcTItem listTItem2 in listTItems)
        {
            TcTItem current2 = listTItem2;
            if (!current2.isKey)
            {
                list.Add(current2);
            }
        }
        return(list.ToArray());
    }
 public void AddExpectations(TcTItem item)
 {
     listTItems.Add(item);
 }
    public override bool DoDialog()
    {
        bool    result = false;
        GUISkin skin   = GUI.skin;

        GUI.skin = GUISkinFinder.Instance.GetGUISkin();
        imgList.Draw();
        labelList.Draw();
        TcStatus[] array = TreasureChestManager.Instance.ToArray();
        scrollBoard.ListResetAddPosition();
        scrollBoard.SetListCount(array.Length);
        scrollBoard.BeginScroll();
        for (int i = 0; i < scrollBoard.GetListCount(); i++)
        {
            TcStatus tcStatus = array[i];
            select.IsDraw           = (curBoard == i);
            boardBack.toolTipString = tcStatus.Seq.ToString();
            boardName.SetText(tcStatus.GetTitle());
            if (tcStatus.TokenPrice == 0)
            {
                token.IsDraw      = false;
                tokenCount.IsDraw = false;
            }
            else
            {
                token.IsDraw      = true;
                tokenCount.IsDraw = true;
                tokenCount.SetText(tcStatus.TokenPrice.ToString());
            }
            if (tcStatus.CoinPrice == 0)
            {
                coin.IsDraw      = false;
                coinCount.IsDraw = false;
                premium.IsDraw   = true;
            }
            else
            {
                coin.IsDraw      = true;
                coinCount.IsDraw = true;
                premium.IsDraw   = false;
                coinCount.SetText(tcStatus.CoinPrice.ToString());
            }
            if (BuildOption.Instance.Props.randomBox == BuildOption.RANDOM_BOX_TYPE.INFERNUM)
            {
                maxRare.SetListCount(tcStatus.MaxKey);
                currentRare.SetListCount(tcStatus.Key);
                count.SetText(tcStatus.GetDescription());
                itemIconTable.IsDraw = false;
                itemTimeTable.IsDraw = false;
            }
            else
            {
                TcTItem firstRare = tcStatus.GetFirstRare();
                if (!firstRare.IsNull())
                {
                    TItem tItem = TItemManager.Instance.Get <TItem>(firstRare.code);
                    if (tItem != null)
                    {
                        itemIconTable.IsDraw   = true;
                        itemTimeTable.IsDraw   = true;
                        premium.IsDraw         = false;
                        itemIconTable.texImage = tItem.CurIcon();
                        if (tItem.IsAmount)
                        {
                            itemTimeTable.SetText(firstRare.opt.ToString() + " " + StringMgr.Instance.Get("TIMES_UNIT"));
                        }
                        else if (firstRare.opt >= 1000000)
                        {
                            itemTimeTable.SetText(StringMgr.Instance.Get("INFINITE"));
                        }
                        else
                        {
                            itemTimeTable.SetText(firstRare.opt.ToString() + " " + StringMgr.Instance.Get("DAYS"));
                        }
                    }
                    else
                    {
                        itemIconTable.IsDraw = false;
                        itemTimeTable.IsDraw = false;
                    }
                }
            }
            scrollBoard.SetListPostion(i);
            scrollBoard.Draw();
            if (boardBack.isClick())
            {
                curBoard = i;
                if (Time.time - lastClickTime < doubleClickTimeout && clickBoard == curBoard)
                {
                    doubleClicked = true;
                }
                else
                {
                    lastClickTime = Time.time;
                    clickBoard    = curBoard;
                }
            }
        }
        scrollBoard.EndScroll();
        if (curBoard >= 0 && curBoard < array.Length)
        {
            TcTItem[] arraySorted = array[curBoard].GetArraySorted();
            scrollRare.ListResetAddPosition();
            itemLine.ResetAddPosition();
            scrollRare.SetListCount(arraySorted.Length);
            scrollRare.BeginScroll();
            for (int j = 0; j < arraySorted.Length; j++)
            {
                TItem tItem2 = TItemManager.Instance.Get <TItem>(arraySorted[j].code);
                if (tItem2 != null)
                {
                    itemName.textKey    = tItem2.name;
                    itemIcon.texImage   = tItem2.CurIcon();
                    itemExplain.textKey = tItem2.comment;
                    if (tItem2.IsAmount)
                    {
                        itemTime.SetText(arraySorted[j].opt.ToString() + " " + StringMgr.Instance.Get("TIMES_UNIT"));
                    }
                    else if (arraySorted[j].opt >= 1000000)
                    {
                        itemTime.SetText(StringMgr.Instance.Get("INFINITE"));
                    }
                    else
                    {
                        itemTime.SetText(arraySorted[j].opt.ToString() + " " + StringMgr.Instance.Get("DAYS"));
                    }
                    if (arraySorted[j].isKey)
                    {
                        itemBackNomal.IsDraw = false;
                        itemBackRare.IsDraw  = true;
                    }
                    else
                    {
                        itemBackNomal.IsDraw = true;
                        itemBackRare.IsDraw  = false;
                    }
                    scrollRare.SetListPostion(j);
                    bool flag = scrollRare.IsSkipAble();
                    if (!flag)
                    {
                        scrollRare.Draw();
                        property.sizeX = size.x - 100f;
                        property.Start();
                        property.tItem = tItem2;
                        TooltipProperty tooltipProperty = property;
                        Vector2         showPosition    = itemName.showPosition;
                        tooltipProperty.categoryPosX = showPosition.x;
                        TooltipProperty tooltipProperty2 = property;
                        Vector2         showPosition2    = itemName.showPosition;
                        tooltipProperty2.categoryPosY = showPosition2.y + 22f;
                        TooltipProperty tooltipProperty3 = property;
                        Vector2         showPosition3    = itemName.showPosition;
                        tooltipProperty3.DoPropertyGuage(showPosition3.y + 2f);
                    }
                    if (j != arraySorted.Length - 1)
                    {
                        if (!flag)
                        {
                            itemLine.Draw();
                        }
                        itemLine.AddPositionY(scrollRare.offSetY);
                    }
                }
            }
            scrollRare.EndScroll();
        }
        if (exit.Draw() || GlobalVars.Instance.IsEscapePressed())
        {
            result = true;
        }
        if ((enter.Draw() || GlobalVars.Instance.IsReturnPressed() || doubleClicked) && curBoard >= 0 && curBoard < array.Length)
        {
            CSNetManager.Instance.Sock.SendCS_TC_ENTER_REQ(array[curBoard].Seq);
        }
        myTokenHave.SetText(MyInfoManager.Instance.Cash.ToString("n0"));
        myCoinHave.SetText(MyInfoManager.Instance.FreeCoin.ToString("n0"));
        myToken.Draw();
        myTokenHave.Draw();
        myCoinHave.Draw();
        if (!ContextMenuManager.Instance.IsPopup)
        {
            WindowUtil.EatEvent();
        }
        GUI.skin = skin;
        return(result);
    }