/// <summary> /// 判断当前装备位置是不是可以强化 /// </summary> /// <param name="pos"></param> /// <returns></returns> public bool JudgeEquipPosCanStrengthen(GameCmd.EquipPos pos) { //部位的当前强化等级<主角当前等级 bool isStrengthMax = emgr.IsGridStrengthenMax(pos); bool moneyEnough = false; bool itemEnough = false; EquipDefine.LocalGridStrengthenData next = emgr.GetNextStrengthDataByPos(pos); if (next != null) { ClientMoneyType type = (ClientMoneyType)next.MoneyCostData.ID; uint num = next.MoneyCostData.Num; moneyEnough = MainPlayerHelper.GetMoneyNumByType(type) >= num; //满足下面要求的 道具 的数量 int matchItemNum = 0; for (int i = 0; i < next.ItemCostDatas.Count; i++) { uint itemID = next.ItemCostDatas[i].ID; uint itemNum = next.ItemCostDatas[i].Num; int holdNum = DataManager.Manager <ItemManager>().GetItemNumByBaseId(itemID); if (holdNum >= itemNum) { matchItemNum++; } } itemEnough = matchItemNum == next.ItemCostDatas.Count; } return(itemEnough && moneyEnough); }
private void SetStrengthenCostMaterial() { bool isMax = emgr.IsGridStrengthenMax(m_emSelectInlayPos); if (null != m_trans_StrengthenCost && m_trans_StrengthenCost.gameObject.activeSelf == isMax) { m_trans_StrengthenCost.gameObject.SetActive(!isMax); } if (!isMax) { if (null == strengthenCostMaterialTransformCache) { strengthenCostMaterialTransformCache = new List <Transform>(); } if (strengthenCostMaterialTransformCache.Count > 0) { for (int i = 0; i < strengthenCostMaterialTransformCache.Count; i++) { strengthenCostMaterialTransformCache[i].gameObject.SetActive(false); } } EquipDefine.LocalGridStrengthenData next = emgr.GetNextStrengthDataByPos(m_emSelectInlayPos); if (null != next.ItemCostDatas && next.ItemCostDatas.Count > 0) { int cacheCount = strengthenCostMaterialTransformCache.Count; Transform tempTran = null; UIItemGrowCostGrid tempGrid = null; ItemManager itemMgr = imgr; for (int i = 0; i < next.ItemCostDatas.Count; i++) { if (i < cacheCount) { tempTran = strengthenCostMaterialTransformCache[i]; } else { GameObject go = NGUITools.AddChild(m_grid_StrengthenCostGridContent.gameObject, m_trans_UIItemGrowCostGrid.gameObject); tempTran = go.transform; strengthenCostMaterialTransformCache.Add(tempTran); } tempTran.gameObject.SetActive(true); tempTran.localScale = Vector3.one; tempTran.localRotation = Quaternion.identity; tempGrid = tempTran.GetComponent <UIItemGrowCostGrid>(); if (null == tempGrid) { tempGrid = tempTran.gameObject.AddComponent <UIItemGrowCostGrid>(); } tempGrid.RegisterUIEventDelegate(OnUIEventCallback); tempGrid.SetGridData(next.ItemCostDatas[i].ID, num: next.ItemCostDatas[i].Num); } m_grid_StrengthenCostGridContent.Reposition(); } } }
private void SetStrengthenCost() { bool isStrengthMax = emgr.IsGridStrengthenMax(m_emSelectInlayPos); EquipDefine.LocalGridStrengthenData next = emgr.GetNextStrengthDataByPos(m_emSelectInlayPos); if (null != m_trans_StrengthenBtns && m_trans_StrengthenBtns.gameObject.activeSelf == isStrengthMax) { m_trans_StrengthenBtns.gameObject.SetActive(!isStrengthMax); } if (!isStrengthMax) { UICurrencyGrid currencyGrid = m_trans_SingleStrengthenCurrency.GetComponent <UICurrencyGrid>(); if (null == currencyGrid) { currencyGrid = m_trans_UICGRefine.gameObject.AddComponent <UICurrencyGrid>(); } currencyGrid.SetGridData(new UICurrencyGrid.UICurrencyGridData( MallDefine.GetCurrencyIconNameByType((GameCmd.MoneyType)next.MoneyCostData.ID), next.MoneyCostData.Num)); } }
/// <summary> /// 刷新 /// </summary> private void UpdateStrengthen() { if (m_emSelectInlayPos == GameCmd.EquipPos.EquipPos_None) { return; } bool isMax = emgr.IsGridStrengthenMax(m_emSelectInlayPos); if (null != m_label_ActiveSuitLvTxt) { m_label_ActiveSuitLvTxt.text = emgr.ActiveStrengthenSuitLv.ToString(); } if (null != m_strengthen) { bool equipGrid = false; uint equipId = 0; if (emgr.IsEquipPos(m_emSelectInlayPos, out equipId)) { equipGrid = true; } equipGrid = equipGrid && !isMax; if (m_strengthen.gameObject.active != equipGrid) { m_strengthen.SetVisible(equipGrid); } if (equipGrid) { m_strengthen.SetGridData(equipId); } } if (null != m_label_StrengthenPosName) { m_label_StrengthenPosName.text = string.Format("{0}.部位", EquipDefine.GetEquipPosName(m_emSelectInlayPos)); } if (null != m_sprite_StrengthenPosIcon) { m_sprite_StrengthenPosIcon.spriteName = EquipDefine.GetEquipPartIcon(m_emSelectInlayPos); m_sprite_StrengthenPosIcon.MakePixelPerfect(); } //强化属性提升 bool enable = !isMax; EquipDefine.LocalGridStrengthenData next = (enable)? emgr.GetNextStrengthDataByPos(m_emSelectInlayPos) : null; if (null != m_label_StrengthenCurLv) { if (m_label_StrengthenCurLv.gameObject.activeSelf != enable) { m_label_StrengthenCurLv.gameObject.SetActive(enable); } if (enable) { m_label_StrengthenCurLv.text = string.Format("强化 {0}级", emgr.GetGridStrengthenLvByPos(m_emSelectInlayPos)); } } if (null != m_label_StrengthenTargetLv) { if (m_label_StrengthenTargetLv.gameObject.activeSelf != enable) { m_label_StrengthenTargetLv.gameObject.SetActive(enable); } if (enable) { m_label_StrengthenTargetLv.text = string.Format("强化 {0}级", emgr.GetGridStrengthenLvByPos(m_emSelectInlayPos) + 1); } } if (null != m_label_StrengthenMaxLv) { if (m_label_StrengthenMaxLv.gameObject.activeSelf != isMax) { m_label_StrengthenMaxLv.gameObject.SetActive(isMax); } if (isMax) { m_label_RefineMaxLv.text = string.Format("强化 {0}级", emgr.GetGridStrengthenLvByPos(m_emSelectInlayPos));; } } List <EquipDefine.EquipBasePropertyData> curBaseProData = (null != StrengthenData) ? StrengthenData.BaseProp : null; List <EquipDefine.EquipBasePropertyData> nextBaseProData = (enable) ? emgr.GetNextStrengthDataByPos(m_emSelectInlayPos).BaseProp : null; Transform content = null; Transform max = null; bool propertyenable = false; if (null != m_trans_StrengthenEquipProperty1) { propertyenable = (null != curBaseProData) && (curBaseProData.Count > 0) || (null != nextBaseProData) && (nextBaseProData.Count > 0); if (m_trans_StrengthenEquipProperty1.gameObject.activeSelf != propertyenable) { m_trans_StrengthenEquipProperty1.gameObject.SetActive(propertyenable); } if (propertyenable) { content = m_trans_StrengthenEquipProperty1.Find("Content"); max = m_trans_StrengthenEquipProperty1.Find("Max"); if (content.gameObject.activeSelf != enable) { content.gameObject.SetActive(enable); } if (enable) { content.Find("Name").GetComponent <UILabel>().text = ((null != curBaseProData && curBaseProData.Count > 0) ? curBaseProData[0].Name : nextBaseProData[0].Name); content.Find("CurValue").GetComponent <UILabel>().text = "+" + ((null != curBaseProData && curBaseProData.Count > 0) ? curBaseProData[0].ToString() : "0"); content.Find("TargetValue").GetComponent <UILabel>().text = "+" + nextBaseProData[0].ToString(); } if (max.gameObject.activeSelf == enable) { max.gameObject.SetActive(!enable); } if (!enable) { max.Find("AttrTxt").GetComponent <UILabel>().text = string.Format("{0} +{1}" , curBaseProData[0].Name , curBaseProData[0]); } } } if (null != m_trans_StrengthenEquipProperty2) { propertyenable = (null != curBaseProData) && (curBaseProData.Count > 1) || (null != nextBaseProData) && (nextBaseProData.Count > 1); if (m_trans_StrengthenEquipProperty2.gameObject.activeSelf != propertyenable) { m_trans_StrengthenEquipProperty2.gameObject.SetActive(propertyenable); } if (propertyenable) { content = m_trans_StrengthenEquipProperty2.Find("Content"); max = m_trans_StrengthenEquipProperty2.Find("Max"); if (content.gameObject.activeSelf != enable) { content.gameObject.SetActive(enable); } if (enable) { content.Find("Name").GetComponent <UILabel>().text = ((null != curBaseProData && curBaseProData.Count > 1) ? curBaseProData[1].Name : nextBaseProData[1].Name); content.Find("CurValue").GetComponent <UILabel>().text = "+" + ((null != curBaseProData && curBaseProData.Count > 1) ? curBaseProData[1].ToString() : "0"); content.Find("TargetValue").GetComponent <UILabel>().text = "+" + nextBaseProData[1].ToString(); } if (max.gameObject.activeSelf == enable) { max.gameObject.SetActive(!enable); } if (!enable) { max.Find("AttrTxt").GetComponent <UILabel>().text = string.Format("{0} +{1}" , curBaseProData[1].Name , curBaseProData[1]); } } } if (null != m_trans_StrengthenMax) { if (m_trans_StrengthenMax.gameObject.activeSelf != isMax) { m_trans_StrengthenMax.gameObject.SetActive(isMax); } } //设置消耗材料 SetStrengthenCostMaterial(); //设置消耗钱币 SetStrengthenCost(); RefreshBtnState(); }