| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | using UnityEngine; |
| | | |
| | | //武将相关界面的操作数据管理 |
| | | public class HeroUIManager : GameSystemManager<HeroUIManager> |
| | | public partial class HeroUIManager : GameSystemManager<HeroUIManager> |
| | | { |
| | | //武将列表界面 |
| | | public List<string> heroSortList { get; private set; } = new List<string>(); //上阵为主线的列表 |
| | | #region 武将列表界面 |
| | | public List<string> heroSortList { get; private set; } = new List<string>(); //上阵为主线的 GUID列表 |
| | | public int selectHeroListJob = 0; //武将列表界面 筛选职业 |
| | | public int selectHeroListCountry = 0; //武将列表界面筛选国家 |
| | | public string selectHeroGuid; //选中的武将id |
| | | #endregion |
| | | |
| | | public List<string> heroOnTeamSortList { get; private set; } = new List<string>(); //不同上阵的列表排序 |
| | | public WaitHeroFuncResponse waitResponse; //请求武将功能,与服务端交互 |
| | | |
| | | public TeamType selectTeamType = TeamType.Story; //当前选中的是哪个阵容, 布阵相关逻辑使用 |
| | | |
| | | public override void Init() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize; |
| | | HeroManager.Instance.onHeroChangeEvent += OnHeroChangeEvent; |
| | | ParseConfig(); |
| | | } |
| | | |
| | | public override void Release() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize; |
| | | HeroManager.Instance.onHeroChangeEvent -= OnHeroChangeEvent; |
| | | } |
| | | |
| | | void ParseConfig() |
| | | { |
| | | var config = FuncConfigConfig.Get("HeroRebirth"); |
| | | payBackMoneyType = int.Parse(config.Numerical1); |
| | | payBackMoney = int.Parse(config.Numerical2); |
| | | } |
| | | |
| | | public void OnBeforePlayerDataInitialize() |
| | | { |
| | | heroSortList.Clear(); |
| | | heroOnTeamSortList.Clear(); |
| | | awakeRebirthCnt = 0; |
| | | waitResponse = default; |
| | | heroCollectInfoDic.Clear(); |
| | | } |
| | | |
| | | public void OnPlayerLoginOk() |
| | | private void OnHeroChangeEvent(HeroInfo hero) |
| | | { |
| | | if (!DTC0403_tagPlayerLoginLoadOK.finishedLogin) |
| | | return; |
| | | WaitServerResponse(hero); |
| | | } |
| | | |
| | | public override void Init() |
| | | private void WaitServerResponse(HeroInfo hero) |
| | | { |
| | | if (waitResponse.Equals(default(WaitHeroFuncResponse))) |
| | | { |
| | | return; |
| | | } |
| | | // 等待超过5秒 不处理 |
| | | var nowTime = Time.time; |
| | | if (waitResponse.time > 0f && waitResponse.time + 5 < nowTime) |
| | | { |
| | | waitResponse = default; |
| | | return; |
| | | } |
| | | |
| | | if (hero.itemHero.guid != waitResponse.guid) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (waitResponse.type == HeroFuncType.Break) |
| | | { |
| | | UIManager.Instance.OpenWindow<HeroLVBreakSuccessWin>(); |
| | | } |
| | | |
| | | waitResponse = default; |
| | | |
| | | } |
| | | |
| | | public override void Release() |
| | | #region 武将UI常用接口 |
| | | public string GetCountryName(int index) |
| | | { |
| | | |
| | | return RichTextMsgReplaceConfig.GetRichReplace("Country", index); |
| | | } |
| | | |
| | | public bool waitResortHeroList = false; |
| | | public string GetJobName(int index) |
| | | { |
| | | return RichTextMsgReplaceConfig.GetRichReplace("Class", index); |
| | | } |
| | | |
| | | public string GetCountryIconName(int index) |
| | | { |
| | | return StringUtility.Contact("herocountry", index); |
| | | } |
| | | |
| | | public string GetJobIconName(int index) |
| | | { |
| | | return StringUtility.Contact("herojob", index); |
| | | } |
| | | |
| | | public int GetMaxLV(int quality) |
| | | { |
| | | return HeroQualityBreakConfig.maxlvDic[quality]; |
| | | } |
| | | |
| | | //是否达到最高级 |
| | | public bool IsLVMax(HeroInfo hero) |
| | | { |
| | | return hero.heroLevel >= GetMaxLV(hero.Quality); |
| | | |
| | | } |
| | | //突破限制的最高等级 |
| | | public int GetMaxLVByBreakLV(int quality, int breakLevel) |
| | | { |
| | | return HeroQualityBreakConfig.GetQualityBreakConfig(quality, breakLevel).LVMax; |
| | | } |
| | | |
| | | public bool IsLVMaxByBreakLevel(HeroInfo hero) |
| | | { |
| | | return hero.heroLevel == GetMaxLVByBreakLV(hero.Quality, hero.breakLevel); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | public void QueryUnLockHeroPack() |
| | | { |
| | | //解锁更多的武将背包 |
| | | int canBuyCnt = PackManager.Instance.GetCanBuyPackGirdCount(PackType.Hero); |
| | | if (canBuyCnt <= 0) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var buyInfo = PackManager.Instance.BuyPackGirdNeedData(PackType.Hero); |
| | | ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), |
| | | Language.Get("HeroPack1", UIHelper.GetIconNameWithMoneyType(buyInfo[0]), buyInfo[1], buyInfo[2]), |
| | | (bool isOK) => |
| | | { |
| | | if (isOK) |
| | | { |
| | | if (UIHelper.GetMoneyCnt(buyInfo[0]) < (ulong)buyInfo[1]) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("LackMoney", buyInfo[0]); |
| | | return; |
| | | } |
| | | PackManager.Instance.BuyPackGird(PackType.Hero); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //刷新时机, 打开武将界面 或者 关闭功能界面 |
| | | public void SortHeroList() |
| | | { |
| | | heroSortList = HeroManager.Instance.GetHeroGuidList(); |
| | | heroSortList = HeroManager.Instance.GetHeroGuidList(selectHeroListJob, selectHeroListCountry); |
| | | heroSortList.Sort(CmpHero); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public void SortHeroOnTeamList() |
| | | { |
| | | heroOnTeamSortList = HeroManager.Instance.GetHeroGuidList(); |
| | | heroOnTeamSortList.Sort(CmpHeroByTeamType); |
| | | } |
| | | |
| | | |
| | | |
| | | int CmpHeroByTeamType(string guidA, string guidB) |
| | | { |
| | | HeroInfo heroA = HeroManager.Instance.GetHero(guidA); |
| | | HeroInfo heroB = HeroManager.Instance.GetHero(guidB); |
| | | if (heroA == null || heroB == null) |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | } |
| | | |
| | | // 排序规则:上阵>武将等级>突破等级>武将觉醒阶级>武将品质>武将吞噬星级>武将ID |
| | | bool isInTeamA = heroA.IsInTeamByTeamType(selectTeamType); |
| | | bool isInTeamB = heroB.IsInTeamByTeamType(selectTeamType); |
| | | if (isInTeamA != isInTeamB) |
| | | { |
| | | return isInTeamA ? -1 : 1; |
| | | } |
| | | if (heroA.heroLevel != heroB.heroLevel) |
| | | { |
| | | return heroA.heroLevel > heroB.heroLevel ? -1 : 1; |
| | | } |
| | | if (heroA.breakLevel != heroB.breakLevel) |
| | | { |
| | | return heroA.breakLevel > heroB.breakLevel ? -1 : 1; |
| | | } |
| | | if (heroA.awakeLevel != heroB.awakeLevel) |
| | | { |
| | | return heroA.awakeLevel > heroB.awakeLevel ? -1 : 1; |
| | | } |
| | | if (heroA.Quality != heroB.Quality) |
| | | { |
| | | return heroA.Quality > heroB.Quality ? -1 : 1; |
| | | } |
| | | if (heroA.heroStar != heroA.heroStar) |
| | | { |
| | | return heroA.heroStar > heroB.heroStar ? -1 : 1; |
| | | } |
| | | public struct WaitHeroFuncResponse |
| | | { |
| | | public HeroFuncType type; |
| | | public string guid; |
| | | public float time; |
| | | } |
| | | |
| | | return heroA.heroId.CompareTo(heroB.heroId); |
| | | } |
| | | |
| | | |
| | | |
| | | public void QueryUnLockHeroPack() |
| | | { |
| | | //解锁更多的武将背包 |
| | | } |
| | | |
| | | //上阵队伍中各个国家的武将数量 |
| | | public Dictionary<HeroCountry, int> GetCountryHeroCountByTeamType(TeamType teamType) |
| | | { |
| | | Dictionary<HeroCountry, int> heroCountryCount = new Dictionary<HeroCountry, int>(); |
| | | |
| | | var team = TeamManager.Instance.GetTeam(teamType); |
| | | if (team != null) |
| | | { |
| | | for (int i = 0; i < team.serverHeroes.Length; i++) |
| | | { |
| | | var hero = HeroManager.Instance.GetHero(team.serverHeroes[i].guid); |
| | | if (hero != null) |
| | | { |
| | | if (!heroCountryCount.ContainsKey(hero.heroCountry)) |
| | | { |
| | | heroCountryCount.Add(hero.heroCountry, 1); |
| | | } |
| | | else |
| | | { |
| | | heroCountryCount[hero.heroCountry] += 1; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | return heroCountryCount; |
| | | } |
| | | |
| | | //获得上阵中武将数量最大的国家和数量 |
| | | public Int2 GetMaxCountHeroCountry(TeamType teamType) |
| | | { |
| | | var countryCount = GetCountryHeroCountByTeamType(teamType); |
| | | //找到最大的国家和数量 |
| | | HeroCountry country = HeroCountry.None; |
| | | int maxValue = 0; |
| | | foreach (var data in countryCount) |
| | | { |
| | | if (data.Value > maxValue) |
| | | { |
| | | country = data.Key; |
| | | maxValue = data.Value; |
| | | } |
| | | } |
| | | return new Int2((int)country, maxValue); |
| | | } |
| | | |
| | | //在不同页签下选AttackType 0 攻击阵容 1 防守阵容 |
| | | public int GetSelectTeamTypeByAttackType(int AttackType) |
| | | { |
| | | if (selectTeamType == TeamType.Arena || selectTeamType == TeamType.ArenaDefense) |
| | | { |
| | | return AttackType == 0 ? (int)TeamType.Arena : (int)TeamType.ArenaDefense; |
| | | } |
| | | |
| | | |
| | | return (int)TeamType.Story; |
| | | } |
| | | //武将功能类型 |
| | | public enum HeroFuncType |
| | | { |
| | | None = 0, //无功能 |
| | | Break = 1, //突破 |
| | | |
| | | } |