forked from sin365/AxibugEmuOnline
Merge pull request '重构一下' (#33) from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: sin365/AxibugEmuOnline#33
This commit is contained in:
commit
8e61551d3d
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b3f84ffc19016f4dbc28b308894bb4a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45d5034162d6cf04dbe46da84fc7d074
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -6,7 +6,7 @@ using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client.ClientCore
|
||||
{
|
||||
public static class AppAxibugEmuOnline
|
||||
public static class App
|
||||
{
|
||||
public static string TokenStr;
|
||||
public static string IP;
|
||||
@ -22,6 +22,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
public static HttpAPI httpAPI;
|
||||
public static CacheManager CacheMgr;
|
||||
public static AppSceneLoader SceneLoader;
|
||||
public static AppRoom roomMgr;
|
||||
|
||||
private static CoroutineRunner coRunner;
|
||||
|
||||
@ -42,6 +43,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
nesRomLib = new RomLib(EnumPlatform.NES);
|
||||
CacheMgr = new CacheManager();
|
||||
SceneLoader = new AppSceneLoader();
|
||||
roomMgr = new AppRoom();
|
||||
|
||||
var go = new GameObject("[AppAxibugEmuOnline]");
|
||||
GameObject.DontDestroyOnLoad(go);
|
||||
@ -81,7 +83,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
|
||||
public static void Close()
|
||||
{
|
||||
AppAxibugEmuOnline.log.Info("停止");
|
||||
App.log.Info("停止");
|
||||
}
|
||||
static void OnNoSugarNetLog(int LogLevel, string msg)
|
||||
{
|
@ -137,7 +137,7 @@ namespace AxibugEmuOnline.Client.Event
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Error(e.Message);
|
||||
App.log.Error(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -156,7 +156,7 @@ namespace AxibugEmuOnline.Client.Event
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Error(e.Message);
|
||||
App.log.Error(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,7 +175,7 @@ namespace AxibugEmuOnline.Client.Event
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Error(e.Message);
|
||||
App.log.Error(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,7 +194,7 @@ namespace AxibugEmuOnline.Client.Event
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Error(e.Message + ", method name : " + callback.Method);
|
||||
App.log.Error(e.Message + ", method name : " + callback.Method);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,7 +214,7 @@ namespace AxibugEmuOnline.Client.Event
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Error(e.Message);
|
||||
App.log.Error(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
{
|
||||
ChatMsg = ChatMsg,
|
||||
};
|
||||
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdChatmsg, ProtoBufHelper.Serizlize(msg));
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdChatmsg, ProtoBufHelper.Serizlize(msg));
|
||||
}
|
||||
|
||||
public void RecvChatMsg(byte[] reqData)
|
||||
|
@ -16,17 +16,17 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
|
||||
public void Login()
|
||||
{
|
||||
AppAxibugEmuOnline.log.Debug("-->Login");
|
||||
App.log.Debug("-->Login");
|
||||
if (string.IsNullOrEmpty(LastLoginGuid))
|
||||
LastLoginGuid = Guid.NewGuid().ToString();
|
||||
|
||||
AppAxibugEmuOnline.user.userdata.Account = LastLoginGuid;
|
||||
App.user.userdata.Account = LastLoginGuid;
|
||||
Protobuf_Login msg = new Protobuf_Login()
|
||||
{
|
||||
LoginType = 0,
|
||||
Account = AppAxibugEmuOnline.user.userdata.Account,
|
||||
Account = App.user.userdata.Account,
|
||||
};
|
||||
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg));
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg));
|
||||
}
|
||||
|
||||
public void RecvLoginMsg(byte[] reqData)
|
||||
@ -34,12 +34,12 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
Protobuf_Login_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Login_RESP>(reqData);
|
||||
if (msg.Status == LoginResultStatus.Ok)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Info("登录成功");
|
||||
AppAxibugEmuOnline.user.InitMainUserData(AppAxibugEmuOnline.user.userdata.Account, msg.UID);
|
||||
App.log.Info("登录成功");
|
||||
App.user.InitMainUserData(App.user.userdata.Account, msg.UID);
|
||||
}
|
||||
else
|
||||
{
|
||||
AppAxibugEmuOnline.log.Info("登录失败");
|
||||
App.log.Info("登录失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
byte[] comData = Helper.CompressByteArray(RenderBuffer);
|
||||
_Protobuf_Screnn_Frame.FrameID = 0;
|
||||
_Protobuf_Screnn_Frame.RawBitmap = ByteString.CopyFrom(comData);
|
||||
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdScreen, ProtoBufHelper.Serizlize(_Protobuf_Screnn_Frame));
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdScreen, ProtoBufHelper.Serizlize(_Protobuf_Screnn_Frame));
|
||||
}
|
||||
|
||||
public void OnScreen(byte[] reqData)
|
||||
|
@ -14,7 +14,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
{
|
||||
public Protobuf_Room_MiniInfo mineRoomMiniInfo { get; private set; } = null;
|
||||
public bool InRoom => mineRoomMiniInfo != null;
|
||||
public bool IsHost => mineRoomMiniInfo?.HostPlayerUID == AppAxibugEmuOnline.user.userdata.UID;
|
||||
public bool IsHost => mineRoomMiniInfo?.HostPlayerUID == App.user.userdata.UID;
|
||||
public RoomGameState RoomState => mineRoomMiniInfo.GameState;
|
||||
public int MinePlayerIdx => GetMinePlayerIndex();
|
||||
public int WaitStep { get; private set; } = -1;
|
||||
@ -100,9 +100,9 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
if (mineRoomMiniInfo == null)
|
||||
return -1;
|
||||
|
||||
if (mineRoomMiniInfo.Player1UID == AppAxibugEmuOnline.user.userdata.UID)
|
||||
if (mineRoomMiniInfo.Player1UID == App.user.userdata.UID)
|
||||
return 0;
|
||||
if (mineRoomMiniInfo.Player2UID == AppAxibugEmuOnline.user.userdata.UID)
|
||||
if (mineRoomMiniInfo.Player2UID == App.user.userdata.UID)
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
@ -115,7 +115,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
|
||||
if (mineRoomMiniInfo.Player1UID > 0)
|
||||
result[0] = mineRoomMiniInfo.Player1UID;
|
||||
if (mineRoomMiniInfo.Player2UID == AppAxibugEmuOnline.user.userdata.UID)
|
||||
if (mineRoomMiniInfo.Player2UID == App.user.userdata.UID)
|
||||
result[1] = mineRoomMiniInfo.Player2UID;
|
||||
|
||||
return result;
|
||||
@ -129,8 +129,8 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
/// <param name="ChatMsg"></param>
|
||||
public void SendGetRoomList()
|
||||
{
|
||||
AppAxibugEmuOnline.log.Info("拉取房间列表");
|
||||
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomList, ProtoBufHelper.Serizlize(_Protobuf_Room_List));
|
||||
App.log.Info("拉取房间列表");
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdRoomList, ProtoBufHelper.Serizlize(_Protobuf_Room_List));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -139,7 +139,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
/// <param name="reqData"></param>
|
||||
void RecvGetRoomList(byte[] reqData)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Info("取得完整房间列表");
|
||||
App.log.Info("取得完整房间列表");
|
||||
Protobuf_Room_List_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_List_RESP>(reqData);
|
||||
for (int i = 0; i < msg.RoomMiniInfoList.Count; i++)
|
||||
AddOrUpdateRoomList(msg.RoomMiniInfoList[i]);
|
||||
@ -152,7 +152,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
/// <param name="reqData"></param>
|
||||
void RecvGetRoomListUpdate(byte[] reqData)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Debug("单个房间状态更新");
|
||||
App.log.Debug("单个房间状态更新");
|
||||
Protobuf_Room_Update_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Update_RESP>(reqData);
|
||||
AddOrUpdateRoomList(msg.RoomMiniInfo);
|
||||
EventSystem.Instance.PostEvent(EEvent.OnRoomListSingleUpdate, msg.RoomMiniInfo.GameRomID);
|
||||
@ -169,8 +169,8 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
_Protobuf_Room_Create.JoinPlayerIdx = JoinPlayerIdx;
|
||||
_Protobuf_Room_Create.GameRomID = GameRomID;
|
||||
_Protobuf_Room_Create.GameRomHash = GameRomHash;
|
||||
AppAxibugEmuOnline.log.Info($"创建房间");
|
||||
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomCreate, ProtoBufHelper.Serizlize(_Protobuf_Room_Create));
|
||||
App.log.Info($"创建房间");
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdRoomCreate, ProtoBufHelper.Serizlize(_Protobuf_Room_Create));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -179,7 +179,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
/// <param name="reqData"></param>
|
||||
void RecvCreateRoom(byte[] reqData)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Debug("创建房间成功");
|
||||
App.log.Debug("创建房间成功");
|
||||
Protobuf_Room_Create_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Create_RESP>(reqData);
|
||||
mineRoomMiniInfo = msg.RoomMiniInfo;
|
||||
}
|
||||
@ -194,8 +194,8 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
{
|
||||
_Protobuf_Room_Join.RoomID = RoomID;
|
||||
_Protobuf_Room_Join.PlayerNum = JoinPlayerIdx;
|
||||
AppAxibugEmuOnline.log.Info($"创建房间");
|
||||
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomJoin, ProtoBufHelper.Serizlize(_Protobuf_Room_Join));
|
||||
App.log.Info($"创建房间");
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdRoomJoin, ProtoBufHelper.Serizlize(_Protobuf_Room_Join));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -204,7 +204,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
/// <param name="reqData"></param>
|
||||
void RecvJoinRoom(byte[] reqData)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Debug("加入房间成功");
|
||||
App.log.Debug("加入房间成功");
|
||||
Protobuf_Room_Join_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Join_RESP>(reqData);
|
||||
mineRoomMiniInfo = msg.RoomMiniInfo;
|
||||
InitRePlay();
|
||||
@ -218,8 +218,8 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
public void SendLeavnRoom(int RoomID)
|
||||
{
|
||||
_Protobuf_Room_Leave.RoomID = RoomID;
|
||||
AppAxibugEmuOnline.log.Info($"创建房间");
|
||||
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomLeave, ProtoBufHelper.Serizlize(_Protobuf_Room_Leave));
|
||||
App.log.Info($"创建房间");
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdRoomLeave, ProtoBufHelper.Serizlize(_Protobuf_Room_Leave));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -228,7 +228,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
/// <param name="reqData"></param>
|
||||
void RecvLeavnRoom(byte[] reqData)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Debug("加入房间成功");
|
||||
App.log.Debug("加入房间成功");
|
||||
Protobuf_Room_Leave_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Leave_RESP>(reqData);
|
||||
ReleaseRePlay();
|
||||
mineRoomMiniInfo = null;
|
||||
@ -271,8 +271,8 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
{
|
||||
LoadStateRaw = Google.Protobuf.ByteString.CopyFrom(compressRawData)
|
||||
};
|
||||
AppAxibugEmuOnline.log.Info($"上报即时存档数据 原数据大小:{RawData.Length},压缩后;{compressRawData.Length}");
|
||||
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomHostPlayerUpdateStateRaw, ProtoBufHelper.Serizlize(msg));
|
||||
App.log.Info($"上报即时存档数据 原数据大小:{RawData.Length},压缩后;{compressRawData.Length}");
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdRoomHostPlayerUpdateStateRaw, ProtoBufHelper.Serizlize(msg));
|
||||
}
|
||||
|
||||
void RecvRoom_WaitStep(byte[] reqData)
|
||||
@ -285,7 +285,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
if (WaitStep == 1)
|
||||
{
|
||||
byte[] decompressRawData = Helper.DecompressByteArray(msg.LoadStateRaw.ToByteArray());
|
||||
AppAxibugEmuOnline.log.Info($"收到即时存档数据 解压后;{decompressRawData.Length}");
|
||||
App.log.Info($"收到即时存档数据 解压后;{decompressRawData.Length}");
|
||||
RawData = decompressRawData;
|
||||
}
|
||||
}
|
||||
@ -294,7 +294,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
void RecvHostPlayer_UpdateStateRaw(byte[] reqData)
|
||||
{
|
||||
Protobuf_Room_HostPlayer_UpdateStateRaw_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_HostPlayer_UpdateStateRaw_RESP>(reqData);
|
||||
AppAxibugEmuOnline.log.Info($"鸡翅孙当上报成功");
|
||||
App.log.Info($"鸡翅孙当上报成功");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -302,8 +302,8 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
/// </summary>
|
||||
public void SendRoomPlayerReady()
|
||||
{
|
||||
AppAxibugEmuOnline.log.Debug("上报准备完毕");
|
||||
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomPlayerReady, ProtoBufHelper.Serizlize(_Protobuf_Room_Player_Ready));
|
||||
App.log.Debug("上报准备完毕");
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdRoomPlayerReady, ProtoBufHelper.Serizlize(_Protobuf_Room_Player_Ready));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -313,7 +313,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
{
|
||||
_Protobuf_Room_SinglePlayerInputData.FrameID = FrameID;
|
||||
_Protobuf_Room_SinglePlayerInputData.InputData = InputData;
|
||||
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdRoomSingelPlayerInput, ProtoBufHelper.Serizlize(_Protobuf_Room_SinglePlayerInputData));
|
||||
App.networkHelper.SendToServer((int)CommandID.CmdRoomSingelPlayerInput, ProtoBufHelper.Serizlize(_Protobuf_Room_SinglePlayerInputData));
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
m_tasks.Enqueue(new LoadTask(scenePath, callback));
|
||||
if (m_coroutine == null)
|
||||
m_coroutine = AppAxibugEmuOnline.StartCoroutine(TaskFlow());
|
||||
m_coroutine = App.StartCoroutine(TaskFlow());
|
||||
}
|
||||
|
||||
private IEnumerator TaskFlow()
|
||||
|
@ -10,7 +10,7 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class CacheManager
|
||||
{
|
||||
static readonly string CacheDirPath = $"{AppAxibugEmuOnline.PersistentDataPath}/Caches";
|
||||
static readonly string CacheDirPath = $"{App.PersistentDataPath}/Caches";
|
||||
static readonly string TextureCacheDirPath = $"{CacheDirPath}/Texture";
|
||||
|
||||
public void GetSpriteCache(string url, Action<Sprite, string> callback)
|
||||
@ -27,7 +27,7 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
IEnumerator DownloadFromURL(string url, string path, Action<byte[]> callback)
|
||||
{
|
||||
var request = UnityWebRequest.Get($"{AppAxibugEmuOnline.httpAPI.DownSite}/{url}");
|
||||
var request = UnityWebRequest.Get($"{App.httpAPI.DownSite}/{url}");
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
if (request.result == UnityWebRequest.Result.Success)
|
||||
@ -62,7 +62,7 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
else
|
||||
{
|
||||
AppAxibugEmuOnline.StartCoroutine(DownloadFromURL(url, path, (data) =>
|
||||
App.StartCoroutine(DownloadFromURL(url, path, (data) =>
|
||||
{
|
||||
var @out = RawDataConvert<T>(data);
|
||||
cachesInMemory[url] = @out;
|
||||
|
@ -16,7 +16,7 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public void GetNesRomList(Action<Resp_GameList> callback, int page, int pageSize = 10)
|
||||
{
|
||||
AppAxibugEmuOnline.StartCoroutine(GetNesRomListFlow(page, pageSize, callback));
|
||||
App.StartCoroutine(GetNesRomListFlow(page, pageSize, callback));
|
||||
}
|
||||
|
||||
private IEnumerator GetNesRomListFlow(int page, int pageSize, Action<Resp_GameList> callback)
|
||||
|
@ -16,7 +16,7 @@ namespace AxibugEmuOnline.Client
|
||||
private UnityWebRequest downloadRequest;
|
||||
|
||||
/// <summary> 指示该Rom文件的存放路径 </summary>
|
||||
public string LocalFilePath => $"{AppAxibugEmuOnline.PersistentDataPath}/RemoteRoms/{platform}/{fileName}";
|
||||
public string LocalFilePath => $"{App.PersistentDataPath}/RemoteRoms/{platform}/{fileName}";
|
||||
/// <summary> 指示该Rom文件是否已下载完毕 </summary>
|
||||
public bool RomReady => hasLocalFile;
|
||||
/// <summary> 指示是否正在下载Rom文件 </summary>
|
||||
@ -57,7 +57,7 @@ namespace AxibugEmuOnline.Client
|
||||
if (RomReady) return;
|
||||
if (IsDownloading) return;
|
||||
|
||||
AppAxibugEmuOnline.StartCoroutine(DownloadRemoteRom((bytes) =>
|
||||
App.StartCoroutine(DownloadRemoteRom((bytes) =>
|
||||
{
|
||||
if (bytes != null)
|
||||
{
|
||||
@ -106,7 +106,7 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
private IEnumerator DownloadRemoteRom(Action<byte[]> callback)
|
||||
{
|
||||
downloadRequest = UnityWebRequest.Get($"{AppAxibugEmuOnline.httpAPI.DownSite}/{webData.url}");
|
||||
downloadRequest = UnityWebRequest.Get($"{App.httpAPI.DownSite}/{webData.url}");
|
||||
yield return downloadRequest.SendWebRequest();
|
||||
|
||||
if (downloadRequest.result != UnityWebRequest.Result.Success)
|
||||
|
@ -26,7 +26,7 @@ namespace AxibugEmuOnline.Client
|
||||
switch (platform)
|
||||
{
|
||||
case EnumPlatform.NES:
|
||||
m_romGetFunc = AppAxibugEmuOnline.httpAPI.GetNesRomList;
|
||||
m_romGetFunc = App.httpAPI.GetNesRomList;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -41,7 +41,7 @@ namespace AxibugEmuOnline.Client
|
||||
/// <summary> 清除所有下载的Rom文件 </summary>
|
||||
public void ClearRomFile()
|
||||
{
|
||||
var path = $"{AppAxibugEmuOnline.PersistentDataPath}/RemoteRoms/{m_platform}";
|
||||
var path = $"{App.PersistentDataPath}/RemoteRoms/{m_platform}";
|
||||
if (Directory.Exists(path)) Directory.Delete(path, true);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
public UserDataManager()
|
||||
{
|
||||
//注册重连成功事件,以便后续自动登录
|
||||
AppAxibugEmuOnline.networkHelper.OnReConnected += OnReConnected;
|
||||
App.networkHelper.OnReConnected += OnReConnected;
|
||||
}
|
||||
public MainUserDataBase userdata { get; private set; } = new MainUserDataBase();
|
||||
public bool IsLoggedIn => userdata.IsLoggedIn;
|
||||
@ -50,7 +50,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
//如果之前已登录,则重新登录
|
||||
if (userdata.IsLoggedIn)
|
||||
{
|
||||
AppAxibugEmuOnline.login.Login();
|
||||
App.login.Login();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
try
|
||||
{
|
||||
var romFile = AppAxibugEmuOnline.nesRomLib.GetRomFile(fname);
|
||||
var romFile = App.nesRomLib.GetRomFile(fname);
|
||||
var bytes = romFile.GetRomFileData();
|
||||
Debug.Log($"Open {romFile.Alias}");
|
||||
return new MemoryStream(bytes);
|
||||
@ -26,7 +26,7 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public void GetRomPathInfo(string fname, out string fullPath, out string directPath)
|
||||
{
|
||||
var romFile = AppAxibugEmuOnline.nesRomLib.GetRomFile(fname);
|
||||
var romFile = App.nesRomLib.GetRomFile(fname);
|
||||
UnityEngine.Debug.Assert(romFile != null);
|
||||
|
||||
fullPath = romFile.LocalFilePath;
|
||||
@ -40,7 +40,7 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public void SaveSRAMToFile(byte[] sramContent, string romName)
|
||||
{
|
||||
string sramDirectoryPath = $"{AppAxibugEmuOnline.PersistentDataPath}/sav";
|
||||
string sramDirectoryPath = $"{App.PersistentDataPath}/sav";
|
||||
Directory.CreateDirectory(sramDirectoryPath);
|
||||
romName = Path.GetFileNameWithoutExtension(romName);
|
||||
File.WriteAllBytes($"{sramDirectoryPath}/{romName}.sav", sramContent);
|
||||
@ -48,7 +48,7 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public void SaveDISKToFile(byte[] diskFileContent, string romName)
|
||||
{
|
||||
string diskFileDirectoryPath = $"{AppAxibugEmuOnline.PersistentDataPath}/dsv";
|
||||
string diskFileDirectoryPath = $"{App.PersistentDataPath}/dsv";
|
||||
Directory.CreateDirectory(diskFileDirectoryPath);
|
||||
romName = Path.GetFileNameWithoutExtension(romName);
|
||||
File.WriteAllBytes($"{diskFileDirectoryPath}/{romName}.dsv", diskFileContent);
|
||||
@ -58,14 +58,14 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public void PrepareDirectory(string directPath)
|
||||
{
|
||||
Directory.CreateDirectory($"{AppAxibugEmuOnline.PersistentDataPath}/{directPath}");
|
||||
Directory.CreateDirectory($"{App.PersistentDataPath}/{directPath}");
|
||||
}
|
||||
|
||||
public void SaveFile(byte[] fileData, string directPath, string fileName)
|
||||
{
|
||||
PrepareDirectory(directPath);
|
||||
|
||||
var fileFullpath = $"{AppAxibugEmuOnline.PersistentDataPath}/{directPath}/{fileName}";
|
||||
var fileFullpath = $"{App.PersistentDataPath}/{directPath}/{fileName}";
|
||||
File.WriteAllBytes(fileFullpath, fileData);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = File.ReadAllBytes($"{AppAxibugEmuOnline.PersistentDataPath}/{directPath}/{fileName}");
|
||||
var data = File.ReadAllBytes($"{App.PersistentDataPath}/{directPath}/{fileName}");
|
||||
if (data == null) return null;
|
||||
return new MemoryStream(data);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class NesControllerMapper
|
||||
{
|
||||
private static readonly string ConfigFilePath = $"{AppAxibugEmuOnline.PersistentDataPath}/NES/ControllerMapper.json";
|
||||
private static readonly string ConfigFilePath = $"{App.PersistentDataPath}/NES/ControllerMapper.json";
|
||||
|
||||
public MapperSetter Player1 = new MapperSetter();
|
||||
public MapperSetter Player2 = new MapperSetter();
|
||||
@ -50,7 +50,7 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = File.ReadAllText($"{AppAxibugEmuOnline.PersistentDataPath}/Nes/ControllerMapper.json");
|
||||
var json = File.ReadAllText($"{App.PersistentDataPath}/Nes/ControllerMapper.json");
|
||||
s_setting = JsonUtility.FromJson<NesControllerMapper>(json);
|
||||
}
|
||||
catch
|
||||
|
@ -70,7 +70,7 @@ namespace AxibugEmuOnline.Client.Network
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AppAxibugEmuOnline.log.Error(e.Message);
|
||||
App.log.Error(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ namespace AxibugEmuOnline.Client.Network
|
||||
if (IsConnect)
|
||||
{
|
||||
//从未登录过
|
||||
if (!AppAxibugEmuOnline.user.IsLoggedIn)
|
||||
if (!App.user.IsLoggedIn)
|
||||
{
|
||||
//首次登录
|
||||
AppAxibugEmuOnline.login.Login();
|
||||
App.login.Login();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -63,7 +63,7 @@ namespace AxibugEmuOnline.Client.Network
|
||||
{
|
||||
//用于Unity内的输出
|
||||
//Debug.Log("NetCoreDebug >> "+str);
|
||||
AppAxibugEmuOnline.log.Info("NetCoreDebug >> " + str);
|
||||
App.log.Info("NetCoreDebug >> " + str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -115,13 +115,13 @@ namespace AxibugEmuOnline.Client.Network
|
||||
{
|
||||
//等待时间
|
||||
Thread.Sleep(ReConnectTryTime);
|
||||
AppAxibugEmuOnline.log.Info($"尝试自动重连{LastConnectIP}:{LastConnectPort}……");
|
||||
App.log.Info($"尝试自动重连{LastConnectIP}:{LastConnectPort}……");
|
||||
//第一步
|
||||
if (Init(LastConnectIP, LastConnectPort))
|
||||
{
|
||||
AppAxibugEmuOnline.log.Info($"自动重连成功!");
|
||||
App.log.Info($"自动重连成功!");
|
||||
bflagDone = true;
|
||||
AppAxibugEmuOnline.log.Info($"触发重连后的自动逻辑!");
|
||||
App.log.Info($"触发重连后的自动逻辑!");
|
||||
OnReConnected?.Invoke();
|
||||
}
|
||||
} while (!bflagDone);
|
||||
|
@ -3,7 +3,7 @@ using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using UnityEngine;
|
||||
using App = AxibugEmuOnline.Client.ClientCore.AppAxibugEmuOnline;
|
||||
using App = AxibugEmuOnline.Client.ClientCore.App;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public int Index { get; set; }
|
||||
|
||||
private RomLib m_romlib => AppAxibugEmuOnline.nesRomLib;
|
||||
private RomLib m_romlib => App.nesRomLib;
|
||||
private RomFile m_romfile;
|
||||
|
||||
public void SetData(object data)
|
||||
@ -64,7 +64,7 @@ namespace AxibugEmuOnline.Client
|
||||
else
|
||||
{
|
||||
SetBaseInfo(m_romfile.Alias, m_romfile.Descript);
|
||||
AppAxibugEmuOnline.CacheMgr.GetSpriteCache(m_romfile.ImageURL, (img, url) =>
|
||||
App.CacheMgr.GetSpriteCache(m_romfile.ImageURL, (img, url) =>
|
||||
{
|
||||
if (url != m_romfile.ImageURL) return;
|
||||
|
||||
@ -82,7 +82,7 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
else
|
||||
{
|
||||
AppAxibugEmuOnline.BeginGame(m_romfile);
|
||||
App.BeginGame(m_romfile);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user