113 lines
4.5 KiB
C#
113 lines
4.5 KiB
C#
//////////////////////////////////////////////////////////////////////////
|
||
//
|
||
// 文件:Assets/Code/Scripts/Gameplay/Net/Client/NetHelper.cs
|
||
// 作者:Xoen Xie
|
||
// 时间:2023/07/19
|
||
// 描述:网络相关接口
|
||
// 说明:
|
||
//
|
||
//////////////////////////////////////////////////////////////////////////
|
||
|
||
using NLDPB;
|
||
|
||
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);
|
||
}
|
||
|
||
// 退出关卡,关卡结算
|
||
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 ChapterReward(uint nChapterID, uint nIndex)
|
||
{
|
||
MSG_Clt_G_ChapterReward msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltGChapterReward) as MSG_Clt_G_ChapterReward;
|
||
msg.mPB.Chapter = nChapterID;
|
||
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 RaffleOne(uint id)
|
||
{
|
||
MSG_Clt_G_Raffle msg = NetManager.Instance.GetMessage(NLDMID.MSGID.CltGRaffle) as MSG_Clt_G_Raffle;
|
||
msg.mPB.Id = id;
|
||
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);
|
||
}
|
||
}
|
||
} |