/// <summary> /// 获取Grid /// </summary> /// <returns></returns> UICopyTargetGrid GetTargetGrid() { GameObject obj = null; UICopyTargetGrid grid = null; //有缓存先取缓存 if (m_lstTargetGridCache.Count > 0) { obj = m_lstTargetGridCache[0]; m_lstTargetGridCache.RemoveAt(0); grid = obj.GetComponent <UICopyTargetGrid>(); if (grid == null) { grid = obj.AddComponent <UICopyTargetGrid>(); } return(grid); } //无缓存 立即创建 GameObject resObj = UIManager.GetResGameObj(GridID.Uicopytargetgrid) as GameObject; obj = Instantiate(resObj) as GameObject; grid = obj.GetComponent <UICopyTargetGrid>(); if (grid == null) { grid = obj.AddComponent <UICopyTargetGrid>(); } return(grid); }
/// <summary> /// 创建grid /// </summary> void CreateCopyTargetGrid() { //grid ReleaseTargetGrid(); uint copyId = DataManager.Manager <ComBatCopyDataManager>().EnterCopyID; int tempCount = 0; for (int i = 0; i < m_listCopyTarget.Count; i++) { UICopyTargetGrid copyTargetGrid = GetTargetGrid(); copyTargetGrid.transform.parent = m_trans_copyTargetGrid; copyTargetGrid.transform.localScale = Vector3.one; copyTargetGrid.transform.localRotation = Quaternion.identity; float hight1 = -44 * i; tempCount += (m_listCopyTarget[i].waveIdList.Count - 1); float hight2 = -22 * tempCount; //演武场 更新经验 ,金币副本 (特殊处理) if (DataManager.Manager <ComBatCopyDataManager>().IsYanWuChangCopy(copyId) || DataManager.Manager <ComBatCopyDataManager>().IsGoldCopy(copyId) || DataManager.Manager <ComBatCopyDataManager>().IsWorldJuBao(copyId)) { if (i == m_listCopyTarget.Count - 1) { hight2 = -22 * (tempCount + 1); } } copyTargetGrid.transform.localPosition = new Vector3(0, hight1 + hight2, 0); copyTargetGrid.gameObject.SetActive(true); copyTargetGrid.SetGridData(m_listCopyTarget[i]); copyTargetGrid.RegisterUIEventDelegate(UIGridEventDelegate); string name = copyManager.GetCopyTargetName(m_listCopyTarget[i]); copyTargetGrid.SetName(name); m_lstCopyTargetGrid.Add(copyTargetGrid); } }
/// <summary> /// grid点击事件 /// </summary> /// <param name="eventType"></param> /// <param name="data"></param> /// <param name="param"></param> void UIGridEventDelegate(UIEventType eventType, object data, object param) { if (eventType == UIEventType.Click) { UICopyTargetGrid grid = data as UICopyTargetGrid; if (grid == null) { return; } //五行阵副本 bool isWuXinZhenCopy = DataManager.Manager <ComBatCopyDataManager>().IsWuXinZhenCopy(); if (isWuXinZhenCopy) { VisitNpc(grid.copyTarget.mapId, grid.copyTarget.npcId); SetCombatRobot(false); } } }