少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Snxxz.UI;
using LitJson;
 
public class DebugLogin : MonoBehaviour
{
    public InputField appid;
    public InputField serverId;
    public InputField account;
    public InputField password;
    public InputField platform;
 
    public Toggle isToken;
 
    string appidRecorder {
        get { return LocalSave.GetString("DebugLogin_AppId"); }
        set { LocalSave.SetString("DebugLogin_AppId", value); }
    }
 
    string serverIdRecorder {
        get { return LocalSave.GetString("DebugLogin_ServerId"); }
        set { LocalSave.SetString("DebugLogin_ServerId", value); }
    }
 
 
    string accountRecorder {
        get { return LocalSave.GetString("DebugLogin_Account"); }
        set { LocalSave.SetString("DebugLogin_Account", value); }
    }
 
    string passwordRecorder {
        get { return LocalSave.GetString("DebugLogin_Password"); }
        set { LocalSave.SetString("DebugLogin_Password", value); }
    }
 
    int platformRecorder {
        get {
            return LocalSave.GetInt("DebugLoging_Platform", 1);
        }
        set {
            LocalSave.SetInt("DebugLoging_Platform", value);
        }
    }
 
    bool istokenRecorder {
        get { return LocalSave.GetBool("DebugLogin_IsToken", false); }
        set { LocalSave.SetBool("DebugLogin_IsToken", value); }
    }
 
    private void OnEnable()
    {
        appid.text = appidRecorder;
        serverId.text = serverIdRecorder;
        account.text = accountRecorder;
        password.text = passwordRecorder;
        platform.text = platformRecorder.ToString();
        isToken.isOn = istokenRecorder;
    }
 
    public void Login()
    {
        appidRecorder = appid.text;
        serverIdRecorder = serverId.text;
        accountRecorder = account.text;
        passwordRecorder = password.text;
        var platformTemp = 0;
        int.TryParse(platform.text, out platformTemp);
        platformRecorder = platformTemp;
        istokenRecorder = isToken.isOn;
 
        if (!string.IsNullOrEmpty(appid.text))
        {
            VersionConfig.Get().m_AppId = appid.text;
        }
 
        SDKUtility.Instance.ChannelPlatform = (SDKUtility.E_ChannelPlatform)int.Parse(platform.text);
 
        if (isToken.isOn)
        {
            var loginModel = ModelCenter.Instance.GetModel<LoginModel>();
            loginModel.sdkLoginResult = new SDKUtility.FP_LoginOk()
            {
                account = account.text,
                token = password.text,
                tokenExpire = "1519750743000",
                phone = 0,
                accountID = 1000
            };
 
            loginModel.sdkLogined = true;
            var ip = ServerListCenter.Instance.currentServer.region_domain;
            var port = ServerListCenter.Instance.currentServer.login_port;
            var gamePort = ServerListCenter.Instance.currentServer.game_port;
            if (!string.IsNullOrEmpty(serverId.text))
            {
                var serverData = ServerListCenter.Instance.currentServer;
                serverData.region_flag = int.Parse(serverId.text);
                ServerListCenter.Instance.currentServer = serverData;
            }
 
            loginModel.AccountLogin(ip, port, gamePort);
        }
        else
        {
            SDKLogin(account.text, password.text);
        }
    }
 
    private void SDKLogin(string _account, string _password)
    {
        var tables = new Dictionary<string, string>();
        tables["account"] = _account;
        tables["password"] = _password;
        var url = "http://zysdk.zytxgame.com/api.php/Index/login?";
        HttpRequest.Instance.RequestHttpGet(StringUtility.Contact(url, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType, 1, SDKLoginCallBack);
    }
 
    private void SDKLoginCallBack(bool _ok, string _result)
    {
        if (_ok)
        {
            var result = JsonMapper.ToObject<SDKLoginResult>(_result);
            if (result.errorcode == "1")
            {
                var loginModel = ModelCenter.Instance.GetModel<LoginModel>();
                loginModel.sdkLogined = true;
                loginModel.sdkLoginResult = new SDKUtility.FP_LoginOk()
                {
                    account = result.account,
                    token = result.token,
                    phone = int.Parse(result.phone),
                    accountID = int.Parse(result.account_id),
                    tokenExpire = result.token_expire,
                };
 
                SDKUtility.Instance.FreePlatformCheckIDAuthentication(result.account);
                var ip = ServerListCenter.Instance.currentServer.region_domain;
                var port = ServerListCenter.Instance.currentServer.login_port;
                var gamePort = ServerListCenter.Instance.currentServer.game_port;
                if (!string.IsNullOrEmpty(serverId.text))
                {
                    var serverData = ServerListCenter.Instance.currentServer;
                    serverData.region_flag = int.Parse(serverId.text);
                    ServerListCenter.Instance.currentServer = serverData;
                }
 
                loginModel.AccountLogin(ip, port, gamePort);
            }
            else
            {
                ServerTipDetails.DisplayNormalTip(result.errordesc);
            }
        }
        else
        {
            ServerTipDetails.DisplayNormalTip(Language.Get("LoginFailed_Z"));
        }
    }
 
    struct SDKLoginResult
    {
        public string errorcode;
        public string errordesc;
        public string token;
        public string account;
        public string token_expire;
        public string phone;
        public string account_id;
    }
}