43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Net;
|
|
using ET;
|
|
using UnityEngine;
|
|
|
|
namespace ET
|
|
{
|
|
public class CreateRoleHelper
|
|
{
|
|
public static async ETVoid OnCreateRoleAsync(Scene scene, int jobId,string name)
|
|
{
|
|
try
|
|
{
|
|
long userId = GlobalVariable.UserId;
|
|
R2C_CreateRole r2C_Create = (R2C_CreateRole)await SessionComponent.Instance.Session.Call(new C2R_CreateRole() { JobId = jobId, Name = name,PlayerId = userId });
|
|
|
|
if (!r2C_Create.Message.IsNullOrEmpty())
|
|
{
|
|
Game.EventSystem.Publish(new ET.EventType.ShowTipUI
|
|
{
|
|
tip = r2C_Create.Message
|
|
}).Coroutine();
|
|
return;
|
|
}
|
|
// 创建Player
|
|
ClientUser player = EntityFactory.CreateWithId<ClientUser>(scene,userId);
|
|
PlayerComponent playerComponent = scene.GetComponent<PlayerComponent>();
|
|
playerComponent.MyPlayer = player;
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.CreateRoleFinish_EnterGame
|
|
{
|
|
|
|
}).Coroutine();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e);
|
|
}
|
|
}
|
|
}
|
|
} |