Exemplo n.º 1
0
            public LevelDetail_gun GetInstance()
            {
                LevelDetail_gun instance = null;

                if (mCachedInstances != null)
                {
                    while ((instance == null || instance.Equals(null)) && mCachedInstances.Count > 0)
                    {
                        instance = mCachedInstances.Dequeue();
                    }
                }
                if (instance == null || instance.Equals(null))
                {
                    instance = Instantiate <LevelDetail_gun>(m_gun);
                }
                Transform t0 = m_gun.transform;
                Transform t1 = instance.transform;

                t1.SetParent(t0.parent);
                t1.localPosition = t0.localPosition;
                t1.localRotation = t0.localRotation;
                t1.localScale    = t0.localScale;
                t1.SetSiblingIndex(t0.GetSiblingIndex() + 1);
                return(instance);
            }
Exemplo n.º 2
0
 public bool CacheInstance(LevelDetail_gun instance)
 {
     if (instance == null || instance.Equals(null))
     {
         return(false);
     }
     if (mCachedInstances == null)
     {
         mCachedInstances = new Queue <LevelDetail_gun>();
     }
     if (mCachedInstances.Contains(instance))
     {
         return(false);
     }
     instance.gameObject.SetActive(false);
     mCachedInstances.Enqueue(instance);
     return(true);
 }
