diff options
Diffstat (limited to 'Client/Assets/Scripts/GameSirControl')
-rw-r--r-- | Client/Assets/Scripts/GameSirControl/XGameSirControl.cs | 123 | ||||
-rw-r--r-- | Client/Assets/Scripts/GameSirControl/XGameSirControl.cs.meta | 8 |
2 files changed, 131 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/GameSirControl/XGameSirControl.cs b/Client/Assets/Scripts/GameSirControl/XGameSirControl.cs new file mode 100644 index 00000000..e8e0e371 --- /dev/null +++ b/Client/Assets/Scripts/GameSirControl/XGameSirControl.cs @@ -0,0 +1,123 @@ +using UnityEngine;
+using System.Collections;
+#if (UNITY_IOS || UNITY_ANDROID ) && GAMESIR && !UNITY_EDITOR
+using Gamesir;
+#endif
+
+using XUtliPoolLib;
+public class XGameSirControl : MonoBehaviour,IXGameSirControl
+{
+ private bool mIsOpen = false;
+ public void ShowGameSirDialog()
+ {
+#if (UNITY_IOS || UNITY_ANDROID ) && GAMESIR && !UNITY_EDITOR
+ if(mIsOpen){
+ GamesirInput.Instance().OpenConnectDialog();
+ }
+#endif
+ }
+
+ public int GetGameSirState()
+ {
+ #if (UNITY_IOS || UNITY_ANDROID )&& GAMESIR && !UNITY_EDITOR
+ if(mIsOpen)
+ return GamesirInput.Instance().GetGameSirState();
+ else
+ return 0;
+#else
+ return 0;
+#endif
+ }
+
+
+ public float GetAxis(string axisName)
+ {
+ #if (UNITY_IOS || UNITY_ANDROID ) && GAMESIR && !UNITY_EDITOR
+ if(mIsOpen)
+ return GamesirInput.Instance().GetAxis(axisName);
+ else
+ return 0;
+
+#else
+ return 0;
+#endif
+ }
+
+ public bool GetButton(string buttonName)
+ {
+#if (UNITY_IOS || UNITY_ANDROID )&& GAMESIR && !UNITY_EDITOR
+ if(mIsOpen)
+ return GamesirInput.Instance().GetButton(buttonName);
+ else
+ return false;
+#else
+ return false;
+#endif
+ }
+
+ public bool IsOpen
+ {
+ get{ return mIsOpen;}
+ }
+
+ public void Init()
+ {
+
+ }
+
+ void Start()
+ {
+ //GamesirInput.Instance().SetDebug (true);
+ #if(UNITY_IOS || UNITY_ANDROID)&& GAMESIR && !UNITY_EDITOR
+ GamesirInput.Instance().SetIconLocation(IconLocation.BOTTOM_CENTER);
+ GamesirInput.Instance().setHiddenConnectIcon(true);
+ GamesirInput.Instance().onStart();
+ mIsOpen = true;
+ #else
+ mIsOpen = false;
+ #endif
+ }
+
+ public void StartSir()
+ {
+
+ #if(UNITY_IOS || UNITY_ANDROID) && GAMESIR && !UNITY_EDITOR
+ if(!IsConnected())
+ GamesirInput.Instance().AutoConnectToGCM();
+ #endif
+ }
+
+ public void StopSir()
+ {
+#if(UNITY_IOS || UNITY_ANDROID) && GAMESIR && !UNITY_EDITOR
+ if(IsConnected())
+ GamesirInput.Instance().DisConnectGCM();
+#endif
+ }
+
+ public bool IsConnected()
+ {
+ #if (UNITY_IOS || UNITY_ANDROID )&& GAMESIR && !UNITY_EDITOR
+ return mIsOpen && GetGameSirState() == 3;
+#else
+ return false;
+#endif
+ }
+
+
+ void OnDestroy()
+ {
+#if (UNITY_IOS || UNITY_ANDROID ) && GAMESIR&& !UNITY_EDITOR
+ if(mIsOpen)
+ GamesirInput.Instance().OnDestory();
+#endif
+ }
+
+ void OnApplicationQuit()
+ {
+#if (UNITY_IOS || UNITY_ANDROID )&& GAMESIR && !UNITY_EDITOR
+ if(mIsOpen)
+ GamesirInput.Instance().OnQuit();
+#endif
+ }
+}
diff --git a/Client/Assets/Scripts/GameSirControl/XGameSirControl.cs.meta b/Client/Assets/Scripts/GameSirControl/XGameSirControl.cs.meta new file mode 100644 index 00000000..85cbb58c --- /dev/null +++ b/Client/Assets/Scripts/GameSirControl/XGameSirControl.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2
+guid: eda84915548bc9d4ab3ec94f09985b80
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
|