71 lines
1.8 KiB
C#
71 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using Fantasy;
|
|
using Fantasy.Async;
|
|
using Fantasy.Entitas;
|
|
using NBF.Fishing2;
|
|
using RootMotion.FinalIK;
|
|
using Log = NBC.Log;
|
|
|
|
namespace NBF
|
|
{
|
|
public class Fishing
|
|
{
|
|
private static Fishing _instance;
|
|
|
|
public static Fishing Instance
|
|
{
|
|
get
|
|
{
|
|
_instance ??= new Fishing();
|
|
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
public MapRoom OldMap { get; private set; }
|
|
|
|
public MapRoom Map { get; private set; }
|
|
|
|
|
|
public async FTask<bool> Go(int mapId, string roomCode = "")
|
|
{
|
|
if (mapId == 0)
|
|
{
|
|
Log.Warning("账号没有进入过地图,进入新手引导地图");
|
|
mapId = 99;
|
|
}
|
|
|
|
var response = (G2C_EnterMapResponse)await Net.Call(new C2G_EnterMapRequest()
|
|
{
|
|
MapId = mapId,
|
|
RoomCode = roomCode
|
|
});
|
|
Log.Info($"进入地图请求返回={response.ErrorCode}");
|
|
if (response.ErrorCode != 0)
|
|
{
|
|
Notices.Error("enter room error");
|
|
return false;
|
|
}
|
|
LoadingPanel.Show();
|
|
await ChangeMap(response.MapId, response.RoomCode, response.Units);
|
|
LoadingPanel.Hide();
|
|
return true;
|
|
}
|
|
|
|
|
|
public async FTask ChangeMap(int mapId, string roomCode, List<MapUnitInfo> units)
|
|
{
|
|
OldMap = Map;
|
|
Map = Entity.Create<MapRoom>(Game.Main,true, true);
|
|
Map.Code = roomCode;
|
|
Map.Map = mapId;
|
|
var sceneName = "Map1";
|
|
//加载场景==
|
|
await SceneHelper.LoadScene(sceneName);
|
|
foreach (var mapUnitInfo in units)
|
|
{
|
|
Map.AddUnit(mapUnitInfo);
|
|
}
|
|
}
|
|
}
|
|
} |