254 lines
9.8 KiB
C#
254 lines
9.8 KiB
C#
//////////////////////////////////////////////////////////////////////////
|
||
//
|
||
// 文件:Assets/Code/Scripts/Gameplay/Net/Client/NetHelper.cs
|
||
// 作者:Xoen Xie
|
||
// 时间:2023/07/19
|
||
// 描述:网络相关接口
|
||
// 说明:
|
||
//
|
||
//////////////////////////////////////////////////////////////////////////
|
||
|
||
|
||
using Google.Protobuf.Collections;
|
||
using Google.Protobuf;
|
||
using NLDMID;
|
||
using NLDPB;
|
||
using UnityEngine.Rendering;
|
||
|
||
namespace Gameplay.Net
|
||
{
|
||
public static class NetHelper
|
||
{
|
||
// 发送服务器消息,请求角色养成
|
||
public static void CharacterUpgrade(uint nCharacterID, UpgradeType type, uint nTargetLevel)
|
||
{
|
||
MSG_Clt_G_CharacterUpgrade msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltGCharacterUpgrade) as MSG_Clt_G_CharacterUpgrade;
|
||
msg.mPB.CharacterId = nCharacterID;
|
||
msg.mPB.UpgradeType = (uint)type;
|
||
msg.mPB.TargetLevel = nTargetLevel;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
// 进入关卡
|
||
public static void EnterLevel(uint nLevelID, uint nTeamIndex)
|
||
{
|
||
MSG_Clt_G_EnterLevel msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltGEnterLevel) as MSG_Clt_G_EnterLevel;
|
||
msg.mPB.LevelId = nLevelID;
|
||
msg.mPB.TeamIndex = nTeamIndex;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
DebugUtil.Log($"C->S send message EnterLevel,levelID:{nLevelID} nTeamIndex:{nTeamIndex}");
|
||
}
|
||
|
||
// 退出关卡,关卡结算
|
||
public static void ExitLevel(bool isSuccess, uint nStar)
|
||
{
|
||
MSG_Clt_G_ExitLevel msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltGExitLevel) as MSG_Clt_G_ExitLevel;
|
||
msg.mPB.IsSuccess = isSuccess;
|
||
msg.mPB.Star = nStar;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
// 领取章节宝箱
|
||
public static void LevelGroupReward(uint nGroupID, uint nIndex)
|
||
{
|
||
MSG_Clt_G_GroupReward msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltGGroupReward) as MSG_Clt_G_GroupReward;
|
||
msg.mPB.GroupId = nGroupID;
|
||
msg.mPB.Index = nIndex;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
// 载具升级
|
||
public static void VehicleUpgrade(uint nVehicleID, uint[] upgrade_type, uint[] upgrade_count)
|
||
{
|
||
MSG_Clt_G_VehicleUpgrade msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltGVehicleUpgrade) as MSG_Clt_G_VehicleUpgrade;
|
||
msg.mPB.VehicleId = nVehicleID;
|
||
msg.mPB.UpgradeType.Clear();
|
||
msg.mPB.UpgradeType.AddRange(upgrade_type);
|
||
msg.mPB.UpgradeCount.Clear();
|
||
msg.mPB.UpgradeCount.AddRange(upgrade_count);
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
// 创建队伍
|
||
public static void CreateTeam(uint nIndex, string name, uint nIcon, uint[] characterIDs, uint nVehicleID)
|
||
{
|
||
MSG_Clt_G_CreateTeam msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltGCreateTeam) as MSG_Clt_G_CreateTeam;
|
||
msg.mPB.Name = name;
|
||
msg.mPB.Icon = nIcon;
|
||
msg.mPB.Index = nIndex;
|
||
|
||
msg.mPB.CharacterId.Clear();
|
||
for (int i = 0; i < characterIDs.Length; i++)
|
||
msg.mPB.CharacterId.Add(characterIDs[i]);
|
||
|
||
msg.mPB.VehicleId = nVehicleID;
|
||
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
//普通单抽
|
||
public static void Raffle(uint id, uint raffleType, bool isFree, uint useTicketCounr)
|
||
{
|
||
MSG_Clt_G_Raffle msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltGRaffle) as MSG_Clt_G_Raffle;
|
||
msg.mPB.Id = id;
|
||
msg.mPB.Type = raffleType;
|
||
msg.mPB.IsFree = isFree;
|
||
msg.mPB.TicketCount = useTicketCounr;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
// 机器人初始化
|
||
public static void RobotTestInit()
|
||
{
|
||
MSG_Clt_G_TestInit msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltGTestInit) as MSG_Clt_G_TestInit;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
public static void GiftCode(string code)
|
||
{
|
||
MSG_Clt_G_GiftCode msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltGGiftCode) as MSG_Clt_G_GiftCode;
|
||
msg.mPB.Code = code;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
public static void Relogin()
|
||
{
|
||
MSG_Clt_G_Relogin msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltGRelogin) as MSG_Clt_G_Relogin;
|
||
msg.mPB.ActorId = Actor.Instance.Base.GetProp(ActorProp.ActorId);
|
||
msg.mPB.LoginKey = Actor.Instance.Login.LoginKey;
|
||
NetManager.Instance.mClient.SendMessage(msg, Actor.Instance.Login.ServerID);
|
||
}
|
||
|
||
// 请求邮件列表
|
||
public static void RequestMailList(bool NeedAll)
|
||
{
|
||
MSG_Clt_Ml_MailRequest msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltMlMailRequest) as MSG_Clt_Ml_MailRequest;
|
||
msg.mPB.NeedAll = NeedAll;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
// 打开一封邮件
|
||
public static void OpenMail(ulong id)
|
||
{
|
||
MSG_Clt_Ml_OpenMail msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltMlOpenMail) as MSG_Clt_Ml_OpenMail;
|
||
msg.mPB.Id = id;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
// 领取邮件附件,如果id为0,则领取所有
|
||
public static void CliamMail(ulong id)
|
||
{
|
||
MSG_Clt_Ml_ClaimMailItems msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltMlClaimMailItems) as MSG_Clt_Ml_ClaimMailItems;
|
||
msg.mPB.MailId = id;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
public static void DeleteMail(ulong id)
|
||
{
|
||
MSG_Clt_Ml_DeleteMail msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltMlDeleteMail) as MSG_Clt_Ml_DeleteMail;
|
||
msg.mPB.MailId = id;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
// 升级指挥官技能
|
||
public static void PlayerSkillUpgrade(uint nSkillID)
|
||
{
|
||
MSG_Clt_G_PlayerSkillUpgrade msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltGPlayerSkillUpgrade) as MSG_Clt_G_PlayerSkillUpgrade;
|
||
msg.mPB.SkillId = nSkillID;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
//领取任务奖励
|
||
public static void ClaimTaskReward(uint[] taskIds)
|
||
{
|
||
MSG_Clt_G_TaskClaim msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltGTaskClaim) as MSG_Clt_G_TaskClaim;
|
||
msg.mPB.TaskId.Clear();
|
||
for (int i = 0; i < taskIds.Length; i++)
|
||
{
|
||
msg.mPB.TaskId.Add(taskIds[i]);
|
||
}
|
||
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
public static void GetShopData(uint nShopId)
|
||
{
|
||
MSG_Clt_G_GetShopContent msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltGGetShopContent) as MSG_Clt_G_GetShopContent;
|
||
msg.mPB.ShopId = nShopId;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
public static void ShopBuySth(uint nShopId, int index, int count)
|
||
{
|
||
MSG_Clt_G_ShopPurchase msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltGShopPurchase) as MSG_Clt_G_ShopPurchase;
|
||
msg.mPB.ShopId = nShopId;
|
||
msg.mPB.Index = (uint)index;
|
||
msg.mPB.Count = (uint)count;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
public static void SetDefenceTeamForPvp(uint[] characterIDs, uint vehicleID, byte[] teamData)
|
||
{
|
||
MSG_Clt_G_SetDefenceTeamForPvp msg =
|
||
NetManager.Instance.GetMessage(NLDMID.MSGID.CltGSetDefenceTeamForPvp) as MSG_Clt_G_SetDefenceTeamForPvp;
|
||
foreach (var characterID in characterIDs)
|
||
{
|
||
msg.mPB.CharacterId.Add(characterID);
|
||
}
|
||
|
||
msg.mPB.VehicleId = vehicleID;
|
||
msg.mPB.TeamData = ByteString.CopyFrom(teamData);
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
public static void StartPVPFight(uint actorID)
|
||
{
|
||
MSG_Clt_G_PvpStart msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltGPvpStart) as MSG_Clt_G_PvpStart;
|
||
msg.mPB.ActorId = actorID;
|
||
NetManager.Instance.mClient.SendMessage(msg);
|
||
}
|
||
|
||
public static void GetPVPInformation()
|
||
{
|
||
MSG_Clt_Mg_PvpInformation msg =
|
||
NetManager.Instance.GetMessage(MSGID.CltMgPvpInformation) as MSG_Clt_Mg_PvpInformation;
|
||
NetManager.Instance.SendMessage(msg);
|
||
}
|
||
|
||
public static void FinishPVPFight(bool isWin,uint key)
|
||
{
|
||
MSG_Clt_G_PvpResult msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltGPvpResult) as MSG_Clt_G_PvpResult;
|
||
msg.mPB.IsWin = isWin;
|
||
msg.mPB.Key = key;
|
||
|
||
NetManager.Instance.SendMessage(msg);
|
||
}
|
||
|
||
public static void GetPvpOrderList(uint page)
|
||
{
|
||
MSG_Clt_Mg_PvpOrderList msg =
|
||
NetManager.Instance.GetMessage(MSGID.CltMgPvpOrderList) as MSG_Clt_Mg_PvpOrderList;
|
||
msg.mPB.Page = page;
|
||
|
||
NetManager.Instance.SendMessage(msg);
|
||
}
|
||
public static void PatioExchange(uint gachaId,uint index)
|
||
{
|
||
MSG_Clt_G_PatioExchange msg = NetManager.Instance.GetMessage(MSGID.CltGPatioExchange) as MSG_Clt_G_PatioExchange;
|
||
msg.mPB.GachaId = gachaId;
|
||
msg.mPB.Index = index;
|
||
NetManager.Instance.SendMessage(msg);
|
||
}
|
||
}
|
||
} |