Esempio n. 1
0
 public static void Reload()
 {
     if (!ConfigAPI.ParamExist("server.create_log"))
     {
         ConfigAPI.SetBool("server.create_log", true);
     }
     CreateLog = ConfigAPI.GetBool("server.create_log");
 }
    public void LoadMap()
    {
        if (ConfigAPI.GetInt("players.limit") < 1 | !ConfigAPI.ParamExist("players.limit"))
        {
            ConfigAPI.SetInt("players.limit", 50);
        }
        GetComponent <NetworkManager>().maxConnections = ConfigAPI.GetInt("players.limit");

        if (ConfigAPI.GetInt("server.port") < 500 | ConfigAPI.GetInt("server.port") > 65535 | !ConfigAPI.ParamExist("server.port"))
        {
            ConfigAPI.SetInt("server.port", 20000);
        }
        if (ConfigAPI.GetInt("server.port") != GetComponent <NetworkManager>().networkPort)
        {
            GetComponent <NetworkManager>().networkPort = ConfigAPI.GetInt("server.port");
            //GetComponent<NetworkManager>().matchPort = ConfigAPI.GetInt("server.port");

            GetComponent <NetworkManager>().StopHost();
            GetComponent <NetworkManager>().StartHost();
        }


        m_Message = new MyMsgBase();

        string path = Application.dataPath;

#if UNITY_EDITOR
        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);
        path = Application.dataPath.Replace(Path[Path.Length - 1], "");
#endif
        if (!File.Exists(path + "map.level"))
        {
            File.WriteAllText(path + "map.level", DefaultMap.text);
        }

        m_Message.map = File.ReadAllText(path + "map.level");

        if (!ConfigAPI.ParamExist("map.reload_for_players"))
        {
            ConfigAPI.SetBool("map.reload_for_players", true);
        }
        if (ConfigAPI.GetBool("map.reload_for_players"))
        {
            NetworkServer.SendToAll(MsgID.SendServerMap, m_Message);
        }
    }