备份CatanBuilding瘦身独立工程
This commit is contained in:
905
Assets/Scripts/Services/ClubService.cs
Normal file
905
Assets/Scripts/Services/ClubService.cs
Normal file
@@ -0,0 +1,905 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class ClubStateChangeEvent
|
||||
{
|
||||
public int state;
|
||||
public bool joinClub;
|
||||
}
|
||||
public class ClubSttingUpdateEvent
|
||||
{
|
||||
}
|
||||
public class GetClubPlayInfoEvent
|
||||
{
|
||||
public string id;
|
||||
public string name;
|
||||
public string avatarUrl;
|
||||
}
|
||||
public class LureDonateData
|
||||
{
|
||||
public DateTime DonateCountTime { get; set; }
|
||||
public int ClubLureDonateCount { get; set; }//时间加次数
|
||||
public DateTime ClubLureRequestCDEnd { get; set; }
|
||||
}
|
||||
public class ClubService //: IClubService
|
||||
{
|
||||
[Inject]
|
||||
public IUserService userService { get; set; }
|
||||
[Inject]
|
||||
public ICustomServerMgr customServerMgr { get; set; }
|
||||
[Inject]
|
||||
public IChatService chatService { get; set; }
|
||||
public bool IsOpenClubJoined = false;
|
||||
public bool IsOpenClubRed = true;
|
||||
|
||||
public int socialTipforUnlocked;
|
||||
public ClubInfo myClubInfo { get; private set; }
|
||||
//public bool isAdm { get; private set; }
|
||||
public EMemberRole memberRole { get; private set; } = EMemberRole.Member;
|
||||
public DateTime? signTime { get; private set; }
|
||||
|
||||
LureDonateData lureDonateData;
|
||||
public int ClubLureDonateCount => lureDonateData.ClubLureDonateCount;
|
||||
public DateTime ClubLureRequestCDEnd => lureDonateData.ClubLureRequestCDEnd;
|
||||
|
||||
public Dictionary<long, string> internalIdToPlayerId = new Dictionary<long, string>();
|
||||
public ClubItemData ClubItemData;
|
||||
public List<SocialInfoItemData> clubPlayerInfos { get; private set; }
|
||||
public List<EventPopupData> eventPopupDatas { get; private set; } = new List<EventPopupData>();
|
||||
public EventPopupData eventPopupDataClub { get; private set; }
|
||||
public int OpenPanelType = 0;
|
||||
|
||||
public async void OpenFishingSocialPanel(int type)
|
||||
{
|
||||
OpenPanelType = type;
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingSocialPanel);
|
||||
OpenPanelType = 0;
|
||||
}
|
||||
|
||||
public bool CanAccepted
|
||||
{
|
||||
get
|
||||
{
|
||||
return memberRole == EMemberRole.Owner
|
||||
|| memberRole == EMemberRole.Vice
|
||||
|| memberRole == EMemberRole.Elder;
|
||||
}
|
||||
}
|
||||
public bool ApplyState { get; private set; }
|
||||
public bool CanSetting
|
||||
{
|
||||
get
|
||||
{
|
||||
return memberRole == EMemberRole.Owner || memberRole == EMemberRole.Vice;
|
||||
}
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
if (lureDonateData == null)
|
||||
{
|
||||
lureDonateData = new LureDonateData();
|
||||
lureDonateData.DonateCountTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
lureDonateData.ClubLureDonateCount = 0;
|
||||
lureDonateData.ClubLureRequestCDEnd = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
}
|
||||
if (IsOpenClubJoined)
|
||||
{
|
||||
SetClubRed();
|
||||
}
|
||||
}
|
||||
void SetClubRed()
|
||||
{
|
||||
if (myClubInfo == null)
|
||||
{
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Club, IsOpenClubRed);
|
||||
}
|
||||
else
|
||||
{
|
||||
var timer = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
bool isSign = signTime?.DayOfYear != timer.DayOfYear;
|
||||
bool isCanLure = lureDonateData != null && lureDonateData.ClubLureRequestCDEnd <= timer;
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Club, isCanLure || isSign);
|
||||
}
|
||||
}
|
||||
public void SetLureDonateData(string value)
|
||||
{
|
||||
lureDonateData = Newtonsoft.Json.JsonConvert.DeserializeObject<LureDonateData>(value);
|
||||
}
|
||||
void SaveLureDonateData()
|
||||
{
|
||||
PlayFabMgr.Instance.UpdateUserDataValue("LureDonateData", Newtonsoft.Json.JsonConvert.SerializeObject(lureDonateData));
|
||||
}
|
||||
//刷新体力求助次数
|
||||
public void RefreshLureDonate()
|
||||
{
|
||||
if (lureDonateData.DonateCountTime.Date != ZZTimeHelper.UtcNow().UtcNowOffset().Date)
|
||||
{
|
||||
lureDonateData.DonateCountTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
lureDonateData.ClubLureDonateCount = 0;
|
||||
SaveLureDonateData();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetOpenClubRed()
|
||||
{
|
||||
if (IsOpenClubRed)
|
||||
{
|
||||
IsOpenClubRed = false;
|
||||
SetClubRed();
|
||||
PlayFabMgr.Instance.UpdateUserDataValue("IsOpenClubRed", "1");
|
||||
}
|
||||
}
|
||||
public bool IsClubJoined()
|
||||
{
|
||||
return myClubInfo != null;
|
||||
}
|
||||
public void SetClubSignin(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
signTime = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
signTime = DateTime.Parse(value);
|
||||
}
|
||||
}
|
||||
public async void GetSelfClub()
|
||||
{
|
||||
GetSelfClubRequest getSelfClubRequest = new GetSelfClubRequest()
|
||||
{
|
||||
playerId = userService.UserId,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("GetSelfClub", getSelfClubRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
GetSelfClubResp getSelfClubResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetSelfClubResp>(json);
|
||||
myClubInfo = getSelfClubResp.clubInfo;
|
||||
if (myClubInfo != null)
|
||||
{
|
||||
memberRole = getSelfClubResp.role;
|
||||
//signTime = getSelfClubResp.signTime;
|
||||
internalIdToPlayerId = getSelfClubResp.playerIDs;
|
||||
SetClubPlayerProfile(getSelfClubResp.clubPlayerProfiles);
|
||||
chatService.GetConversationList((long)myClubInfo.id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memberRole = EMemberRole.Member;
|
||||
myClubInfo = null;
|
||||
}
|
||||
SetClubRed();
|
||||
MyClubInfoChange();
|
||||
}
|
||||
void MyClubInfoChange(bool joinClub = false)
|
||||
{
|
||||
GContext.Publish(new ClubStateChangeEvent() { state = 0, joinClub = joinClub });
|
||||
}
|
||||
public async Task<int> GetOnlineUsers()
|
||||
{
|
||||
HashSet<long> longs = await chatService.GetOnlineUsers(internalIdToPlayerId.Keys.ToList());
|
||||
return longs == null ? 0 : longs.Count;
|
||||
}
|
||||
public async Task<List<ClubInfo>> GetClubs(string clubName)
|
||||
{
|
||||
GetClubsRequest getClubsRequest = new GetClubsRequest()
|
||||
{
|
||||
clubName = clubName,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("GetClubs", getClubsRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
GetClubsResp clubDatas = Newtonsoft.Json.JsonConvert.DeserializeObject<GetClubsResp>(json);
|
||||
return clubDatas.clubInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<SocialInfoItemData>> GetClubDetails(ulong clubID, bool applyState = false)
|
||||
{
|
||||
ApplyState = false;
|
||||
GetClubDetailsRequest getClubDetailsRequest = new GetClubDetailsRequest()
|
||||
{
|
||||
id = clubID,
|
||||
playerId = userService.UserId,
|
||||
applyState = applyState,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("GetClubDetails", getClubDetailsRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
GetClubDetailsResp clubDetails = Newtonsoft.Json.JsonConvert.DeserializeObject<GetClubDetailsResp>(json);
|
||||
if (clubDetails.playerIDs == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<SocialInfoItemData> clubPlayerInfos = new List<SocialInfoItemData>();
|
||||
if (myClubInfo != null && clubID == myClubInfo.id)
|
||||
{
|
||||
internalIdToPlayerId = clubDetails.playerIDs;
|
||||
//internalIds = clubDetails.internalIds;
|
||||
}
|
||||
List<long> longs1 = clubDetails.playerIDs.Keys.ToList();
|
||||
HashSet<long> longs = await chatService.GetOnlineUsers(longs1);
|
||||
List<ClubPlayerProfile> clubPlayerProfiles = clubDetails.clubPlayerProfiles;
|
||||
SetClubPlayerProfile(clubPlayerProfiles);
|
||||
|
||||
for (int i = 0; i < clubPlayerProfiles.Count; i++)
|
||||
{
|
||||
ClubPlayerProfile clubPlayerProfile = clubPlayerProfiles[i];
|
||||
SocialInfoItemData clubPlayerInfo = new SocialInfoItemData();
|
||||
clubPlayerInfo.playFabId = clubPlayerProfile.playerId;
|
||||
userService.GetPlayInfo(clubPlayerInfo.playFabId);
|
||||
clubPlayerInfo.lv = userService.GetPlayerLv(clubPlayerInfo.playFabId);
|
||||
//clubPlayerInfo.rank = i + 1;
|
||||
clubPlayerInfo.isOnline = longs.Contains(clubPlayerProfile.internalId);
|
||||
clubPlayerInfo.role = clubPlayerProfile.role;
|
||||
|
||||
if (clubPlayerProfile.lastLoginTime != null)
|
||||
{
|
||||
clubPlayerInfo.lastLoginTime = (DateTime)clubPlayerProfile.lastLoginTime;
|
||||
}
|
||||
clubPlayerInfos.Add(clubPlayerInfo);
|
||||
}
|
||||
|
||||
clubPlayerInfos.Sort((x, y) =>
|
||||
{
|
||||
//if (y.isOnline != x.isOnline)
|
||||
//{
|
||||
// return y.isOnline.CompareTo(x.isOnline);
|
||||
//}
|
||||
//else
|
||||
{
|
||||
return y.lv.CompareTo(x.lv);
|
||||
}
|
||||
});
|
||||
ApplyState = clubDetails.applyState;
|
||||
return clubPlayerInfos;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<ClubInfo> CreateClub(ClubSettingData clubSettingData)
|
||||
{
|
||||
CreateClubRequest createClubRequest = new CreateClubRequest()
|
||||
{
|
||||
playerId = userService.UserId,
|
||||
//entityKey = userService.entityKey.Id,
|
||||
clubSettingData = clubSettingData,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("CreateClub", createClubRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
CreateClubResp createClubResp = Newtonsoft.Json.JsonConvert.DeserializeObject<CreateClubResp>(json);
|
||||
if (createClubResp.code != 2)
|
||||
{
|
||||
if (createClubResp.code == 0)
|
||||
{
|
||||
memberRole = EMemberRole.Owner;
|
||||
ShowPromote();
|
||||
}
|
||||
myClubInfo = createClubResp.clubInfo;
|
||||
chatService.GetConversationList((long)myClubInfo.id);
|
||||
internalIdToPlayerId[userService.InternalId] = userService.UserId;
|
||||
MyClubInfoChange(true);
|
||||
return myClubInfo;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myClubInfo = null;
|
||||
}
|
||||
MyClubInfoChange();
|
||||
return myClubInfo;
|
||||
}
|
||||
public async void ShowPromote()
|
||||
{
|
||||
GameObject go = await UIManager.Instance.ShowUI(UITypes.ClubPromoteNoticePopupPanel);
|
||||
var ClubPromoteNoticePopupPanel = go.GetComponent<ClubPromoteNoticePopupPanel>();
|
||||
ClubPromoteNoticePopupPanel.SetRole(memberRole);
|
||||
}
|
||||
public async Task<bool> UpdateClub(ClubSettingData clubSettingData)
|
||||
{
|
||||
UpdateClubRequest updateClubRequest = new UpdateClubRequest()
|
||||
{
|
||||
id = myClubInfo.id,
|
||||
clubSettingData = clubSettingData,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("UpdateClub", updateClubRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
UpdateClubResp createClubResp = Newtonsoft.Json.JsonConvert.DeserializeObject<UpdateClubResp>(json);
|
||||
if (createClubResp.code == 0)
|
||||
{
|
||||
myClubInfo.clubSettingData = clubSettingData;
|
||||
GContext.Publish(new ClubSttingUpdateEvent());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<bool> ApplyClub(ulong clubID)
|
||||
{
|
||||
memberRole = EMemberRole.Member;
|
||||
ApplyClubRequest applyClubRequest = new ApplyClubRequest()
|
||||
{
|
||||
playerId = userService.UserId,
|
||||
//entityKey = userService.entityKey.Id,
|
||||
id = clubID,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("ApplyClub", applyClubRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
ApplyClubResp applyClubResp = Newtonsoft.Json.JsonConvert.DeserializeObject<ApplyClubResp>(json);
|
||||
if (applyClubResp.code == 0)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_41"));
|
||||
myClubInfo = applyClubResp.clubInfo;
|
||||
internalIdToPlayerId = applyClubResp.playerIDs;
|
||||
SetClubPlayerProfile(applyClubResp.clubPlayerProfiles);
|
||||
//internalIds = applyClubResp.internalIds;
|
||||
chatService.GetConversationList((long)myClubInfo.id);
|
||||
MyClubInfoChange(true);
|
||||
return true;
|
||||
}
|
||||
else if (applyClubResp.code == 1)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_44"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_45"));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async void HandleApply(bool isAgree, string applyId)
|
||||
{
|
||||
if (isAgree && myClubInfo.curMembers >= myClubInfo.maxMembers)
|
||||
{
|
||||
//人数已满
|
||||
return;
|
||||
}
|
||||
HandleApplyRequest handleApplyRequest = new HandleApplyRequest()
|
||||
{
|
||||
playerId = applyId,
|
||||
//entityKey = entityID,
|
||||
isAgree = isAgree,
|
||||
id = myClubInfo.id,
|
||||
};
|
||||
if (applyId == "")
|
||||
{
|
||||
clubPlayerInfos.Clear();
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.ApplyList, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < clubPlayerInfos.Count; i++)
|
||||
{
|
||||
if (clubPlayerInfos[i].playFabId == applyId)
|
||||
{
|
||||
clubPlayerInfos.RemoveAt(i);
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.ApplyList, clubPlayerInfos.Count > 0
|
||||
&& CanAccepted);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
string json = await customServerMgr.ClubRequest("HandleApply", handleApplyRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
HandleApplyResp handleApplyResp = Newtonsoft.Json.JsonConvert.DeserializeObject<HandleApplyResp>(json);
|
||||
if (handleApplyResp.code == 0)
|
||||
{
|
||||
myClubInfo.curMembers++;
|
||||
GContext.Publish(new ClubSttingUpdateEvent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async void GetApplyList()
|
||||
{
|
||||
clubPlayerInfos = new List<SocialInfoItemData>();
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.ApplyList, false);
|
||||
GetApplyListRequest getApplyListRequest = new GetApplyListRequest()
|
||||
{
|
||||
playerId = userService.UserId,
|
||||
id = myClubInfo.id,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("GetApplyList", getApplyListRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
GetApplyListResp getApplyListResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetApplyListResp>(json);
|
||||
SetClubPlayerProfile(getApplyListResp.clubPlayerProfiles);
|
||||
for (int i = 0; i < getApplyListResp.userIDList.Count; i++)
|
||||
{
|
||||
SocialInfoItemData clubPlayerInfo = new SocialInfoItemData();
|
||||
//clubPlayerInfo.rank = i + 1;
|
||||
//clubPlayerInfo.entityKey = getApplyListResp.entityKeys[i];
|
||||
clubPlayerInfo.playFabId = getApplyListResp.userIDList[i];
|
||||
userService.GetPlayInfo(clubPlayerInfo.playFabId);
|
||||
clubPlayerInfo.lv = userService.GetPlayerLv(clubPlayerInfo.playFabId);
|
||||
clubPlayerInfos.Add(clubPlayerInfo);
|
||||
}
|
||||
clubPlayerInfos.Sort((x, y) => y.lv.CompareTo(x.lv));
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.ApplyList, clubPlayerInfos.Count > 0 && CanAccepted);
|
||||
}
|
||||
}
|
||||
void SetClubPlayerProfile(List<ClubPlayerProfile> clubPlayerProfiles)
|
||||
{
|
||||
if (clubPlayerProfiles == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var item in clubPlayerProfiles)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.displayName) || !string.IsNullOrEmpty(item.avatar))
|
||||
{
|
||||
userService.SetPlayInfo(item.playerId, item.displayName, item.avatar);
|
||||
userService.SetPlayerLv(item.playerId, item.level);
|
||||
}
|
||||
}
|
||||
}
|
||||
public async void QuitClub(string appointId = "0")
|
||||
{
|
||||
QuitClubRequest quitClubRequest = new QuitClubRequest()
|
||||
{
|
||||
playerId = userService.UserId,
|
||||
appointId = appointId,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("QuitClub", quitClubRequest);
|
||||
//if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
//{
|
||||
// QuitClubResp quitClubResp = Newtonsoft.Json.JsonConvert.DeserializeObject<QuitClubResp>(json);
|
||||
//}
|
||||
chatService.OnQuit();
|
||||
myClubInfo = null;
|
||||
ClearLikeCursorIds();
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_46"));
|
||||
MyClubInfoChange();
|
||||
}
|
||||
public async void Demote(string playerId)
|
||||
{
|
||||
DemoteClubRequest demoteClubRequest = new DemoteClubRequest()
|
||||
{
|
||||
culbId = myClubInfo.id,
|
||||
demoteId = playerId,
|
||||
playerId = userService.UserId,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("DemoteClub", demoteClubRequest);
|
||||
}
|
||||
public async void Promote(string playerId, EMemberRole role)
|
||||
{
|
||||
PromoteClubRequest promoteClubRequest = new PromoteClubRequest()
|
||||
{
|
||||
culbId = myClubInfo.id,
|
||||
promoteId = playerId,
|
||||
playerId = userService.UserId,
|
||||
role = role,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("PromoteClub", promoteClubRequest);
|
||||
}
|
||||
public async void Kickout(string playerId)
|
||||
{
|
||||
KickoutClubRequest kickoutClubRequest = new KickoutClubRequest()
|
||||
{
|
||||
culbId = myClubInfo.id,
|
||||
kickoutId = playerId,
|
||||
playerId = userService.UserId,
|
||||
};
|
||||
myClubInfo.curMembers--;
|
||||
GContext.Publish(new ClubSttingUpdateEvent());
|
||||
string json = await customServerMgr.ClubRequest("KickoutClub", kickoutClubRequest);
|
||||
//if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
//{
|
||||
// KickoutClubResp quitClubResp = Newtonsoft.Json.JsonConvert.DeserializeObject<KickoutClubResp>(json);
|
||||
//}
|
||||
}
|
||||
public async void ReadClubEvent()
|
||||
{
|
||||
ReadClubEventRequest readClubEventRequest = new ReadClubEventRequest()
|
||||
{
|
||||
playerId = userService.UserId,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("ReadClubEvent", readClubEventRequest);
|
||||
//if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
//{
|
||||
// ReadClubEventResp readClubEventResp = Newtonsoft.Json.JsonConvert.DeserializeObject<ReadClubEventResp>(json);
|
||||
//}
|
||||
}
|
||||
public async void ClubSingin()
|
||||
{
|
||||
signTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
ClubSinginRequest clubSinginRequest = new ClubSinginRequest()
|
||||
{
|
||||
playerId = userService.UserId,
|
||||
id = myClubInfo.id,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("ClubSingin", clubSinginRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
ClubSinginResp clubSinginResp = Newtonsoft.Json.JsonConvert.DeserializeObject<ClubSinginResp>(json);
|
||||
signTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
PlayFabMgr.Instance.UpdateUserDataValue("ClubSignin", signTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
if (clubSinginResp.code == 0)
|
||||
{
|
||||
chatService.SendSystemMessage($"{MessageChatType.SI}_{userService.UserId}");
|
||||
//签到成功奖励
|
||||
GContext.container.Resolve<PlayerItemData>().AddItemByDrop(GContext.container.Resolve<cfg.Tables>().TbGlobalConfig.ClubSignReward);
|
||||
GContext.Publish(new ShowData());
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("guild_sign"))
|
||||
{
|
||||
e.AddContent("guild_id", myClubInfo.id)
|
||||
.AddContent("drop_list", GContext.container.Resolve<cfg.Tables>().TbGlobalConfig.ClubSignReward);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
SetClubRed();
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> SendGetPhoto(int pictureID)
|
||||
{
|
||||
if (GContext.container.Resolve<AlbumData>().GetPhotoRequestCountByDay(pictureID) > 0)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_43"));
|
||||
return false;
|
||||
}
|
||||
//messageID
|
||||
long messageID = await chatService.SendGetPhotoMessage(pictureID.ToString());
|
||||
if (messageID > 0)
|
||||
{
|
||||
//记录今日请求pictureID
|
||||
GContext.container.Resolve<AlbumData>().SetPhotoRequestCountByDay(pictureID);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SendSystemMessage2(int index)
|
||||
{
|
||||
chatService.SendSystemMessage2($"{userService.UserId}_{index}");
|
||||
}
|
||||
public async Task<string> SendDonatePhoto(string playerId, long cursorId, int pictureID)
|
||||
{
|
||||
ClubDonateRequest clubDonateRequest = new ClubDonateRequest()
|
||||
{
|
||||
donateId = userService.UserId,
|
||||
cursorId = cursorId,
|
||||
playerId = playerId,
|
||||
pictureID = pictureID,
|
||||
id = myClubInfo.id,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("DonatePhoto", clubDonateRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
ClubDonateResp clubDonateResp = Newtonsoft.Json.JsonConvert.DeserializeObject<ClubDonateResp>(json);
|
||||
if (clubDonateResp.code == 0)
|
||||
{
|
||||
//减去一个照片
|
||||
GContext.container.Resolve<AlbumData>().RemovePictureProgress(pictureID, 1);
|
||||
int gold = GContext.container.Resolve<cfg.Tables>().TbGlobalConfig.ClubDonationCashReward;
|
||||
GContext.container.Resolve<PlayerData>().AddGold((ulong)gold);
|
||||
GContext.Publish(new ShowData(new ItemData() { count = gold, id = 1002 }));
|
||||
|
||||
GContext.Publish(new ShowData());
|
||||
return clubDonateResp.donateId;
|
||||
}
|
||||
else
|
||||
{
|
||||
return clubDonateResp.donateId;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public async Task<string> GetPhotoState(string playerId, long cursorId)
|
||||
{
|
||||
GetDonateStatusRequest DonateStatusRequest = new GetDonateStatusRequest()
|
||||
{
|
||||
//playerId = playerId,
|
||||
cursorId = cursorId,
|
||||
id = myClubInfo.id,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("GetDonateStatus", DonateStatusRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
GetDonateStatusResp clubSinginResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDonateStatusResp>(json);
|
||||
return clubSinginResp.donateId;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取被赠送的照片 以及其他事件
|
||||
/// </summary>
|
||||
///
|
||||
int energyAddCount = 0;
|
||||
public int GetEnergyAddCount()
|
||||
{
|
||||
int count = energyAddCount;
|
||||
energyAddCount = 0;
|
||||
return count;
|
||||
}
|
||||
public async void GetServiceEvent()
|
||||
{
|
||||
energyAddCount = 0;
|
||||
GetPictureRequest getPictureRequest = new GetPictureRequest()
|
||||
{
|
||||
playerId = userService.UserId,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("GetPictureList", getPictureRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
GetPictureResp getPictureResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetPictureResp>(json);
|
||||
//var pictureDatas = getPictureResp.pictureDataList;
|
||||
//if (pictureDatas != null && pictureDatas.Count > 0)
|
||||
//{
|
||||
// List<int> pictureIDs = new List<int>();
|
||||
// foreach (var pictureData in pictureDatas)
|
||||
// {
|
||||
// pictureIDs.Add(pictureData.pictureID);
|
||||
// }
|
||||
// GContext.container.Resolve<AlbumData>().AddPictureProgress(pictureIDs);
|
||||
//}
|
||||
eventPopupDatas = getPictureResp.eventPopupDatas;
|
||||
if (eventPopupDatas != null && eventPopupDatas.Count > 0)
|
||||
{
|
||||
IReportService reportService = GContext.container.Resolve<IReportService>();
|
||||
var playerData = GContext.container.Resolve<PlayerData>();
|
||||
var tables = GContext.container.Resolve<Tables>();
|
||||
//CampData campData = GContext.container.Resolve<CampData>();
|
||||
foreach (var eventPopupData in eventPopupDatas)
|
||||
{
|
||||
if (eventPopupData.type == ReportDataType.Heist)
|
||||
{
|
||||
long content = long.Parse(eventPopupData.content);
|
||||
if (content < 0)
|
||||
{
|
||||
content = -content;
|
||||
}
|
||||
//=====新规则=====
|
||||
long newContent = content / 100;
|
||||
long rangeT = content % 100;
|
||||
float range = Mathf.Clamp(rangeT, 5, 15) * 0.1f;
|
||||
|
||||
|
||||
int m = Mathf.Min(tables.TbGlobalConfig.BottleCashParamLimit, (int)newContent);
|
||||
float mg = (1 + playerData.benefitsCashMag) * (1 + playerData.benefitsCashMagLimited);
|
||||
m = Mathf.RoundToInt(m * mg * range);
|
||||
|
||||
//=====新规则=====
|
||||
eventPopupData.content = m.ToString();
|
||||
}
|
||||
|
||||
if (eventPopupData.IsRead == false)
|
||||
{
|
||||
if (eventPopupData.type == ReportDataType.Energy)
|
||||
{
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("guild_request_lures_reward"))
|
||||
{
|
||||
e.AddContent("donate_userid_list", eventPopupData.content)
|
||||
.AddContent("reward_hook", GContext.container.Resolve<cfg.Tables>().TbGlobalConfig.ClubLureDonateReward);
|
||||
if (myClubInfo != null)
|
||||
{
|
||||
e.AddContent("guild_id", myClubInfo.id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//事件弹窗
|
||||
//添加体力
|
||||
playerData.SetEnergy(playerData.Energy + GContext.container.Resolve<cfg.Tables>().TbGlobalConfig.ClubLureDonateReward);
|
||||
energyAddCount++;
|
||||
}
|
||||
else if (eventPopupData.type == ReportDataType.Club)
|
||||
{
|
||||
//工会事件,只在工会界面调用,弹窗展示之后才设置为已读
|
||||
eventPopupDataClub = eventPopupData;
|
||||
}
|
||||
else if (eventPopupData.type == ReportDataType.Aquarium)
|
||||
{
|
||||
reportService.AddReport(new ReportData()
|
||||
{
|
||||
type = eventPopupData.type,
|
||||
id = eventPopupData.redirectID,
|
||||
playFabId = eventPopupData.playerID,
|
||||
content = eventPopupData.content,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
//可能扣钱
|
||||
if (eventPopupData.type == ReportDataType.Heist && playerData.gold > 0)
|
||||
{
|
||||
int content = int.Parse(eventPopupData.content);
|
||||
|
||||
reportService.AddReport(new ReportData()
|
||||
{
|
||||
type = eventPopupData.type,
|
||||
id = eventPopupData.redirectID,
|
||||
playFabId = eventPopupData.playerID,
|
||||
content = eventPopupData.content,
|
||||
});
|
||||
|
||||
ulong gold = (ulong)content;
|
||||
if (gold >= playerData.gold)
|
||||
{
|
||||
playerData.SetGold(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerData.SetGold(playerData.gold - gold);
|
||||
}
|
||||
}
|
||||
else if (eventPopupData.type == ReportDataType.Bomb)
|
||||
{
|
||||
reportService.AddReport(new ReportData()
|
||||
{
|
||||
type = eventPopupData.type,
|
||||
id = eventPopupData.redirectID,
|
||||
playFabId = eventPopupData.playerID,
|
||||
content = eventPopupData.content,
|
||||
});
|
||||
GContext.container.Resolve<CampDataMM>().SetIsFix(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (energyAddCount > 0)
|
||||
{
|
||||
GContext.container.Resolve<IFaceUIService>().AddFaceCustomUIData(UITypes.EventReportPopupPanel, true);
|
||||
}
|
||||
CurRewardQCount curRewardQCount = new CurRewardQCount();
|
||||
GContext.Publish(curRewardQCount);
|
||||
int faceCount = GContext.container.Resolve<IFaceUIService>().GetFaceUICount();
|
||||
if (curRewardQCount.count <= 0 && faceCount <= 0)
|
||||
{
|
||||
ShowHomeReport();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void ShowHomeReport()
|
||||
{
|
||||
ReportData reportData = GContext.container.Resolve<IReportService>().GetReportData();
|
||||
if (reportData != null)
|
||||
{
|
||||
GContext.Publish(reportData);
|
||||
}
|
||||
}
|
||||
//消息点赞相关
|
||||
List<long> LikeCursorIds;
|
||||
string LikeCursorIdsKey = "LikeCursorIds";
|
||||
void ClearLikeCursorIds()
|
||||
{
|
||||
LikeCursorIds = null;
|
||||
PlayerPrefs.DeleteKey(LikeCursorIdsKey);
|
||||
}
|
||||
public async void SendLike(long cursorId)
|
||||
{
|
||||
ClubLikeRequest clubLikeRequest = new ClubLikeRequest()
|
||||
{
|
||||
cursorId = cursorId,
|
||||
id = myClubInfo.id,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("ClubLike", clubLikeRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
ClubLikeResp clubSinginResp = Newtonsoft.Json.JsonConvert.DeserializeObject<ClubLikeResp>(json);
|
||||
LikeCursorIds.Add(cursorId);
|
||||
PlayerPrefs.SetString(LikeCursorIdsKey, Newtonsoft.Json.JsonConvert.SerializeObject(LikeCursorIds));
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<(bool, int)> GetLikeCount(long cursorId)
|
||||
{
|
||||
GetLikeCountRequest LikeCountRequest = new GetLikeCountRequest()
|
||||
{
|
||||
cursorId = cursorId,
|
||||
id = myClubInfo.id,
|
||||
};
|
||||
LikeCursorIds = Newtonsoft.Json.JsonConvert.DeserializeObject<List<long>>(PlayerPrefs.GetString(LikeCursorIdsKey, "[]"));
|
||||
bool isLike = LikeCursorIds.Contains(cursorId);
|
||||
int count = 0;
|
||||
if (isLike)
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
string json = await customServerMgr.ClubRequest("GetLikeCount", LikeCountRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
GetLikeCountResp clubSinginResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetLikeCountResp>(json);
|
||||
count = clubSinginResp.count;
|
||||
}
|
||||
return (isLike, count);
|
||||
}
|
||||
//体力求助相关
|
||||
//聊天消息
|
||||
public async Task<bool> SendHelpEnergy()
|
||||
{
|
||||
//messageID
|
||||
long messageID = await chatService.SendHelpEnergyMessage(1001);
|
||||
if (messageID > 0)
|
||||
{
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("guild_request_lures"))
|
||||
{
|
||||
e.AddContent("guild_id", myClubInfo.id);
|
||||
}
|
||||
#endif
|
||||
//记录今日请求 体力互助
|
||||
lureDonateData.ClubLureRequestCDEnd = ZZTimeHelper.UtcNow().UtcNowOffset().
|
||||
AddHours(GContext.container.Resolve<cfg.Tables>().TbGlobalConfig.ClubLureRequestCd);
|
||||
SaveLureDonateData();
|
||||
SetClubRed();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//服务器消息状态
|
||||
public async Task<string> SendHelpOthersEnergy(string playerId, long cursorId)
|
||||
{
|
||||
ClubHelpEnergyRequest clubHelpEnergyRequest = new ClubHelpEnergyRequest()
|
||||
{
|
||||
donateId = userService.UserId,
|
||||
cursorId = cursorId,
|
||||
playerId = playerId,
|
||||
id = myClubInfo.id,
|
||||
};
|
||||
lureDonateData.ClubLureDonateCount++;
|
||||
string json = await customServerMgr.ClubRequest("ClubHelpEnergy", clubHelpEnergyRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("guild_donate_lures"))
|
||||
{
|
||||
e.AddContent("guild_id", myClubInfo.id)
|
||||
.AddContent("to_user_id", playerId)
|
||||
;
|
||||
}
|
||||
#endif
|
||||
ClubHelpEnergyResp clubHelpEnergyResp = Newtonsoft.Json.JsonConvert.DeserializeObject<ClubHelpEnergyResp>(json);
|
||||
SaveLureDonateData();
|
||||
return clubHelpEnergyResp.idContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
lureDonateData.ClubLureDonateCount--;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public async Task<string> GetHelpEnergyState(long cursorId)
|
||||
{
|
||||
GetHelpEnergyStatusRequest helpEnergyRequest = new GetHelpEnergyStatusRequest()
|
||||
{
|
||||
cursorId = cursorId,
|
||||
id = myClubInfo.id,
|
||||
};
|
||||
string json = await customServerMgr.ClubRequest("GetHelpEnergyStatus", helpEnergyRequest);
|
||||
if (!string.IsNullOrEmpty(json) && json != "[]")
|
||||
{
|
||||
GetHelpEnergyStatusResp helpEnergyResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetHelpEnergyStatusResp>(json);
|
||||
return helpEnergyResp.idContent;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user