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);
    }
示例#2
0
        public ActionResult ConfigAPI(int MaNCC)
        {
            var a1 = new ConfigAPI();

            a1.NhaCungCapId = MaNCC;
            return(View(a1));
        }
    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");
        }
    }
示例#4
0
        public ActionResult ConfigAPI(string MaNCC)
        {
            ConfigAPI a1 = new ConfigAPI();

            a1.MaNCC = MaNCC;
            return(View(a1));
        }
示例#5
0
 void Start()
 {
     Viewport = transform.GetChild(0).GetChild(0).GetChild(0).gameObject;
     ConfigAPI.Reload();
     Net.StartServer();
     Message("Server start");
 }
示例#6
0
 public static void Reload()
 {
     if (!ConfigAPI.ParamExist("server.create_log"))
     {
         ConfigAPI.SetBool("server.create_log", true);
     }
     CreateLog = ConfigAPI.GetBool("server.create_log");
 }
示例#7
0
        public ActionResult ConfigAPI(ConfigAPI a)
        {
            ConfigAPIModel model = new ConfigAPIModel();

            if (model.ThemmoiConfig(a))
            {
                return(RedirectToAction("GetNhaDoiTac"));
            }
            return(View(a));
        }
    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);
        }
    }
 public static void onServerJoinHandler(Player JoinedPlayer)
 {
     if (ConfigAPI.loadProfile(JoinedPlayer))
     {
         PlayerAPI.createPlayer(JoinedPlayer);
         ColourEngine.write("[Project Eco] ", ConsoleColor.Magenta, Console.BackgroundColor);
         ColourEngine.writeLine("Welcome " + JoinedPlayer.playerName + " to the server!", ConsoleColor.Red, Console.BackgroundColor);
     }
     else
     {
         ServerAPI.playerList.Add(JoinedPlayer);
         ColourEngine.write("[Project Eco] ", ConsoleColor.Magenta, Console.BackgroundColor);
         ColourEngine.writeLine(JoinedPlayer.playerName + " joined the server.", ConsoleColor.Yellow, Console.BackgroundColor);
     }
 }
示例#10
0
        public ActionResult Taohopdong(HopDongNCC a)
        {
            HopdongNCCModel Ncc = new HopdongNCCModel();

            if (ModelState.IsValid)
            {
                string MaHD;
                if ((MaHD = Ncc.ThemmoiHopDongNCC(a)) != "")
                {
                    ConfigAPI a1 = new ConfigAPI();
                    a1.MaNCC = a.MaNCC;
                    return(View("ConfigAPI", a1));
                }
            }

            ViewBag.TenNCC = new SelectList(Ncc.getDsNhaCC(), "MaNCC", "TenNCC");
            ViewBag.MaSP   = new SelectList(Ncc.getDsSanPham(), "ID", "TenSP");
            return(View(a));
        }
示例#11
0
        public ActionResult Taohopdong(HopDongNcc hopDong)
        {
            var Ncc = new HopdongNCCModel();

            if (ModelState.IsValid)
            {
                string MaHD;
                if (Ncc.ThemmoiHopDongNCC(hopDong) != 0)
                {
                    var a1 = new ConfigAPI();
                    a1.NhaCungCapId = hopDong.NccId;
                    return(View("ConfigAPI", a1));
                }
            }

            ViewBag.TenNCC = new SelectList(Ncc.getDsNhaCC(), "NhaCungCapId", "TenNcc");
            ViewBag.MaSP   = new SelectList(Ncc.getDsSanPham(), "Id", "TenSP");
            return(View(hopDong));
        }
 public bool ThemmoiConfig(ConfigAPI a)
 {
     using (Entities db = new Entities())
     {
         try
         {
             if (kiemtratontai(a.MaNCC, db))
             {
                 db.Entry(a).State = EntityState.Modified;
                 db.SaveChanges();
             }
             else
             {
                 db.ConfigAPIs.Add(a);
                 db.SaveChanges();
             }
             return(true);
         }
         catch (Exception e) { return(false); }
     }
 }
示例#13
0
 public bool ThemmoiConfig(ConfigAPI a)
 {
     using (var db = new MainContext())
     {
         try
         {
             if (kiemtratontai(a.NhaCungCapId, db))
             {
                 db.Entry(a).State = EntityState.Modified;
                 db.SaveChanges();
             }
             else
             {
                 db.ConfigApIs.Add(a);
                 db.SaveChanges();
             }
             return(true);
         }
         catch (Exception e) { return(false); }
     }
 }
示例#14
0
    public void CommandEnter()
    {
        if (string.IsNullOrEmpty(IF.text))
        {
            Message("Please enter a command", 1);
        }
        else
        {
            lastCMD   = lastCMD.Union(new string[] { IF.text }).ToArray();
            CMDactual = "";
            string cmd = IF.text.Split(new string[1] {
                " "
            }, System.StringSplitOptions.None)[0].ToLower();
            string[] args = IF.text.Replace(cmd + " ", "").Split(new string[1] {
                " "
            }, System.StringSplitOptions.None);

            if (cmd == "stop")
            {
                Message("Stopping server ...");
                Net.Disconnect();
                Message("The server stopped");
            }
            else if (cmd == "color")
            {
                bool      done     = false;
                Color32[] newColor = new Color32[textColor.Length];
                try
                {
                    for (int i = 0; i < args.Length; i++)
                    {
                        newColor[i] = Base.HexToColor(args[i]);
                    }
                    done = true;
                }
                catch { Message("Syntax error, all data need to be hex : color {main} {info} {error}", 2); }

                if (done)
                {
                    textColor = newColor;
                    for (int i = 0; i < MessagesList.Count; i++)
                    {
                        MessagesList[i].textObject.color = textColor[MessagesList[i].type];
                    }
                    Message("The colors have been changed");
                }
            }
            else if (cmd == "reload")
            {
                ConfigAPI.Reload();
                Message("The config file has been reload");
                Net.LoadMap();
                Message("The map has been reload");
            }
            else if (cmd == "info")
            {
                if (Net.player > 1)
                {
                    Message(Net.player + " players connected", 1);
                }
                else
                {
                    Message(Net.player + " player connected", 1);
                }
                Message("", 1);
                Message("Angry Dash Server v" + Application.version, 1);
                Message("Coded by EvanG", 1);
                Message("©" + DateTime.Now.Year + " 06Games. All rights reserved.", 1);
            }
            else if (cmd == "clear")
            {
                for (int i = 0; i < Viewport.transform.childCount; i++)
                {
                    Destroy(Viewport.transform.GetChild(i).gameObject);
                }
                Log.LogNewMessage("Terminal has been cleared", false);
            }
            else
            {
                Message(IF.text + " : unkown command", 1);
            }
        }

        IF.text = "";
    }
示例#15
0
 public SecureController()
 {
     _configAPI     = new ConfigAPI();
     _currentConfig = new Config();
     _currentConfig = _configAPI.GetConfig();
 }