void RefreshBuildCostPanel() { InitBuildCostElement(); foreach (Transform trans in _buildCostContentTrans) { trans.gameObject.SetActive(false); } var materialDic = PlayerModule.Instance.GetBuildMaterialCost(model.BuildData); int index = 0; foreach (KeyValuePair <Material, ushort> kvp in materialDic) { MaterialDataModel model = new MaterialDataModel(); if (model.Create(kvp.Key.MaterialID)) { var element = UIUtility.SafeGetComponent <BuildRequireElement>(_buildCostContentTrans.GetChild(index)); if (element != null) { element.InitBuildCost(model, kvp.Value); element.gameObject.SetActive(true); index++; } } else { continue; } } }
/// <summary> /// 初始化科技需求 /// </summary> private void SetUpTechRequire() { if (techInfo == null) { return; } var content = Transform.FindTransfrom("Content/Context/RequireContent/Content/Scroll View/Viewport/Content"); content.InitObj(UIPath.PrefabPath.Tech_Require_Element, Config.GlobalConfigData.TechDetail_Dialog_MaxRequire_Count); content.SafeSetActiveAllChild(false); var requireList = techInfo.techRequireList; int index = 0; //Init Cost //Init Cost var costObj = content.GetChild(index); if (costObj != null) { index++; var cmpt = costObj.SafeGetComponent <TechRequireElement>(); cmpt.SetUpElement(TechRequireElement.RequireType.ResearchPoint, new object[] { techInfo._model.TechCost }, false); costObj.SafeSetActive(true); } for (int i = 0; i < requireList.Count; i++) { var type = TechnologyModule.Instance.GetTechRequireType(requireList[i]); switch (type) { case TechRequireType.PreTech: ///Init PreTech var techList = TechnologyModule.ParseTechParam_Require_PreTech(requireList[i].Param); for (int j = 0; j < techList.Count; j++) { TechnologyDataModel techModel = new TechnologyDataModel(); if (techModel.Create(techList[j])) { var obj = content.GetChild(index); if (obj != null) { index++; var element = obj.SafeGetComponent <TechRequireElement>(); bool warning = TechnologyDataManager.Instance.GetTechInfo(techList[j]).currentState == TechnologyState.Lock ? true : false; element.SetUpElement(TechRequireElement.RequireType.PreTech, new object[] { techModel.ID }, warning); obj.SafeSetActive(true); } } } break; case TechRequireType.Material: var materialDic = TechnologyModule.parseTechParam_Require_Material(requireList[i].Param); foreach (KeyValuePair <int, int> kvp in materialDic) { MaterialDataModel maModel = new MaterialDataModel(); if (maModel.Create(kvp.Key)) { var obj = content.GetChild(index); if (obj != null) { index++; var element = obj.SafeGetComponent <TechRequireElement>(); bool warning = PlayerManager.Instance.GetMaterialStoreCount(kvp.Key) < kvp.Value ? true : false; element.SetUpElement(TechRequireElement.RequireType.Material, new object[] { maModel.ID, kvp.Value }, warning); obj.SafeSetActive(true); } } } break; } } }