public LevelDetail_progress GetInstance() { LevelDetail_progress 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_progress>(m_progress); } Transform t0 = m_progress.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); }
public bool CacheInstance(LevelDetail_progress instance) { if (instance == null || instance.Equals(null)) { return(false); } if (mCachedInstances == null) { mCachedInstances = new Queue <LevelDetail_progress>(); } if (mCachedInstances.Contains(instance)) { return(false); } instance.gameObject.SetActive(false); mCachedInstances.Enqueue(instance); return(true); }
private void MakeProgressItem(QuestItem itemCfg, int curId, LevelDetail_progress progressUI) { float thisId = itemCfg.condition[1]; progressUI.transform.SetParent(progress.progress.transform.parent, false); progressUI.gameObject.SetActive(true); PassItem passItem = Global.gApp.gGameData.PassData.Get(m_InitId + (int)itemCfg.condition[1]); ItemItem itemItemCfg = Global.gApp.gGameData.ItemData.Get((int)itemCfg.award[0]); if (isRight) { progressUI.RightGiftBg.gameObject.SetActive(isRight); progressUI.RightGift.gameObject.SetActive(isRight); } else { if (itemCfg.condition[1] == curId) { progressUI.mask.image.fillAmount = 0.5f; } else if (itemCfg.condition[1] < curId) { progressUI.mask.image.fillAmount = 1f; } else { progressUI.mask.image.fillAmount = 0f; } progressUI.LeftGiftBg.gameObject.SetActive(!isRight); progressUI.LeftGift.gameObject.SetActive(!isRight); } if (isRight) { progressUI.RightRetry.button.onClick.AddListener(() => { OnStartGame(passItem.id); }); progressUI.RightRetry.gameObject.SetActive(passItem.id < Global.gApp.gSystemMgr.GetPassMgr().GetCurPassId()); } else { progressUI.LeftRetry.button.onClick.AddListener(() => { OnStartGame(passItem.id); }); progressUI.LeftRetry.gameObject.SetActive(passItem.id < Global.gApp.gSystemMgr.GetPassMgr().GetCurPassId()); } QuestItemDTO questItemDTO = Global.gApp.gSystemMgr.GetQuestMgr().GetQuestItemDTO(itemCfg.quest_id); Image giftImageBg = isRight ? progressUI.RightBgImg.image : progressUI.LeftBgImg.image; giftImageBg.rectTransform.Rotate(new Vector3(0, 180, 0)); giftImageBg.sprite = Resources.Load(string.Format(CommonResourceConstVal.LEVEL_DETAIL_BG_PATH, passItem.dtType, 0), typeof(Sprite)) as Sprite; if (passItem.dtType != 4) { if (m_EffectIndex == m_EffectShowIndex) { string effctUri; if (m_DtEffectDtc.TryGetValue(passItem.dtType.ToString(), out effctUri)) { GameObject effect = UiTools.GetEffect(effctUri, giftImageBg.transform, 45); } m_EffectShowIndex = m_EffectIndex + UnityEngine.Random.Range(2, 4); } m_EffectIndex++; } Image giftImage = isRight ? progressUI.RightGift.image : progressUI.LeftGift.image; giftImage.sprite = Resources.Load(itemItemCfg.closeBoxImg, typeof(Sprite)) as Sprite; Image openedImage = isRight ? progressUI.RightOpened.image : progressUI.LeftOpened.image; Image awardBgImage = isRight ? progressUI.RightAwardBg.image : progressUI.LeftAwardBg.image; if (questItemDTO.state == QuestStateConstVal.RECEIVED) { openedImage.gameObject.SetActive(true); } else { openedImage.gameObject.SetActive(false); } Text text = isRight ? progressUI.RightNum.text : progressUI.LeftNum.text; text.text = ((int)itemCfg.condition[1]).ToString(); if (thisId >= curId) { giftImageBg.color = ColorUtil.GetTextColor(false, Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.GREY_COLOR).content); giftImage.color = ColorUtil.GetTextColor(false, Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.GREY_COLOR).content); openedImage.color = ColorUtil.GetTextColor(false, Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.GREY_COLOR).content); awardBgImage.color = ColorUtil.GetTextColor(false, Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.GREY_COLOR).content); } RectTransform levelBg = isRight ? progressUI.RightLevel.rectTransform : progressUI.LeftLevel.rectTransform; SetPassIcon(levelBg, passItem, m_InitId + curId); }
private void MakeNormalProgress(int id, int curId, LevelDetail_progress curProgressUI) { curProgressUI.transform.SetParent(progress.progress.transform.parent, false); curProgressUI.gameObject.SetActive(true); PassItem passItem = Global.gApp.gGameData.PassData.Get(m_InitId + id); if (isRight) { curProgressUI.RightGiftBg.gameObject.SetActive(isRight); m_BgIndex++; } else { if (id == curId) { curProgressUI.mask.image.fillAmount = 0.5f; } else if (id < curId) { curProgressUI.mask.image.fillAmount = 1f; } else { curProgressUI.mask.image.fillAmount = 0f; } curProgressUI.LeftGiftBg.gameObject.SetActive(!isRight); m_BgIndex++; } if (isRight) { curProgressUI.RightRetry.button.onClick.AddListener(() => { OnStartGame(m_InitId + id); }); curProgressUI.RightRetry.gameObject.SetActive(m_InitId + id < Global.gApp.gSystemMgr.GetPassMgr().GetCurPassId()); } else { curProgressUI.LeftRetry.button.onClick.AddListener(() => { OnStartGame(m_InitId + id); }); curProgressUI.LeftRetry.gameObject.SetActive(m_InitId + id < Global.gApp.gSystemMgr.GetPassMgr().GetCurPassId()); } Text text = isRight ? curProgressUI.RightNum.text : curProgressUI.LeftNum.text; text.text = id.ToString(); Image giftImageBg = isRight ? curProgressUI.RightBgImg.image : curProgressUI.LeftBgImg.image; giftImageBg.rectTransform.Rotate(new Vector3(0, 180, 0)); int ri = (m_BgIndex % 3) + 1; giftImageBg.sprite = Resources.Load(string.Format(CommonResourceConstVal.LEVEL_DETAIL_BG_PATH, passItem.dtType, ri), typeof(Sprite)) as Sprite; if (passItem.dtType == 4 && ri == 2) { string effctUri; if (m_DtEffectDtc.TryGetValue(passItem.dtType.ToString(), out effctUri)) { GameObject effect = UiTools.GetEffect(effctUri, giftImageBg.transform, 45); } } else if (passItem.dtType != 4) { if (m_EffectIndex == m_EffectShowIndex) { string effctUri; if (m_DtEffectDtc.TryGetValue(passItem.dtType.ToString(), out effctUri)) { GameObject effect = UiTools.GetEffect(effctUri, giftImageBg.transform, 45); } m_EffectShowIndex = m_EffectIndex + UnityEngine.Random.Range(2, 4); } m_EffectIndex++; } Image giftImage = isRight ? curProgressUI.RightGift.image : curProgressUI.LeftGift.image; Image openedImage = isRight ? curProgressUI.RightOpened.image : curProgressUI.LeftOpened.image; openedImage.gameObject.SetActive(false); Image awardBgImage = isRight ? curProgressUI.RightAwardBg.image : curProgressUI.LeftAwardBg.image; awardBgImage.gameObject.SetActive(false); if (id >= curId) { giftImageBg.color = ColorUtil.GetTextColor(false, Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.GREY_COLOR).content); giftImage.color = ColorUtil.GetTextColor(false, Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.GREY_COLOR).content); openedImage.color = ColorUtil.GetTextColor(false, Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.GREY_COLOR).content); awardBgImage.color = ColorUtil.GetTextColor(false, Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.GREY_COLOR).content); } RectTransform levelBg = isRight ? curProgressUI.RightLevel.rectTransform : curProgressUI.LeftLevel.rectTransform; SetPassIcon(levelBg, passItem, m_InitId + curId); }