private void OpenSelectView(ESelectViewState state) { // 培养仓为空。先判断是否有满足当前条件的本命英雄。若有,则跳转本命英雄选择界面,否则弹窗提示 ActorHeroInfo info = LogicDataCenter.playerSystemDataManager.GetActorAllHero(); if (info == null || info.dicEntityHeroInfo == null) { return; } List <int> heroIDList = LogicDataCenter.lifeHeroDataManager.FindCandidatesFromHistoryRecord(); if (heroIDList != null && heroIDList.Count > 0) { List <cmd_entity_hero_info> candidates = new List <cmd_entity_hero_info>(); foreach (int heroID in heroIDList) { cmd_entity_hero_info hero; if (info.dicEntityHeroInfo.TryGetValue(heroID, out hero)) { candidates.Add(hero); } else { Debug.LogWarning("在玩家拥有的英雄中未找到该英雄ID=" + heroID); } } ULifeHeroCandidateData msgData = new ULifeHeroCandidateData(); msgData.msgID = (int)WndID.WND_ID_LIFE_HERO_SELECT; msgData.candidates = candidates; msgData.cultureID = mCurrentSelectCultureID; msgData.state = state; if (state == ESelectViewState.REPLACE) { msgData.heroID = m_hasHeroCulture[mCurrentSelectCultureID]; } UISystem.Instance.SendTargetWndMessage(WndID.WND_ID_LIFE_HERO_SELECT, WndMsgID.WND_MSG_OPEN_LIFEHERO_SELECT, msgData); } else { SSchemeLifeHero config; int heroCount = LogicDataCenter.lifeHeroDataManager.AllLifeHero.Count; int key = state == ESelectViewState.INJECT ? heroCount : heroCount - 1; key = key < 0 ? 0 : key; if (LifeHeroConfig.Instance.LifeHeroConfigDic.TryGetValue(key, out config)) { string content = ULocalizationService.Instance.Get("UIView", "LifeHeroSelect", "TravelContent_NoLifeHero"); ShowDialog(ULocalizationService.Instance.Get("UIView", "LifeHeroSelect", "TravelTitle"), String.Format(content, config.rule), new UIWidgets.DialogActions() { { ULocalizationService.Instance.Get("UIView", "LifeHeroSelect", "Confirm"), GoToBattle }, { ULocalizationService.Instance.Get("UIView", "LifeHeroSelect", "Cancel"), null } }); } else { Debug.LogError("获取本命配置失败.key = " + key); } } }
private void SwitchState(ESelectViewState state) { if (state == m_currentState) { return; } EnterState(state); m_currentState = state; }
private void EnterState(ESelectViewState state) { if (m_currentState == state) { return; } switch (state) { case ESelectViewState.INJECT: { consumeFrame.gameObject.SetActive(false); RectTransform rf = this.gameObject.GetComponent <RectTransform>(); rf.sizeDelta = new Vector2(670, rf.sizeDelta.y); } break; case ESelectViewState.REPLACE: { int lifeHeroCount = LogicDataCenter.lifeHeroDataManager.AllLifeHero.Count; if (lifeHeroCount != (int)ELifeHeroType.LIFEHERO_MAX_COUNT) { Debug.LogFormat("本命英雄未收集满,不能替换"); return; } consumeFrame.gameObject.SetActive(true); RectTransform rf = this.gameObject.GetComponent <RectTransform>(); rf.sizeDelta = new Vector2(832, rf.sizeDelta.y); consumeFrame.SetData(-1); } break; default: break; } }