/// <summary> /// 获取服务器上的一些数据 /// </summary> void GetServerInfo() { if (StaticData.playerInfoData.favorableData.Count <= 0)//如果本地没有数据就请求并记录本地 只请求一次 { //默认值(配置表里的数据) foreach (var item in StaticData.configExcel.HallRole) { if (!item.isImpulseRole) { continue; //如果不是心动时刻的角色就下一个 } Favorable favorable = new Favorable(); favorable.NPCId = item.ID; favorable.NpcSetPainting = item.SetPainting; favorable.headPortrait = item.HeadPortraitImage; favorableList.Add(favorable); } CSEmptyFavorableInfo cSEmptyFavorableInfo = new CSEmptyFavorableInfo(); //bool receive = false;等待返回 ProtocalManager.Instance().SendCSEmptyFavorableInfo(cSEmptyFavorableInfo, (SCFavorableInfo FavorableInfo) => { Init(FavorableInfo); StaticData.playerInfoData.favorableData = favorableList;//数据保存到本地 }, (ErrorInfo e) => { Debug.Log("请求失败"); }); //await UniTask.WaitUntil(()=>receive==true); } else { Debug.Log("本地已缓存好感数据"); favorableList = StaticData.playerInfoData.favorableData; impulesMainView.OpenView(favorableList); } //JoinViewRefreshGift(); }
/// <summary> /// 好感值存入缓存(外部初始化好感列表)章节用到 /// </summary> public static void CacheFavorable() { List <Favorable> favorableList = new List <Favorable>(); //好感列表赋初值 foreach (var item in StaticData.configExcel.HallRole) { if (!item.isImpulseRole) { continue; //如果不是心动时刻的角色就下一个 } Favorable favorable = new Favorable(); favorable.NPCId = item.ID; favorable.NpcSetPainting = item.SetPainting; favorable.headPortrait = item.HeadPortraitImage; favorableList.Add(favorable); } CSEmptyFavorableInfo cSEmptyFavorableInfo = new CSEmptyFavorableInfo(); ProtocalManager.Instance().SendCSEmptyFavorableInfo(cSEmptyFavorableInfo, (SCFavorableInfo FavorableInfo) => { if (FavorableInfo != null)//赋保存后的值 { foreach (var item in FavorableInfo.FavorableInfo) { for (int i = 0; i < favorableList.Count; i++) { if (item.HeroId != favorableList[i].NPCId) { continue; } favorableList[i].NPC2PlayerValue = item.HeroPlayerValue; favorableList[i].Player2NPCValue = item.PlayerHeroValue; favorableList[i].cardiacValue = favorableList[i].NPC2PlayerValue <= favorableList[i].Player2NPCValue ? favorableList[i].NPC2PlayerValue : favorableList[i].Player2NPCValue; } } } StaticData.playerInfoData.favorableData = favorableList;//数据保存到本地 Debug.Log("好感列表初始化成功"); }, (ErrorInfo e) => { Debug.LogError("请求初始化好感请求失败"); }); }
public void SendCSEmptyFavorableInfo(CSEmptyFavorableInfo csemptyfavorableinfo, Action <SCFavorableInfo> ResponseSCFavorableInfoCallBack, Action <ErrorInfo> errorCallBack, bool isShowDefaultTip = true) { OpCodeType opCodeType = ListOPRelation.GetOpCodeTypeByRequest <CSEmptyFavorableInfo> (); ProtoSendMethod.BusinessRequest <SCFavorableInfo>(csemptyfavorableinfo, opCodeType, ResponseSCFavorableInfoCallBack, errorCallBack, isShowDefaultTip); }