示例#1
0
        private void OnPrizeChestSelectChanged(UButtonGroupItem oldItem, UButtonGroupItem newItem)
        {
            ClearContainer(chestObjContainer);
            if (newItem)
            {
                PrizeChestInfo info = newItem.GetComponent <PrizeChestInfo>();
                if (info)
                {
                    if (chestObjContainer == null)
                    {
                        GameObject go = new GameObject();
                        go.name           = "PrizeChestContainer";
                        chestObjContainer = go.transform;
                    }

                    GameObject parent = new GameObject();
                    parent.name = "PrizeItem";
                    parent.transform.SetParent(chestObjContainer);
                    parent.transform.localPosition = Vector3.zero;

                    SceneEffectParamBase effectParam = new SceneEffectParamBase(info.PrizeChestConfig.nNormalEffect, parent.transform);
                    SceneEffectManager.Instance.CreateSceneEffect(ref effectParam);

                    SceneEffectParamBase bgEffectParam = new SceneEffectParamBase(info.PrizeChestConfig.nBgEffectID, parent.transform);
                    SceneEffectManager.Instance.CreateSceneEffect(ref bgEffectParam);

                    prizeChestItem.Clear();
                    prizeChestItem.SetData(this, info.PrizeChestConfig.nChestId, info.PrizeChestConfig.strChestName, info.PrizeChestCount);
                }
            }
        }
示例#2
0
        //刷新主界面宝箱模型及UI数据
        private void RefreshChest()
        {
            prizeChestItem.Clear();
            if (defaultBGEffect != null)
            {
                SceneEffectManager.Instance.DestroySceneEffect(ref defaultBGEffect);
                defaultBGEffect = null;
            }
            ClearContainer(chestObjContainer);
            ClearContainer(chestGroup.transform);
            Dictionary <int, int> selfChestInfo = LogicDataCenter.prizeChestDataManager.ChestInfo;
            Dictionary <int, SSchemePrizeChestConfig> chestConfig = ActorPrizeConfig.Instance.PrizeChestConfig;

            int nIndex = 0;

            m_reaminingChestCount = 0;
            foreach (var config in chestConfig)
            {
                if (!selfChestInfo.ContainsKey(config.Key))
                {
                    continue;
                }

                int nHaveNum = selfChestInfo[config.Key];
                if (config.Value.nAlwaysShow == 0 && nHaveNum <= 0)
                {
                    continue;
                }

                //只显示宝箱,不显示矿石
                if (config.Value.nChestFlag > 1)
                {
                    continue;
                }

                ++nIndex;
                if (nIndex > 6)
                {
                    break;
                }

                GameObject go = GameObject.Instantiate(prizeChestInfoGO);
                if (go)
                {
                    go.name = "PrizeChestInfoItem";
                    go.transform.SetParent(chestGroup.transform);
                    go.transform.localScale = Vector3.one;
                    UButtonGroupItem item = go.GetComponent <UButtonGroupItem>();
                    if (item)
                    {
                        item.Group = chestGroup;
                    }
                    PrizeChestInfo info = go.GetComponent <PrizeChestInfo>();
                    if (info)
                    {
                        info.SetData(config.Value, nHaveNum);
                        go.SetActive(true);
                        m_reaminingChestCount++;
                    }
                }
            }

            if (m_reaminingChestCount > 0)
            {
                linkBtn.gameObject.SetActive(false);
                Transform chestItemTr = chestGroup.transform.GetChild(0);
                OnPrizeChestSelectChanged(null, chestItemTr.gameObject.GetComponent <UButtonGroupItem>());
                if (m_reaminingChestCount == 1)
                {
                    prizeChestItem.SetOpenChestBtnText(chestItemTr.GetComponent <PrizeChestInfo>().PrizeChestCount);
                    ClearContainer(chestGroup.transform);
                }
                else
                {
                    prizeChestItem.SetOpenChestBtnText(-1);
                }
            }
        }