public bool SetMatrixInfo(int matrixID) { if (!BelleData.OwnedMatrixMap.ContainsKey(matrixID)) { return(false); } BelleMatrix curMatrix = BelleData.OwnedMatrixMap[matrixID]; if (curMatrix == null) { return(false); } Tab_BelleMatrix curBelleMatrix = TableManager.GetBelleMatrixByID(curMatrix.id, 0); if (null == curBelleMatrix) { LogModule.ErrorLog("BelleMatrix not defined"); return(false); } List <int> matrixLayout = GetLayOutByMatrixLayout(curBelleMatrix.Layout); LogModule.DebugLog("matrixLayout ======================= " + matrixLayout.ToArray().ToString()); if (null == matrixLayout || null == m_BelleBandBtns || matrixLayout.Count != m_BelleBandBtns.Length) { LogModule.ErrorLog("matrixLayout.Count " + matrixLayout.Count + " m_BelleBandBtns.Length " + m_BelleBandBtns.Length); LogModule.ErrorLog("BelleMatrix id == " + curBelleMatrix.Id + " Layout " + curBelleMatrix.Layout + "is wrong! "); return(false); } m_MatrixBelleInfos = new MatrixBelleInfo[m_BelleBandBtns.Length]; if (null == m_MatrixBelleInfos) { LogModule.ErrorLog("m_MatrixBelleInfos is created failed!"); return(false); } m_curMatrixCanPutBelles = 0; //初始化默认图标都为+号,使当前的阵法的布局正确显示出来 for (int i = 0; i < matrixLayout.Count && i < m_BelleBandBtns.Length; i++) { m_MatrixBelleInfos[i].CleanUp(); m_BelleBandBtns[i].gameObject.SetActive(matrixLayout[i] == 1); if (m_BelleBandBtns[i].gameObject.activeSelf) { //默认都为+ m_BelleBandBtns[i].SetIconName(null, false, -1, i); } if (matrixLayout[i] == 1) { m_MatrixBelleInfos[i].canPutFlag = 1; m_curMatrixCanPutBelles++; } } //判断当前阵法布局可放的美人数量是否合法 if (m_curMatrixCanPutBelles <= 0 || m_curMatrixCanPutBelles > m_BelleBandBtns.Length) { LogModule.ErrorLog("curMatrixCanPutBellles is null or out of the max = " + m_BelleBandBtns.Length); return(false); } if (!BelleData.OwnedMatrixMap.ContainsKey(matrixID)) { return(false); } //开始正式放美人到阵上 m_hasBattleCount = 0; for (int i = 0; i < curMatrix.belleIDs.Length; ++i) { if (BelleData.OwnedBelleMap.ContainsKey(curMatrix.belleIDs[i])) { Belle curBelle = BelleData.OwnedBelleMap[curMatrix.belleIDs[i]]; if (curBelle.matrixID != matrixID) { LogModule.WarningLog("matrix ID data error: matrixID :" + matrixID.ToString() + "belleMatrixID: " + curBelle.matrixID.ToString()); continue; } int curMatrixIndex = curBelle.matrixIndex; if (curMatrixIndex >= m_BelleBandBtns.Length) { LogModule.WarningLog("curMatrixIndex is big than curMatrix layout count " + curMatrixIndex.ToString()); continue; } //该位置是否可放置美人加个判断 if (curMatrixIndex < 0 || curMatrixIndex >= m_MatrixBelleInfos.Length || m_MatrixBelleInfos[curMatrixIndex].canPutFlag == 0) { LogModule.ErrorLog("CurMatrixIndex " + curMatrixIndex + " is invalid!"); continue; } Tab_Belle curTabBelle = TableManager.GetBelleByID(curMatrix.belleIDs[i], 0); if (null == curTabBelle) { continue; } Tab_CommonItem commItem = TableManager.GetCommonItemByID(curTabBelle.BelleItemID, 0); if (null == commItem) { continue; } m_BelleBandBtns[curMatrixIndex].SetIconName(commItem.Icon, false, curTabBelle.Id, curMatrixIndex); m_MatrixBelleInfos[curMatrixIndex].belleID = curTabBelle.Id; m_MatrixBelleInfos[curMatrixIndex].isRecommond = false; m_hasBattleCount++; } } //////////////////////////////////////////////////////////////////////////////////////////// //当前已经上阵的美人ID列表 hasInMatirxBelles.Clear(); for (int i = 0; i < m_MatrixBelleInfos.Length; i++) { if (m_MatrixBelleInfos[i].canPutFlag == 1 && m_MatrixBelleInfos[i].belleID != -1 && !m_MatrixBelleInfos[i].isRecommond) { hasInMatirxBelles.Add(m_MatrixBelleInfos[i].belleID); } } //Debug一下数据 LogModule.DebugLog(hasInMatirxBelles.ToString()); //推荐不要了 // recomonBelleDatas = GetRecommondBellesByBelleId(hasInMatirxBelles); // SelectBelleList = GetSelectBelleListByBelleId(); // //如果有美人在阵上,并且没有占满就推荐跟他有情缘关系的美人, // if (m_hasBattleCount > 0 && m_hasBattleCount < m_curMatrixCanPutBelles && recomonBelleDatas != null) // { // //当前阵法剩余空位 // int remainCount = m_curMatrixCanPutBelles - m_hasBattleCount; // // for (int i = 0, j = 0; i < m_MatrixBelleInfos.Length; i++) // { // if (m_MatrixBelleInfos[i].canPutFlag == 1 && m_MatrixBelleInfos[i].belleID == -1) // { // if (j >= 0 && j < remainCount && j < recomonBelleDatas.Count) // { // RecommondBelleData _recommonBellData = recomonBelleDatas[j]; // if (m_hasBattleCount < m_curMatrixCanPutBelles) // { // m_MatrixBelleInfos[i].belleID = recomonBelleDatas[j++].BelleID; // m_MatrixBelleInfos[i].isRecommond = true; // } // } // } // } // } // // //推荐的美人界面设置 // for (int i = 0; i < m_MatrixBelleInfos.Length; i++) // { // if (m_MatrixBelleInfos[i].canPutFlag == 1 && m_MatrixBelleInfos[i].belleID != -1 && m_MatrixBelleInfos[i].isRecommond) // { // if (BelleData.OwnedBelleMap.ContainsKey(m_MatrixBelleInfos[i].belleID)) // { // Belle curBelle = BelleData.OwnedBelleMap[m_MatrixBelleInfos[i].belleID]; // // Tab_Belle curTabBelle = TableManager.GetBelleByID(m_MatrixBelleInfos[i].belleID, 0); // if (null == curTabBelle) // { // continue; // } // Tab_CommonItem commItem = TableManager.GetCommonItemByID(curTabBelle.BelleItemID, 0); // if (null == commItem) // { // continue; // } // m_BelleBandBtns[i].SetIconName(commItem.Icon, true, curTabBelle.Id, i); // } // } // } return(true); }
public void SetMatrix(int matrixID) { if (!BelleData.OwnedMatrixMap.ContainsKey(matrixID)) { return; } Tab_BelleMatrix curMatrix = TableManager.GetBelleMatrixByID(matrixID, 0); if (null == curMatrix) { return; } if (null != labelName) { labelName.text = curMatrix.Name; } if (!BelleData.OwnedMatrixMap.ContainsKey(matrixID)) { return; } BelleMatrix curMatrixData = BelleData.OwnedMatrixMap[matrixID]; if (curMatrixData == null) { return; } int minLevel = 10000; curMatrixData.UpdateAttrMap(); labelMatrixGrade.text = BelleData.GetPowerNum(curMatrixData.attrMap).ToString(); labelBelleGrade.text = BelleData.GetPowerNum(curMatrixData.attrBelleMap).ToString(); labelAffectionValue.text = BelleData.GetPowerNum(curMatrixData.attrAffectionMap).ToString(); for (int i = 0; i < curMatrixData.belleIDs.Length; ++i) { if (BelleData.OwnedBelleMap.ContainsKey(curMatrixData.belleIDs[i])) { int curLevel = BelleData.OwnedBelleMap[curMatrixData.belleIDs[i]].colorLevel; if (curLevel < minLevel) { minLevel = curLevel; } } } for (int i = 0; i < labelAttrs.Length; i++) { if (labelAttrValues.Length > i && labelAttrs.Length > i) { if ((i + 1) == minLevel) { if (BelleData.OwnedMatrixMap[matrixID].isActive && IsMatrixFull(matrixID)) { labelAttrs[i].color = labelAttrValues[i].color = m_ColorHighlight; } else { labelAttrs[i].color = labelAttrValues[i].color = Color.gray;//Color.black; } } else if ((i + 1) < minLevel) { labelAttrs[i].color = labelAttrValues[i].color = Color.gray;//Color.black; } else { labelAttrs[i].color = labelAttrValues[i].color = Color.gray; } labelAttrValues[i].text = curMatrix.GetAttrGainsbyIndex(i).ToString(); labelAttrs[i].text = Utils.GetAttrTypeString(curMatrix.AttrType); } } }