private void HideLand(GameObject land) { if (land != null) { int chlid = land.transform.childCount; for (int i = chlid - 1; i >= 0; --i) { LTInstanceMapChapterCtrl ctrl = land.transform.GetChild(i).GetMonoILRComponent <LTInstanceMapChapterCtrl>(); SetItem(ctrl); } land.CustomSetActive(false); LandQueue.Enqueue(land); } }
private void SetItem(LTInstanceMapChapterCtrl temp) { if (temp == null) { return; } temp.mDMono.transform.SetParent(PoolTrans); temp.mDMono.transform.localPosition = Vector3.zero; temp.mDMono.transform.localScale = Vector3.one; temp.mDMono.gameObject.CustomSetActive(false); if (ChapterQueue != null) { ChapterQueue.Enqueue(temp); } }
//创建缓存 private LTInstanceMapChapterCtrl GetItem(Transform parent) { LTInstanceMapChapterCtrl temp = null; if (ChapterQueue != null && ChapterQueue.Count > 0) { temp = ChapterQueue.Dequeue(); temp.mDMono.transform.SetParent(parent); temp.mDMono.transform.localScale = Vector3.one; } else { GameObject obj = GameObject.Instantiate(ChapterObjInstance, parent); temp = obj.GetMonoILRComponent <LTInstanceMapChapterCtrl>(); } return(temp); }
//创建大陆 private GameObject CreateLand(string landId) { if (LandQueue.Count == 0) { EB.Debug.LogWarning("LandQueue.Count not enough!"); return(null); } Hotfix_LT.Data.LostMainLandTemplate temp = Hotfix_LT.Data.SceneTemplateManager.Instance.GetLostMainLandTemplateByLandId(landId); if (temp == null) { EB.Debug.LogWarning("LandId is error!landId = {0}", landId); return(null); } GameObject land = LandQueue.Dequeue(); land.GetComponent <CampaignTextureCmp>().spriteName = temp.LineName; bool initSelect = false; for (int i = 0; i < temp.ChapterList.Count; ++i) { bool show = false; string dataId = temp.ChapterList[i]; if (openChapterIds.Contains(dataId)) { show = true; } else { var boxTemp = Hotfix_LT.Data.SceneTemplateManager.Instance.GetNextChapter(dataId); if (boxTemp != null && boxTemp.IsBoxRewardType()) { show = true; } } if (show) { Hotfix_LT.Data.LostMainChapterTemplate tpl = Hotfix_LT.Data.SceneTemplateManager.Instance.GetLostMainChatpterTplById(dataId); if (tpl == null) { continue; } LTInstanceMapChapterCtrl item = GetItem(land.transform); item.Init(tpl); if (!string.IsNullOrEmpty(newChapterId) && tpl.Id.Equals(newChapterId)) { newChapterId = string.Empty; item.PlayNewChapterFX(); } else { item.PlayNewChapterFX(false); } if (tpl.Id.Equals(vaildMaxChapter)) { initSelect = true; controller.Transforms["ArrowTran"].SetParent(item.mDMono.transform); } } } if (!initSelect) { controller.Transforms["ArrowTran"].SetParent(PoolTrans); } land.name = landId; return(land); }