();
139 | }
140 |
141 | //========================= UI EVENT Regist Function ==================================
142 | //
143 | //========================================================================
144 | }
145 |
146 |
--------------------------------------------------------------------------------
/src/Controller/CPage.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 |
6 |
7 | // CPage.cs
8 | // Author: Lu Zexi
9 | // 2014-09-19
10 |
11 |
12 |
13 | ///
14 | /// page.
15 | ///
16 | public class CPage : MonoBehaviour
17 | where P : MonoBehaviour
18 | where V : CView
19 | where C : CController
20 | {
21 | public static V s_cView = null; //view
22 | public static C s_cController = null; //controller
23 | private static P s_cInstance; //instance
24 |
25 | public bool IsShow{get;private set;} //is show
26 |
27 | public static P sInstance
28 | {
29 | get
30 | {
31 | if( s_cInstance == null )
32 | {
33 | Type t = typeof(P);
34 | GameObject obj = new GameObject(t.Name);
35 | s_cInstance = obj.AddComponent
();
36 | s_cView = obj.AddComponent();
37 | s_cController = obj.AddComponent();
38 | }
39 | return s_cInstance;
40 | }
41 | }
42 |
43 | ///
44 | /// Raises the load complete event.
45 | ///
46 | /// Res map.
47 | public virtual void OnLoadComplete(Dictionary resMap)
48 | {
49 | s_cView.m_mapRes = resMap;
50 | s_cController.Init();
51 | }
52 |
53 | ///
54 | /// Show this instance.
55 | ///
56 | public virtual void Show()
57 | {
58 | IsShow = true;
59 | }
60 |
61 | ///
62 | /// Init this instance.
63 | ///
64 | public virtual void Init()
65 | {
66 | s_cController.Init();
67 | }
68 |
69 | ///
70 | /// Hiden this instance.
71 | ///
72 | public virtual void Hiden()
73 | {
74 | GameObject.Destroy(this.gameObject);
75 | Resources.UnloadUnusedAssets();
76 | GC.Collect();
77 | }
78 |
79 | ///
80 | /// Raises the destroy event.
81 | ///
82 | void OnDestroy()
83 | {
84 | IsShow = false;
85 | s_cInstance = null;
86 | s_cView = null;
87 | s_cController = null;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/Controller/CPageSwitch.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 |
4 | // UIController.cs
5 | // Author: LU Zexi
6 | // 2014-09-15
7 |
8 |
9 |
10 | public enum SwitchEffect
11 | {
12 | None,
13 | Fade,
14 | Loading,
15 | PretaskNone,
16 | }
17 |
18 |
19 | ///
20 | /// page controller.
21 | ///
22 | public class CPageSwitch
23 | {
24 | public static void SwitchUI(SwitchEffect effect = SwitchEffect.None)
25 | // where T : CPage<>
26 | {
27 | // T.sInstace.Show();
28 | }
29 |
30 | public static void SwitchScene()
31 | {
32 | //
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/src/Controller/CScene.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System;
3 | using System.Collections;
4 |
5 | // BaseScene.cs
6 | // Author: Lu Zexi
7 | // 2014-07-16
8 |
9 |
10 | ///
11 | /// Base scene.
12 | ///
13 | public class CScene
14 | {
15 | protected static CScene s_cCurrentScene;
16 |
17 | public static bool Is(Type type)
18 | {
19 | return type == s_cCurrentScene.GetType();
20 | }
21 |
22 | public static void Switch()
23 | where T : CScene , new()
24 | {
25 | if(s_cCurrentScene != null )
26 | s_cCurrentScene.OnExit();
27 | s_cCurrentScene = new T();
28 | s_cCurrentScene.OnEnter();
29 | }
30 |
31 | ///
32 | /// Raises the enter event.
33 | ///
34 | public virtual void OnEnter()
35 | {
36 | //
37 | }
38 |
39 | ///
40 | /// Raises the exit event.
41 | ///
42 | public virtual void OnExit()
43 | {
44 | //
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Controller/Input/INPUT_INFO.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 |
6 | // INPUT_INFO.cs
7 | // Author: Lu Zexi
8 | // 2014-07-06
9 |
10 |
11 | ///
12 | /// input type
13 | ///
14 | public enum INPUT_TYPE
15 | {
16 | NONE = 0,
17 | HOVER,
18 | PRESS,
19 | SELECT,
20 | CLICK,
21 | DOUBLE_CLICK,
22 | DRAG,
23 | DROP,
24 | INPUT,
25 | TOOLTIP,
26 | SCROLL,
27 | KEY,
28 | MAX
29 | }
30 |
31 | ///
32 | /// the info of the input.
33 | ///
34 | public class INPUT_INFO
35 | {
36 | public INPUT_TYPE m_eType;
37 | public float m_fDelta;
38 | public Vector2 m_vecDelta;
39 | public Vector2 m_vecPos;
40 | public bool m_bDone;
41 | public GameObject m_cTarget;
42 | public string m_strText;
43 | public KeyCode m_eKey;
44 | }
45 |
--------------------------------------------------------------------------------
/src/Controller/Input/UIEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 | using UnityEngine.EventSystems;
5 |
6 |
7 |
8 | // UIEvent.cs
9 | // Author: Lu Zexi
10 | // 2014-07-06
11 |
12 |
13 | ///
14 | /// ui event.
15 | ///
16 | public class UIEvent : UnityEngine.EventSystems.EventTrigger
17 | {
18 | public delegate void PointerEventDelegate ( BaseEventData eventData , GameObject go , object[] arg);
19 | public delegate void BaseEventDelegate ( BaseEventData eventData , GameObject go , object[] arg );
20 | public delegate void AxisEventDelegate ( BaseEventData eventData , GameObject go , object[] arg );
21 |
22 | public object[] m_vecArg = null;
23 |
24 | public BaseEventDelegate onDeselect = null;
25 | public PointerEventDelegate onDrag = null;
26 | public PointerEventDelegate onDrop = null;
27 | public AxisEventDelegate onMove = null;
28 | public PointerEventDelegate onClick = null;
29 | public PointerEventDelegate onDown = null;
30 | public PointerEventDelegate onEnter = null;
31 | public PointerEventDelegate onExit = null;
32 | public PointerEventDelegate onUp = null;
33 | public PointerEventDelegate onScroll = null;
34 | public PointerEventDelegate onSelect = null;
35 | public PointerEventDelegate onUpdateSelect = null;
36 |
37 | public static UIEvent Get(GameObject go)
38 | {
39 | UIEvent listener = go.GetComponent();
40 | if (listener == null) listener = go.AddComponent();
41 | return listener;
42 | }
43 |
44 | public static UIEvent Get(MonoBehaviour go)
45 | {
46 | UIEvent listener = go.GetComponent();
47 | if (listener == null) listener = go.gameObject.AddComponent();
48 | return listener;
49 | }
50 |
51 | public override void OnDeselect( BaseEventData eventData )
52 | {
53 | if(onDeselect != null) onDeselect(eventData , gameObject , this.m_vecArg);
54 | }
55 |
56 | public override void OnDrag( PointerEventData eventData )
57 | {
58 | if(onDrag != null) onDrag(eventData , gameObject , this.m_vecArg);
59 | }
60 |
61 | public override void OnDrop( PointerEventData eventData )
62 | {
63 | if(onDrop != null) onDrop(eventData , gameObject , this.m_vecArg);
64 | }
65 |
66 | public override void OnMove( AxisEventData eventData )
67 | {
68 | if(onMove != null) onMove(eventData , gameObject , this.m_vecArg);
69 | }
70 |
71 | public override void OnPointerClick(PointerEventData eventData)
72 | {
73 | if(onClick != null) onClick(eventData , gameObject , this.m_vecArg);
74 | }
75 |
76 | public override void OnPointerDown (PointerEventData eventData)
77 | {
78 | if(onDown != null) onDown(eventData , gameObject , this.m_vecArg);
79 | }
80 |
81 | public override void OnPointerEnter (PointerEventData eventData)
82 | {
83 | if(onEnter != null) onEnter(eventData , gameObject , this.m_vecArg);
84 | }
85 |
86 | public override void OnPointerExit (PointerEventData eventData)
87 | {
88 | if(onExit != null) onExit(eventData , gameObject , this.m_vecArg);
89 | }
90 | public override void OnPointerUp (PointerEventData eventData)
91 | {
92 | if(onUp != null) onUp(eventData , gameObject , this.m_vecArg);
93 | }
94 |
95 | public override void OnScroll( PointerEventData eventData )
96 | {
97 | if(onScroll != null) onScroll(eventData , gameObject , this.m_vecArg);
98 | }
99 |
100 | public override void OnSelect (BaseEventData eventData)
101 | {
102 | if(onSelect != null) onSelect(eventData , gameObject , this.m_vecArg);
103 | }
104 |
105 | public override void OnUpdateSelected (BaseEventData eventData)
106 | {
107 | if(onUpdateSelect != null) onUpdateSelect(eventData , gameObject , this.m_vecArg);
108 | }
109 | }
110 |
111 |
--------------------------------------------------------------------------------
/src/Controller/UILAYER.cs:
--------------------------------------------------------------------------------
1 | ///
2 | /// UI层级
3 | ///
4 | public enum UILAYER
5 | {
6 | NONE = -1,
7 | GUI_BACKGROUND = 0, //背景层
8 | GUI_MENU = 1, //菜单层0
9 | GUI_MENU1, //菜单层1
10 | GUI_PANEL, //面板层
11 | GUI_PANEL1, //面板1层
12 | GUI_PANEL2, //面板2层
13 | GUI_PANEL3, //面板3层
14 | GUI_FULL, //满屏层
15 | GUI_LOADING, //加载等待层
16 | GUI_MESSAGE, //消息层0
17 | GUI_MESSAGE1, //消息层1
18 | GUI_LOCKPANEL, //Lock面板层
19 | }
20 |
--------------------------------------------------------------------------------
/src/Model/CModel.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 |
6 |
7 | // Model.cs
8 | // Author: Lu Zexi
9 | // 2014-07-05
10 |
11 |
12 |
13 | ///
14 | /// Model类
15 | ///
16 | public abstract class CModel : ScriptableObject , IEnumerable
17 | {
18 | protected static List