45 lines
1.5 KiB
C#
45 lines
1.5 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 ETTask<string> OnCreateRoleAsync(Scene zoneScene, int jobId,string name)
|
|
{
|
|
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 });
|
|
|
|
if (!r2C_Create.Message.IsNullOrEmpty())
|
|
{
|
|
Game.EventSystem.Publish(new ET.EventType.ShowTipUI
|
|
{
|
|
tip = r2C_Create.Message
|
|
}).Coroutine();
|
|
return r2C_Create.Message;
|
|
}
|
|
// 创建Player
|
|
ClientUser player = EntityFactory.CreateWithId<ClientUser>(zoneScene,userId);
|
|
PlayerComponent playerComponent = zoneScene.GetComponent<PlayerComponent>();
|
|
playerComponent.MyPlayer = player;
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.CreateRoleFinish_EnterGame
|
|
{
|
|
|
|
}).Coroutine();
|
|
return null;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e);
|
|
return e.ToString();
|
|
}
|
|
}
|
|
}
|
|
} |