void RequestInfo(NetworkMessage netMsg) { ServInfo info = new ServInfo(); #if UNITY_EDITOR string path = "C:\\Users\\evan\\Documents\\Unity\\Compiller\\Angry Dash Server\\" + Application.version + "\\"; #elif UNITY_STANDALONE string[] Path = Application.dataPath.Split(new string[2] { "/", "\\" }, System.StringSplitOptions.None); string path = Application.dataPath.Replace(Path[Path.Length - 1], ""); #endif if (string.IsNullOrEmpty(ConfigAPI.GetString("server.icon"))) { ConfigAPI.SetString("server.icon", "icon.png"); } if (!File.Exists(path + ConfigAPI.GetString("server.icon"))) { File.WriteAllBytes(path + ConfigAPI.GetString("server.icon"), DefaultIcon.texture.EncodeToPNG()); } info.icon = File.ReadAllBytes(path + ConfigAPI.GetString("server.icon")); info.maxPlayer = ConfigAPI.GetInt("players.limit"); info.player = player; if (string.IsNullOrEmpty(ConfigAPI.GetString("server.name"))) { ConfigAPI.SetString("server.name", "Angry Dash Server"); } info.Name = ConfigAPI.GetString("server.name"); NetworkServer.SendToAll(MsgID.SendServerInfo, info); }
public void StartServer() { LoadMap(); //GetComponent<NetworkManager>().StartHost(); NetworkServer.RegisterHandler(MsgID.AskForServerInfo, RequestInfo); NetworkServer.RegisterHandler(MsgID.AskForServerMap, MapRequestReceive); player = 0; #if UNITY_EDITOR string path = "C:\\Users\\evan\\Documents\\Unity\\Compiller\\Angry Dash Server\\" + Application.version + "\\"; #elif UNITY_STANDALONE string[] Path = Application.dataPath.Split(new string[2] { "/", "\\" }, System.StringSplitOptions.None); string path = Application.dataPath.Replace(Path[Path.Length - 1], ""); #endif if (string.IsNullOrEmpty(ConfigAPI.GetString("server.icon"))) { ConfigAPI.SetString("server.icon", "icon.png"); } if (!File.Exists(path + ConfigAPI.GetString("server.icon"))) { File.WriteAllBytes(path + ConfigAPI.GetString("server.icon"), DefaultIcon.texture.EncodeToPNG()); } if (string.IsNullOrEmpty(ConfigAPI.GetString("server.name"))) { ConfigAPI.SetString("server.name", "Angry Dash Server"); } }