Exemplo n.º 3
0
        private void ShowStepUI(int stepId)
        {
            isRight = false;
            int index = stepId == 0 ? 0 : m_StepIndexDic[stepId - 1];

            if (stepId == -1)
            {
                m_UserStep = Global.gApp.gSystemMgr.GetPassMgr().GetUserStep();
                m_CurStep  = m_UserStep;
            }
            else
            {
                m_CurStep = stepId;
            }

            int stepStart = m_CurStep == 0 ? 1 : Global.gApp.gGameData.PassStep[m_CurStep - 1] + 1 - m_InitId;
            int stepEnd   = Global.gApp.gGameData.PassStep[m_CurStep] - m_InitId;

            List <QuestItem> configs = Global.gApp.gGameData.QuestTypeMapData[QuestConst.TYPE_LEVEL_DETAIL];
            int curId = Global.gApp.gSystemMgr.GetPassMgr().GetCurPassId() - m_InitId;

            //显示顶部标识
            LevelDetail_step stepUI = Instantiate <LevelDetail_step>(step.step);

            stepUI.StepName.gameObject.SetActive(false);
            m_ScrolViewList[index]         = stepUI;
            stepUI.transform.localPosition = new Vector3(Viewport.rectTransform.rect.size.x / 2, m_ScrolViewHeightList[index], stepUI.transform.localPosition.z);
            index++;
            stepUI.transform.SetParent(step.step.transform.parent, false);
            PassItem passItemCfg = Global.gApp.gGameData.PassData.Get(Global.gApp.gGameData.PassStep[m_CurStep]);
            string   bgIndex     = System.Text.RegularExpressions.Regex.Replace(passItemCfg.mainUIbg, @"[^0-9]+", "");

            stepUI.StepIcon.image.sprite = Resources.Load(string.Format(CommonResourceConstVal.RESOURCE_LEVEL_DETAIL_ICON, bgIndex), typeof(Sprite)) as Sprite;
            string effctUri;

            if (m_IconEffectDtc.TryGetValue(bgIndex, out effctUri))
            {
                GameObject effect = UiTools.GetEffect(effctUri, stepUI.transform, 45);
            }
            stepUI.gameObject.SetActive(true);
            //stepUI.GunItem.gameObject.SetActive(i != configs.Count - 1);
            for (int i = stepStart; i <= stepEnd; i++)
            {
                QuestItem questItemCfg = null;
                ItemItem  iCfg         = null;
                bool      isWeapon     = false;
                passQuestDic.TryGetValue(i, out questItemCfg);
                if (questItemCfg != null)
                {
                    iCfg     = Global.gApp.gGameData.ItemData.Get((int)questItemCfg.award[0]);
                    isWeapon = ItemTypeConstVal.isWeapon(iCfg.showtype);
                }
                if (isWeapon)
                {
                    LevelDetail_gun gunUI = Instantiate <LevelDetail_gun>(gun.gun);

                    gunUI.transform.SetParent(gun.gun.transform.parent, false);
                    gunUI.gameObject.SetActive(true);

                    gunUI.num.text.text = i.ToString();
                    int passId = m_InitId + int.Parse(gunUI.num.text.text);
                    gunUI.GunRetry.button.onClick.AddListener(() => { OnStartGame(passId); });
                    gunUI.GunRetry.gameObject.SetActive(passId < Global.gApp.gSystemMgr.GetPassMgr().GetCurPassId());
                    gunUI.GunIcon.image.sprite   = Resources.Load(iCfg.image_grow, typeof(Sprite)) as Sprite;
                    gunUI.GunBottom.image.sprite = Resources.Load(string.Format(CommonResourceConstVal.MAIN_UI_WEAPON_DOWN_PATH, iCfg.qualevel), typeof(Sprite)) as Sprite;
                    string     effectName = iCfg.showtype == ItemTypeConstVal.BASE_MAIN_WEAPON ? iCfg.qualevel.ToString() : "common";
                    EffectItem effectItem = Global.gApp.gGameData.EffectData.Get(EffectConstVal.QUALITY);
                    GameObject gunEffect  = UiTools.GetEffect(string.Format(effectItem.path, iCfg.qualevel), gunUI.EffectNode.rectTransform);

                    gunEffect.transform.GetChild(0).localPosition = new Vector3(0f, 0f, 0f);
                    ParticleSystem[] pss = gunEffect.GetComponentsInChildren <ParticleSystem>();
                    foreach (ParticleSystem ps in pss)
                    {
                        ps.GetComponent <Renderer>().sortingOrder = 45;
                    }

                    PassItem passItem = Global.gApp.gGameData.PassData.Get(m_InitId + (int)questItemCfg.condition[1]);
                    SetPassIcon(gunUI.level.rectTransform, passItem, m_InitId + curId);
                    if (isRight)
                    {
                        index++;
                    }
                    m_ScrolViewList[index]        = gunUI;
                    gunUI.transform.localPosition = new Vector3(Viewport.rectTransform.rect.size.x / 2, m_ScrolViewHeightList[index], gunUI.transform.localPosition.z);
                    index++;
                    isRight = false;

                    if (i >= curId)
                    {
                        gunUI.GunIcon.image.color = ColorUtil.GetTextColor(false, Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.BLACK_COLOR).content);
                        gunUI.GunName.text.text   = "???";
                        GeneralConfigItem colorConfig = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.BLACK_COLOR);
                        gunUI.GunName.text.color = ColorUtil.GetColor(colorConfig.content);
                        GeneralConfigItem color1Config = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.BLACK_1_COLOR);
                        gunUI.GunBottom.image.color = ColorUtil.GetColor(color1Config.content);
                    }
                    else
                    {
                        gunUI.GunName.text.text = iCfg.gamename;
                        GeneralConfigItem colorConfig = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.QUALITY_COLOR);
                        //gunUI.GunName.text.color = ColorUtil.GetColor(colorConfig.contents[iCfg.qualevel]);
                        if (iCfg.showtype == ItemTypeConstVal.BASE_MAIN_WEAPON)
                        {
                            gunUI.GunBottom.image.sprite = Resources.Load(string.Format(CommonResourceConstVal.MAIN_UI_WEAPON_DOWN_PATH, iCfg.qualevel), typeof(Sprite)) as Sprite;
                            gunUI.GunName.text.color     = ColorUtil.GetColor(colorConfig.contents[iCfg.qualevel]);
                        }
                        else
                        {
                            gunUI.GunBottom.image.sprite = Resources.Load(string.Format(CommonResourceConstVal.MAIN_UI_WEAPON_DOWN_PATH, 2), typeof(Sprite)) as Sprite;
                            gunUI.GunName.text.color     = ColorUtil.GetColor(colorConfig.contents[2]);
                        }
                    }
                }
                else
                {
                    //有奖励
                    QuestItem            questItem;
                    LevelDetail_progress progressUI;
                    if (!isRight)
                    {
                        progressUI = Instantiate <LevelDetail_progress>(progress.progress);
                        progressUI.LeftGiftBg.gameObject.SetActive(false);
                        progressUI.RightGiftBg.gameObject.SetActive(false);
                        progressUI.LeftGift.gameObject.SetActive(false);
                        progressUI.RightGift.gameObject.SetActive(false);

                        m_ScrolViewList[index] = progressUI;
                    }
                    else
                    {
                        progressUI = m_ScrolViewList[index] as LevelDetail_progress;
                    }
                    if (passQuestDic.TryGetValue(i, out questItem))
                    {
                        MakeProgressItem(questItem, curId, progressUI);
                    }
                    else
                    {
                        MakeNormalProgress(i, curId, progressUI);
                    }

                    progressUI.transform.localPosition = new Vector3(Viewport.rectTransform.rect.size.x / 2, m_ScrolViewHeightList[index], progressUI.transform.localPosition.z);

                    if (isRight)
                    {
                        index++;
                    }
                    isRight = !isRight;
                }
            }
            if (m_CurStep == m_UserStep && m_UserStep < Global.gApp.gGameData.PassStep.Count - 1)
            {
                LevelDetail_step nextStepUI = Instantiate <LevelDetail_step>(step.step);
                nextStepUI.StepName.gameObject.SetActive(true);
                m_ScrolViewList[m_ScrolViewHeightList.Count - 1] = stepUI;
                nextStepUI.transform.localPosition = new Vector3(Viewport.rectTransform.rect.size.x / 2, m_ScrolViewHeightList[m_ScrolViewHeightList.Count - 1], nextStepUI.transform.localPosition.z);
                nextStepUI.transform.SetParent(step.step.transform.parent, false);
                PassItem nextPassItemCfg = Global.gApp.gGameData.PassData.Get(Global.gApp.gGameData.PassStep[m_CurStep + 1]);
                string   nextBgIndex     = System.Text.RegularExpressions.Regex.Replace(nextPassItemCfg.mainUIbg, @"[^0-9]+", "");
                nextStepUI.StepIcon.image.sprite = Resources.Load(string.Format(CommonResourceConstVal.RESOURCE_LEVEL_DETAIL_ICON, nextBgIndex), typeof(Sprite)) as Sprite;

                nextStepUI.gameObject.SetActive(true);
                nextStepUI.StepIcon.image.color = ColorUtil.GetTextColor(false, Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.GREY_COLOR).content);

                string nextEffctUri;
                if (m_IconEffectDtc.TryGetValue(nextBgIndex, out nextEffctUri))
                {
                    GameObject effect = UiTools.GetEffect(nextEffctUri, nextStepUI.transform, 45);
                }
            }

            isRight = false;
            //显示顶部标识
            //LevelDetail_boss bossUI = Instantiate<LevelDetail_boss>(boss.boss);
            //m_ScrolViewList.Add(bossUI);
            //m_ScrolViewHeightList.Add(-m_Height - boss.rectTransform.sizeDelta.y / 2);
            //bossUI.transform.SetParent(boss.boss.transform.parent, false);
            //m_Height += boss.rectTransform.sizeDelta.y;
            //bossUI.gameObject.SetActive(true);
        }