少年修仙传客户端代码仓库
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Snxxz.UI;
using LitJson;
using System.IO;
 
[XLua.LuaCallCSharp]
public class DebugUtility : Singleton<DebugUtility>
{
    const string url = "http://pub.game.2460web.com:11000/dbg_player/?";
 
    GameObject debugRoot;
 
    bool m_DebugAccount = false;
    public bool debugAccount {
        get { return m_DebugAccount; }
        private set {
            if (m_DebugAccount != value)
            {
                m_DebugAccount = value;
                if (m_DebugAccount)
                {
                    RunTimeExceptionUtility.Instance.Init();
                }
            }
        }
    }
 
    public int debugBranch = -1;
 
    public bool isWhiteListAccount { get; private set; }
 
    public void Init()
    {
        isWhiteListAccount = false;
        if (VersionConfig.Get().debugVersion)
        {
            debugAccount = true;
        }
        else
        {
            var parentDirectory = Directory.GetParent(Application.persistentDataPath);
            debugAccount = File.Exists(parentDirectory + "/Debug");
        }
 
        if (debugAccount)
        {
            if (Application.isMobilePlatform)
            {
                var parentDirectory = Directory.GetParent(Application.persistentDataPath);
                if (File.Exists(parentDirectory + "/Debug"))
                {
                    var content = File.ReadAllText(parentDirectory + "/Debug");
                    if (!string.IsNullOrEmpty(content))
                    {
                        var json = JsonMapper.ToObject<DebugBranch>(File.ReadAllText(parentDirectory + "/Debug"));
                        debugBranch = json.branch;
                    }
                }
            }
        }
 
        if (debugAccount)
        {
            DebugEx.EnableLog = LocalSave.GetBool("DesignEnableLog", true);
            DebugEx.EnableLogWarning = LocalSave.GetBool("DesignEnableLogWarning", true);
            DebugEx.EnableLogError = LocalSave.GetBool("DesignEnableLogError", true);
            DebugEx.EnableNetLog = false;
        }
        else
        {
            DebugEx.EnableLog = false;
            DebugEx.EnableLogWarning = false;
            DebugEx.EnableLogError = false;
            DebugEx.EnableNetLog = false;
        }
    }
 
    public void CreateDebugRoot()
    {
        if (debugRoot == null)
        {
            var prefab = BuiltInLoader.LoadPrefab("UIRootDebug");
            debugRoot = GameObject.Instantiate(prefab);
            MonoBehaviour.DontDestroyOnLoad(debugRoot);
            debugRoot.name = "UIRootDebug";
        }
    }
 
    public void RequestWhiteListAuthority(string _account)
    {
        isWhiteListAccount = false;
        var tables = new Dictionary<string, string>();
        tables["channel"] = VersionConfig.Get().appId;
        tables["player"] = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
 
        HttpRequest.Instance.RequestHttpGet(StringUtility.Contact(url, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType, 1, OnDebugAuthority);
    }
 
    private void OnDebugAuthority(bool _ok, string _result)
    {
        if (_ok)
        {
            var debugAuthority = JsonMapper.ToObject<DebugAuthority>(_result);
            isWhiteListAccount = debugAuthority.dbg == 1;
        }
    }
 
    public static void SetLogAble(bool _able)
    {
        LocalSave.SetBool("DesignEnableLog", _able);
        DebugEx.EnableLog = _able;
    }
 
    public static void SetLogWarningAble(bool _able)
    {
        LocalSave.SetBool("DesignEnableLogWarning", _able);
        DebugEx.EnableLogWarning = _able;
    }
 
    public static void SetLogErrorAble(bool _able)
    {
        LocalSave.SetBool("DesignEnableLogError", _able);
        DebugEx.EnableLogError = _able;
    }
 
    public static void SetLogNetAble(bool _able)
    {
        DebugEx.EnableNetLog = _able;
    }
 
    struct DebugAuthority
    {
        public int dbg;
    }
 
    public class DebugBranch
    {
        public int branch = -1;
    }
 
}