123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- 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<PartnersService>
- {
- #region 新接口
- /// <summary>
- /// 圣兵一键上阵
- /// </summary>
- public void RequestPartnerOneKeyUp()
- {
- NetModule.Request(new ShengbingWearAllRequest());
- }
- public void RequestPartnerOneKeyStarUp()
- {
- NetModule.Request(new ShengbingStrongAllRequest());
- }
- /// <summary>
- /// 圣兵上阵
- /// </summary>
- /// <param name="posId">槽位id 0开始</param>
- /// <param name="id">圣兵id</param>
- 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);
- }
- /// <summary>
- /// 下阵圣兵
- /// </summary>
- /// <param name="sbId"></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);
- }
- /// <summary>
- /// 更新拥有圣兵信息
- /// </summary>
- /// <param name="list"></param>
- public void UpdatePartnerMap(List<ActShengBingList> 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<ActShengBingList> 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);
- }
- }
- /// <summary>
- /// 获取星星的色阶
- /// </summary>
- /// <param name="starLv"></param>
- /// <returns></returns>
- public int GetStarStep(int starLevel)
- {
- return Mathf.FloorToInt((starLevel - 1) / PartnersData.MaxStarNum) + 1;
- }
- /// <summary>
- /// 获取升星当前级别星星等级
- /// </summary>
- /// <param name="starLv"></param>
- /// <returns></returns>
- public int GetStarLv(int starLv)
- {
- int starNum = starLv == 0 ? 0 : starLv % PartnersData.MaxStarNum;
- if (starLv > 0 && starNum == 0)
- starNum = PartnersData.MaxStarNum;
- return starNum;
- }
- #endregion
- }
- }
|