Exemple #1
0
 void Start()
 {
     Viewport = transform.GetChild(0).GetChild(0).GetChild(0).gameObject;
     ConfigAPI.Reload();
     Net.StartServer();
     Message("Server start");
 }
Exemple #2
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 = "";
    }