summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/LuaEngine/LuaEngine.cs
blob: 0de305ea7210e36650e8a8b652186554bbac52a7 (plain)
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
//
// LuaEngine.cs
// Created by huailiang.peng on 2016/04/14 11:39:07
//

using UnityEngine;
using System.Collections;
using LuaCore;
using System.IO;
using LuaInterface;
using XUtliPoolLib;


public class LuaEngine : MonoBehaviour, ILuaEngine
{

    public static LuaEngine Instance = null;

    void Awake()
    {
        Instance = this;
    }


    void OnDestroy()
    {
        HotfixManager.Instance.Dispose();
        Instance = null;
    }



    bool gui = false;
    //string cname = "LuaEngine";
    string origin_text = "des";
    string des_text = "code";
    int y = 200;

#if UNITY_EDITOR
    void OnGUI()
    {

        if (gui)
        {
            GUI.color = Color.red;
            y = 200;
            GUI.Label(new Rect(20, y, 700, 30), "HOTFIX TOOL");
            GUI.color = Color.white;

            GUI.color = Color.green;
            y += 40;
            GUI.Label(new Rect(20, y, 100, 30), "Click Btn Path:");
            y += 30;
            GUI.TextArea(new Rect(20, y, 700, 20), UICamera.clickpath);

           y += 30;
           GUI.Label(new Rect(20, y, 280, 30), "Test DES Encryption");
           y += 30;
           origin_text = GUI.TextField(new Rect(20, y, 180, 20), origin_text);
           if (GUI.Button(new Rect(220, y, 80, 24), "Encrypt"))
           {
               des_text = Encryption.Encrypt(origin_text);
               Debug.Log(des_text);
           }
           if (GUI.Button(new Rect(320, y, 80, 24), "Decrypt"))
           {
               Debug.Log(Encryption.Decrypt(des_text));
           }
        }
    }
#endif
    private bool init = false;

    public void InitLua()
    {
        init = true;
        TimerManager.Instance.Init();     
        HotfixManager.Instance.LoadHotfix(OnInitFinish);
    }


    void Update()
    {
        if (init)
        {
            TimerManager.Instance.Update();
        }
#if UNITY_EDITOR
        if (Input.GetKeyUp(KeyCode.F5))
        {
            //gui = !gui;
        }
#endif
    }

    void OnApplicationPause(bool pause)
    {
        HotfixManager.Instance.OnPause(pause);
    }

    private void OnInitFinish()
    {
        Debug.Log("Hotfix init finish!");
    }


    public IHotfixManager hotfixMgr
    {
        get
        {
            return HotfixManager.Instance as IHotfixManager;
        }
    }

    public ILuaUIManager luaUIManager
    {
        get
        {
            return LuaUIManager.Instance as ILuaUIManager;
        }
    }

    public ILuaGameInfo luaGameInfo
    {
        get
        {
            return LuaGameInfo.single as ILuaGameInfo;
        }
    }
}