示例#1
0
    public async void Login()
    {
        var send = new KeyValueProtocol();

        send["username"] = Input("username").text;

        if (Input("password").text == PlayerPrefs.GetString("lastLoginToken"))
        {
            send["loginToken"] = Input("password").text;
            send["cmd"]        = "loginByToken";
        }
        else
        {
            send["password"] = StringTool.MD5(Input("password").text);
            send["cmd"]      = "login";
        }
        var receive = await DataHttpClient.PostAsync(DataServerUrl, send);

        if (receive["status"] == "成功")
        {
            PlayerPrefs.SetString("lastUsername", receive["username"]);
            PlayerPrefs.SetString("lastLoginToken", receive["loginToken"]);
            username   = send["username"];
            loginToken = receive["loginToken"];
            UnityEngine.SceneManagement.SceneManager.LoadScene("Main");
        }
        else
        {
            IDGUI.Log(receive["info"]);
            Input("username").text = "";
            Input("password").text = "";
        }
    }
示例#2
0
    public async Task <Character> GetCharacter()
    {
        var send = SendToken();

        send["cmd"] = "getCharacter";
        var receive = await DataHttpClient.PostAsync(DataServerUrl, send);

        var characters_count = receive["characters_count"];

        if (string.IsNullOrEmpty(characters_count))
        {
            return(null);
        }
        if (characters_count != null && int.Parse(characters_count) > 0)
        {
            return(new Character()
            {
                info = receive["character_info0"],
                id = receive["character_id0"]
            });
        }
        else
        {
            return(null);
        }
    }
示例#3
0
    public async void Ready()
    {
        var send = SendToken();

        send["cmd"]   = "switchReady";
        send["ready"] = true.ToString();
        var receive = await DataHttpClient.PostAsync(DataServerUrl, send);
    }
示例#4
0
    public async void Matching()
    {
        var send = SendToken();

        send["cmd"] = "matching";
        var receive = await DataHttpClient.PostAsync(DataServerUrl, send);

        Debug.LogError(receive.GetString());
    }
示例#5
0
    public async void FastLogin()
    {
        if (PlayerPrefs.HasKey("last_username") && PlayerPrefs.HasKey("last_token"))
        {
        }
        var send = new KeyValueProtocol();

        send["cmd"] = "fastRegister";
        var receive = await DataHttpClient.PostAsync(DataServerUrl, send);
    }
示例#6
0
    public async Task <bool> DeleteCharacter(string id)
    {
        var send = SendToken();

        send["cmd"]          = "deleteCharacter";
        send["character_id"] = id;
        var receive = await DataHttpClient.PostAsync(DataServerUrl, send);

        return(Success(receive));
    }
示例#7
0
    public async Task <bool> CreateCharacter()
    {
        var send = SendToken();

        send["cmd"] = "createCharacter";

        var receive = await DataHttpClient.PostAsync(DataServerUrl, send);

        return(Success(receive));
    }
示例#8
0
    public async Task <FightRoom> GetFightRoom()
    {
        var send = SendToken();

        send["cmd"] = "getFightRoom";
        var receive = await DataHttpClient.PostAsync(DataServerUrl, send);

        if (receive["status"] == "成功")
        {
            return(JsonConvert.DeserializeObject <FightRoom>(receive["fightRoom"]));
        }
        else
        {
            return(null);
        }
    }
示例#9
0
    public async Task <Character> GetCharacter()
    {
        var send = SendToken();

        send["cmd"] = "getCharacter";
        var receive = await DataHttpClient.PostAsync(DataServerUrl, send);

        if (int.Parse(receive["characters_count"]) > 0)
        {
            return(new Character()
            {
                info = receive["character_info0"],
                id = receive["character_id0"]
            });
        }
        else
        {
            return(null);
        }
    }
示例#10
0
    public async void Register()
    {
        var send = new KeyValueProtocol();

        send["username"] = Input("username").text;
        send["password"] = StringTool.MD5(Input("password").text);
        send["cmd"]      = "register";
        var receive = await DataHttpClient.PostAsync(DataServerUrl, send);

        if (receive["status"] == "成功")
        {
            Login();
        }
        else
        {
            IDGUI.Log(receive["info"]);
            Input("username").text = "";
            Input("password").text = "";
        }
    }