CTT/Unity/Assets/Hotfix/Logic/Behaviour/Game/Helper/CreateRoleHelper.cs

45 lines
1.5 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using ET;
using UnityEngine;
namespace ET
{
public class CreateRoleHelper
{
public static async ETTask<string> OnCreateRoleAsync(Scene zoneScene, int jobId,string name)
2021-04-08 20:09:59 +08:00
{
try
{
long userId = zoneScene.GetComponent<GlobalVariable>().UserId;
R2C_CreateRole r2C_Create = (R2C_CreateRole)await zoneScene.GetComponent<SessionComponent>().Session.Call(new C2R_CreateRole() { JobId = jobId, Name = name,PlayerId = userId });
2021-04-08 20:09:59 +08:00
if (!r2C_Create.Message.IsNullOrEmpty())
{
Game.EventSystem.Publish(new ET.EventType.ShowTipUI
{
tip = r2C_Create.Message
}).Coroutine();
return r2C_Create.Message;
2021-04-08 20:09:59 +08:00
}
// 创建Player
ClientUser player = EntityFactory.CreateWithId<ClientUser>(zoneScene,userId);
PlayerComponent playerComponent = zoneScene.GetComponent<PlayerComponent>();
2021-04-08 20:09:59 +08:00
playerComponent.MyPlayer = player;
Game.EventSystem.Publish(new ET.EventType.CreateRoleFinish_EnterGame
{
}).Coroutine();
return null;
2021-04-08 20:09:59 +08:00
}
catch (Exception e)
{
Log.Error(e);
return e.ToString();
2021-04-08 20:09:59 +08:00
}
}
}
}