/// <summary> /// 设置Boss宝箱信息 /// </summary> /// <param name="id"></param> /// <param name="imgName"></param> /// <param name="itemName"></param> public void SetBossTreasureGridListData(List <BossTreasureGridData> listBossTreasureGridData) { for (int index = 0; index < listBossTreasureGridData.Count; index++) { if (m_mapBossTreasure.ContainsKey(index)) { InstanceBossTreasureUIGrid gridUI = m_mapBossTreasure[index]; BossTreasureGridData gridData = listBossTreasureGridData[index]; gridUI.LoadResourceInsteadOfAwake(); gridUI.SetBossInfo(gridData.id, gridData.iconName, gridData.bossName, gridData.status, gridData.level); } } }
/// <summary> /// 添加Boss宝箱奖励 /// </summary> /// <param name="num"></param> /// <param name="act"></param> void AddBossTreasureGridList(int num, Action act = null) { ClearBossTreasureGridList(); ResetGridListCameraPos(); // 删除翻页位置 if (m_gridListMyDragableCamera.transformList != null) { for (int i = 0; i < m_gridListMyDragableCamera.transformList.Count; ++i) { Destroy(m_gridListMyDragableCamera.transformList[i].gameObject); } m_gridListMyDragableCamera.transformList.Clear(); } for (int i = 0; i < num; ++i) { int index = i; INSTANCE_COUNT++; MogoGlobleUIManager.Instance.ShowWaitingTip(true); AssetCacheMgr.GetUIInstance("InstanceBossTreasureUIGrid.prefab", (prefab, guid, go) => { GameObject obj = (GameObject)go; obj.transform.parent = m_tranInstanceBossTreasureUIGridlList; obj.transform.localPosition = new Vector3(ITEMSPACEHORIZON * index, 0, 0); obj.transform.localScale = new Vector3(0.8f, 0.8f, 1); obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_gridListCamera; InstanceBossTreasureUIGrid gridUI = obj.AddComponent <InstanceBossTreasureUIGrid>(); m_mapBossTreasure[index] = gridUI; if (m_mapBossTreasure.Count >= BOSSTREASURE_COUNT_ONE_PAGE) { m_gridListMyDragableCamera.MAXX = (m_mapBossTreasure.Count - BOSSTREASURE_COUNT_ONE_PAGE) * ITEMSPACEHORIZON; } // 创建翻页位置 if (index % BOSSTREASURE_COUNT_ONE_PAGE == 0) { GameObject trans = new GameObject(); trans.transform.parent = m_gridListCamera.transform; trans.transform.localPosition = new Vector3(index / BOSSTREASURE_COUNT_ONE_PAGE * ITEMSPACEHORIZON * BOSSTREASURE_COUNT_ONE_PAGE, 0, 0); trans.transform.localEulerAngles = Vector3.zero; trans.transform.localScale = new Vector3(1, 1, 1); trans.name = "GridListPosHorizon" + index / BOSSTREASURE_COUNT_ONE_PAGE; m_gridListMyDragableCamera.transformList.Add(trans.transform); m_gridListMyDragableCamera.SetCurrentPage(m_gridListMyDragableCamera.GetCurrentPage()); } INSTANCE_COUNT--; if (INSTANCE_COUNT <= 0) { MogoGlobleUIManager.Instance.ShowWaitingTip(false); } if (index == num - 1) { if (act != null) { act(); } } }); } }