using System.Collections.Generic; using FL.Network; using UnityEngine; using XGame; using XGame.Database; using XGame.Framework.Data; using XGame.Framework.Network; namespace FL.Data { public class PartnersService : DataSingleton { #region 新接口 /// /// 圣兵一键上阵 /// public void RequestPartnerOneKeyUp() { NetModule.Request(new ShengbingWearAllRequest()); } public void RequestPartnerOneKeyStarUp() { NetModule.Request(new ShengbingStrongAllRequest()); } /// /// 圣兵上阵 /// /// 槽位id 0开始 /// 圣兵id public void RequestPartnerUpNew(int posId, int id) { var sbAttr = PartnersData.Instance.GetPartnerAttrByTableId(id); if (sbAttr == null) return; var param = new ShengbingNewWearRequest() { caoId = posId, sbId = id }; (param as IMessage).Context = sbAttr.UID; NetModule.Request(param); } /// /// 下阵圣兵 /// /// public void RequestPartnerDownNew(int sbId) { var sbAttr = PartnersData.Instance.GetPartnerAttrByTableId(sbId); var pos = PartnersData.Instance.UpSbPosMap.GetValueOrDefault(sbId, -1); var param = new ShengbingNewUnfixRequest() { caoId = pos }; (param as IMessage).Context = sbAttr.UID; NetModule.Request(param); } public void RequestStarUp(int sbId) { var param = new ShengbingUpStarRequest() { sbId = sbId }; NetModule.Request(param); } public void RequestLvUp(int sbId) { var param = new ShengbingUpLevelRequest() { sbId = sbId }; NetModule.Request(param); } public void RequestJibanRwdGet(int rwdId) { var param = new ShengbingUnlockJibanRequest() { jiban = rwdId }; NetModule.Request(param); } public void RequestJibanRwdGetAll(int collectId) { var param = new ShengbingUnlockJibanAllRequest() { collectId = collectId }; NetModule.Request(param); } public void OpenUpPartnerMode(int id) { PartnersData.Instance.UpModeSelect = id; EventSingle.Instance.Notify(EventDefine.PartnerOpenUpMode, id); } public void FinishUpPartnerMode() { PartnersData.Instance.UpModeSelect = 0; EventSingle.Instance.Notify(EventDefine.PartnerFinishUpMode); } /// /// 更新拥有圣兵信息 /// /// public void UpdatePartnerMap(List list) { foreach (var shengBing in list) { if ( PartnersData.Instance.TryGetPartnerAttrByTableId( shengBing.sbId, out var partnerInfo ) ) { var table = PartnerTableRepo.Get(shengBing.sbId); var skillId = PartnersData.Instance.GetSkillId(shengBing.star, table?.Skill); partnerInfo.Level = shengBing.level; partnerInfo.RisingStarLv = shengBing.star; partnerInfo.EpigraphId = shengBing.mingwen; partnerInfo.Status = shengBing.status; partnerInfo.SkillId = skillId; } else { var attr = PartnersData.Instance.CreatePartnerAttr( shengBing.sbId, shengBing.level, shengBing.star, shengBing.mingwen, shengBing.status ); PartnersData.Instance.AddPartnerAttr(attr); } } } public void InitPartnerMap(List list) { PartnersData.Instance.ClearPartnerMap(); foreach (var shengBing in list) { var attr = PartnersData.Instance.CreatePartnerAttr( shengBing.sbId, shengBing.level, shengBing.star, shengBing.mingwen, shengBing.status ); PartnersData.Instance.AddPartnerAttr(attr); } } /// /// 获取星星的色阶 /// /// /// public int GetStarStep(int starLevel) { return Mathf.FloorToInt((starLevel - 1) / PartnersData.MaxStarNum) + 1; } /// /// 获取升星当前级别星星等级 /// /// /// public int GetStarLv(int starLv) { int starNum = starLv == 0 ? 0 : starLv % PartnersData.MaxStarNum; if (starLv > 0 && starNum == 0) starNum = PartnersData.MaxStarNum; return starNum; } #endregion } }