55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using ET;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
public class EnterGameHelper
|
|||
|
{
|
|||
|
public static async ETVoid EnterGameAsync(Scene scene,bool isReconnect = false)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
Game.EventSystem.Publish_Sync(new ET.EventType.TranslateSceneStart
|
|||
|
{
|
|||
|
isAutoEnd = false,
|
|||
|
});
|
|||
|
|
|||
|
|
|||
|
//!发送请求
|
|||
|
G2C_EnterGame ret = (G2C_EnterGame)await SessionComponent.Instance.Session.Call(new C2G_EnterGame() { });
|
|||
|
if (!ret.Message.IsNullOrEmpty())
|
|||
|
{
|
|||
|
Game.EventSystem.Publish(new ET.EventType.ShowTipUI
|
|||
|
{
|
|||
|
tip = "进入游戏失败,请重新登录。\n" + ret.Message,
|
|||
|
okAction = (txt) =>
|
|||
|
{
|
|||
|
Game.EventSystem.Publish_Sync(new ET.EventType.Quit());
|
|||
|
}
|
|||
|
}).Coroutine();
|
|||
|
return;
|
|||
|
}
|
|||
|
//!赋值用户Id
|
|||
|
Unit unit = UnitComponent.Instance.Get(ret.Id);
|
|||
|
GlobalVariable.isOnLine = ret.IsOnline;
|
|||
|
|
|||
|
await Game.EventSystem.Publish(new ET.EventType.EnterGameFinish_CreateMainUI
|
|||
|
{
|
|||
|
zoneScene = scene,
|
|||
|
isReConnect=isReconnect
|
|||
|
});
|
|||
|
|
|||
|
await TimerComponent.Instance.WaitAsync(500);
|
|||
|
Game.Scene.AddComponent<CheckCheatComponent>();
|
|||
|
|
|||
|
await Game.EventSystem.Publish(new ET.EventType.EnterGameFinish_SetCharacter
|
|||
|
{
|
|||
|
isOnline = ret.IsOnline
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|