少年修仙传客户端代码仓库
leonard Wu
2018-08-07 28a16bc08b937f12031c1f4af0da4ac924fbc212
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Snxxz.UI;
using LitJson;
using System.IO;
 
public class DebugUtility : Singleton<DebugUtility>
{
    const string url = "http://pub.game.secondworld.net.cn: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 (debugAccount)
                {
                    RunTimeExceptionUtility.Instance.Init();
                }
            }
        }
    }
 
    public void Init()
    {
        if (VersionConfig.Get().debugVersion)
        {
            debugAccount = true;
        }
        else
        {
            var parentDirectory = Directory.GetParent(Application.persistentDataPath);
            debugAccount = File.Exists(parentDirectory + "/Debug");
        }
    }
 
    public void CreateDebugRoot()
    {
        if (debugRoot == null)
        {
            var prefab = Resources.Load<GameObject>("UI/Prefabs/UIRootDebug");
            debugRoot = GameObject.Instantiate(prefab);
            MonoBehaviour.DontDestroyOnLoad(debugRoot);
            debugRoot.name = "UIRootDebug";
        }
    }
 
    public void RequestDebugAuthority(string _account)
    {
        debugAccount = 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);
            debugAccount = debugAuthority.dbg == 1;
        }
    }
 
    struct DebugAuthority
    {
        public int dbg;
    }
 
}