/// <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; } } }
/// <summary> /// 初始化科技完成效果 /// </summary> private void SetUpTechEffect() { if (techInfo == null) { return; } ///Init var content = Transform.FindTransfrom("Content/Context/EffectContent/Content"); content.InitObj(UIPath.PrefabPath.Tech_Effect_Element, Config.GlobalConfigData.TechDetail_Dialog_MaxEffect_Count); content.SafeSetActiveAllChild(false); var effectlist = techInfo.techFinishEffectList; int totalIndex = 0; for (int i = 0; i < effectlist.Count; i++) { var type = TechnologyModule.Instance.GetTechCompleteType(effectlist[i]); switch (type) { case TechCompleteEffect.Unlock_Block: var blockList = TechnologyModule.ParseTechParam_Unlock_Block(effectlist[i].effectParam); for (int j = 0; j < blockList.Count; j++) { FunctionBlockDataModel model = new FunctionBlockDataModel(); if (model.Create(blockList[j])) { var name = MultiLanguage.Instance.GetTextValue(Research_Effect_Unlock_Text_Block); var element = content.GetChild(totalIndex); if (element != null) { totalIndex++; var cmpt = element.transform.SafeGetComponent <TechEffectElement>(); cmpt.SetUpElement(model.Icon, name, model.Name, Color.white); element.SafeSetActive(true); } } } break; case TechCompleteEffect.Unlock_Tech: var techList = TechnologyModule.ParseTechParam_Unlock_Tech(effectlist[i].effectParam); for (int j = 0; j < techList.Count; j++) { TechnologyDataModel model = new TechnologyDataModel(); if (model.Create(techList[j])) { var name = MultiLanguage.Instance.GetTextValue(Research_Effect_Unlock_Text_Tech); var element = content.GetChild(totalIndex); if (element != null) { totalIndex++; var cmpt = element.transform.SafeGetComponent <TechEffectElement>(); cmpt.SetUpElement(model.Icon, name, model.Name, model.Rarity.color); element.SafeSetActive(true); } } } break; } } }