Ejemplo n.º 1
0
        private void login_Click(object sender, RoutedEventArgs e)
        {
            GameSparksSettings.SetApiKey("xxx");
            GameSparksSettings.SetCredentials("xxx");
            GameSparksSettings.SetSecret("xxx");
            GameSparksSettings.SetIsLive(false);
            var    authService = new GameSparksAuthenticationService();
            string user        = username.Text;
            string pass        = password.Password;
            //Auth Login
            var authRequest = new AuthenticationRequest(user, pass);
            var response    = authService.AuthenticationRequest(authRequest);

            Console.WriteLine(response.DisplayName);
            if (response.DisplayName == null)
            {
                Console.WriteLine("Incorrect Login Information");
                ErrorMessage.Text = "Incorrect Login Information";
            }
            else
            {
                ErrorMessage.Text = "";
                Console.WriteLine("Auth token: " + response.AuthToken);
                Console.WriteLine("User ID: " + response.UserId);
                Properties.Settings.Default.UserID = response.UserId;

                // Load Hub
                mainhub hub = new mainhub();
                hub.Show();
                this.Close();
            }
        }
Ejemplo n.º 2
0
        public static void Initialize()
        {
            string apiKey      = "R314803U8WmT";
            string credentials = "server";
            string secret      = "iXxGLT92D3k9Gn8r4UGljcKmWUgUmqAk";
            bool   isLive      = false;

            GameSparksSettings.Set(apiKey, credentials, secret, isLive);
        }
Ejemplo n.º 3
0
        protected override void Start()
        {
            timerController = new TimerController();
            timerController.Initialize();

            webSocketController = gameObject.AddComponent <WebSocketController>();

            var gameSparksUnity = GetComponent <GameSparksUnity>();

            GameSparksSettings.SetInstance(gameSparksUnity.settings);

            base.Start();
        }
Ejemplo n.º 4
0
        protected override void Start()
        {
            timerController = new TimerController();
            timerController.Initialize();



            // Register crypto implementation
            GSInitializeCrypto();

            // Register socket implementation
            GSInitializeGSSocket();

            webSocketController = gameObject.AddComponent <WebSocketController>();

            var gameSparksUnity = GetComponent <GameSparksUnity>();

            GameSparksSettings.SetInstance(gameSparksUnity.settings);

            base.Start();
        }
Ejemplo n.º 5
0
        public static GameSparksSettings GetOrCreateSettingsAsset()
        {
            string fullPath = Path.Combine(Path.Combine(UnityAssetFolder, GameSparksSettings.gamesparksSettingsPath),
                                           GameSparksSettings.gamesparksSettingsAssetName + GameSparksSettings.gamesparksSettingsAssetExtension
                                           );

            GameSparksSettings instance = AssetDatabase.LoadAssetAtPath(fullPath, typeof(GameSparksSettings)) as GameSparksSettings;

            if (instance == null)
            {
                // no asset found, we need to create it.

                if (!Directory.Exists(Path.Combine(UnityAssetFolder, GameSparksSettings.gamesparksSettingsPath)))
                {
                    AssetDatabase.CreateFolder(Path.Combine(UnityAssetFolder, "GameSparks"), "Resources");
                }

                instance = CreateInstance <GameSparksSettings>();
                AssetDatabase.CreateAsset(instance, fullPath);
                AssetDatabase.SaveAssets();
            }
            return(instance);
        }
Ejemplo n.º 6
0
 public static void SetInstance(GameSparksSettings settings)
 {
     instance = settings;
 }
Ejemplo n.º 7
0
        virtual protected void Start()
        {
            DeviceName = SystemInfo.deviceName.ToString();
            DeviceType = SystemInfo.deviceType.ToString();
#if UNITY_ANDROID && !UNITY_EDITOR && UNITY_5_3
            if (true)
#elif UNITY_5_4_OR_NEWER
            if (Application.platform == RuntimePlatform.PS4 || Application.platform == RuntimePlatform.XboxOne ||
                SystemInfo.unsupportedIdentifier == SystemInfo.deviceUniqueIdentifier)
#else
            if (Application.platform == RuntimePlatform.PS4 || Application.platform == RuntimePlatform.XboxOne)
#endif
            {
#if GS_DONT_USE_PLAYER_PREFS || UNITY_SWITCH
        #if UNITY_5_4_OR_NEWER
                if (SystemInfo.unsupportedIdentifier == SystemInfo.deviceUniqueIdentifier)
                {
                    DeviceId = System.Guid.NewGuid().ToString();
                }
                else
                {
                    DeviceId = SystemInfo.deviceUniqueIdentifier.ToString();
                }
        #else
                DeviceId = System.Guid.NewGuid().ToString();
        #endif
#else
                DeviceId = PlayerPrefs.GetString(PLAYER_PREF_DEVICEID_KEY);
                if (DeviceId.Equals(""))
                {
                    DeviceId = System.Guid.NewGuid().ToString();

                    PlayerPrefs.SetString(PLAYER_PREF_DEVICEID_KEY, DeviceId);
                    PlayerPrefs.Save();
                }
#endif
            }
            else
            {
                DeviceId = SystemInfo.deviceUniqueIdentifier.ToString();
            }

            char[]   delimiterChars = { ' ', ',', '.', ':', '-', '_', '(', ')' };
            int      cpuCores       = SystemInfo.processorCount;
            string   manufacturer   = "Unknown";
            string   model          = SystemInfo.deviceModel;
            string   memory         = SystemInfo.systemMemorySize + " MB";
            string   osName         = SystemInfo.operatingSystem;
            string   osVersion      = SystemInfo.operatingSystem;
            string   cpuVendor      = SystemInfo.processorType;
            string   resolution     = Screen.width + "x" + Screen.height;
            string   gssdk          = GameSparks.Core.GS.Version;
            string   engine         = SDK;
            string   engineVersion  = Application.unityVersion;
            string[] listStrings;

            switch (DeviceOS)
            {
            case "MACOS":
            case "IOS":
            case "TVOS":
                manufacturer = "Apple";
                listStrings  = SystemInfo.operatingSystem.Split(delimiterChars);
                if (DeviceOS.Equals("MACOS"))
                {
                    osName    = listStrings [0] + " " + listStrings [1] + " " + listStrings[2];
                    osVersion = listStrings [3] + "." + listStrings [4] + "." + listStrings[5];
                }
                else
                {
                    //if (listStrings[0].Equals("iOS")) {
                    osName    = listStrings [0];
                    osVersion = listStrings [1] + "." + listStrings [2];
                    //} else {
                    //	osName = listStrings [0] + " " + listStrings [1];
                    //	osVersion = listStrings [2] + "." + listStrings [3];
                    //}
                }

                break;

            case "WINDOWS":
            case "WSA":
            case "XBOXONE":
                manufacturer = "Microsoft";
                if (DeviceOS.Equals("XBOXONE"))
                {
                    model     = "Xbox One";
                    memory    = (SystemInfo.systemMemorySize / 1000) + " MB";
                    osVersion = "Unknown";
                }
                else
                {
                    model       = "PC";
                    listStrings = SystemInfo.operatingSystem.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
                    osName      = listStrings [0] + " " + listStrings [1];
                    osVersion   = listStrings [2] + "." + listStrings [3] + "." + listStrings[4];
                }
                cpuVendor += " " + SystemInfo.processorFrequency.ToString() + "MHz";

                RegexOptions options = RegexOptions.None;
                Regex        regex   = new Regex("[ ]{2,}", options);

                cpuVendor = regex.Replace(cpuVendor, " ");

                break;

            case "ANDROID":
                listStrings  = SystemInfo.deviceModel.Split(delimiterChars);
                manufacturer = listStrings [0];
                model        = SystemInfo.deviceModel.Replace(manufacturer, "").Substring(1);
                listStrings  = SystemInfo.operatingSystem.Split(delimiterChars);
                osName       = listStrings [0] + " " + listStrings [1];
                osVersion    = listStrings [7];
                cpuVendor   += " " + SystemInfo.processorFrequency + "MHz";

                break;

#if !UNITY_2017_3_OR_NEWER
            case "SAMSUNGTV":
                manufacturer = "Samsung";

                break;
#endif

            case "WIIU":
                manufacturer = "Nintendo";
                model        = "WiiU";

                break;

            case "SWITCH":
                manufacturer = "Nintendo";
                model        = "Switch";
                osVersion    = "Unknown";

                break;

            case "PS4":
                manufacturer = "Sony";
                model        = "PS4";
                memory       = (SystemInfo.systemMemorySize / 1000000) + " MB";
                listStrings  = SystemInfo.operatingSystem.Split(delimiterChars);
                osName       = listStrings [0];
                osVersion    = listStrings [1] + "." + listStrings [2] + "." + listStrings[3];
                cpuVendor   += " " + SystemInfo.processorFrequency + "MHz";

                break;

            case "TIZEN":
                manufacturer = "Tizen";

                break;

            case "WEBGL":
                listStrings = SystemInfo.deviceModel.Split(delimiterChars);
                model       = listStrings [0];
                listStrings = SystemInfo.operatingSystem.Split(delimiterChars);
                osName      = listStrings [0];
                if (osName.Equals("Mac"))
                {
                    osName   += " " + listStrings [1] + " " + listStrings [2];
                    osVersion = listStrings [3] + "." + listStrings [4] + "." + listStrings [5];
                }
                else
                {
                    osVersion = listStrings [1];
                }

                break;
            }

            Dictionary <string, object> data = new Dictionary <string, object> ();

            data.Add("manufacturer", manufacturer);
            data.Add("model", model);
            data.Add("memory", memory);
            data.Add("os.name", osName);
            data.Add("os.version", osVersion);
            data.Add("cpu.cores", cpuCores.ToString());
            data.Add("cpu.vendor", cpuVendor);
            data.Add("resolution", resolution);
            data.Add("gssdk", gssdk);
            data.Add("engine", engine);
            data.Add("engine.version", engineVersion);

            DeviceStats = new GSData(data);

            /*Debug.Log (DeviceStats.GetString ("manufacturer"));
             *          Debug.Log (DeviceStats.GetString ("model"));
             *          Debug.Log (DeviceStats.GetString ("memory"));
             *          Debug.Log (DeviceStats.GetString ("os.name"));
             *          Debug.Log (DeviceStats.GetString ("os.version"));
             *          Debug.Log (DeviceStats.GetString ("cpu.cores"));
             *          Debug.Log (DeviceStats.GetString ("cpu.vendor"));
             *          Debug.Log (DeviceStats.GetString ("resolution"));
             *          Debug.Log (DeviceStats.GetString ("gssdk"));
             *          Debug.Log (DeviceStats.GetString ("engine"));
             *          Debug.Log (DeviceStats.GetString ("engine.version"));*/

#if !GS_DONT_USE_PLAYER_PREFS && !UNITY_SWITCH
            AuthToken = PlayerPrefs.GetString(PLAYER_PREF_AUTHTOKEN_KEY);
            UserId    = PlayerPrefs.GetString(PLAYER_PREF_USERID_KEY);
#endif
            Platform = Application.platform.ToString();

            var gameSparksUnity = GetComponent <GameSparksUnity>();
            GameSparksSettings.SetInstance(gameSparksUnity.settings);

            ExtraDebug = GameSparksSettings.DebugBuild;

#if !UNITY_WEBPLAYER && !UNITY_SWITCH
            PersistentDataPath = Application.persistentDataPath;
#endif

            GS.Initialise(this);

            DontDestroyOnLoad(this);

#if UNITY_EDITOR
        #if UNITY_2017_2_OR_NEWER
            EditorApplication.playModeStateChanged += HandlePlayModeStateChanged;
        #else
            EditorApplication.playmodeStateChanged += HandlePlayModeStateChanged;
        #endif
#endif
        }
Ejemplo n.º 8
0
 void OnDisable()
 {
     // make sure the runtime code will load the Asset from Resources when it next tries to access this.
     GameSparksSettings.SetInstance(null);
 }
Ejemplo n.º 9
0
        public override void OnInspectorGUI()
        {
            GameSparksSettings settings = (GameSparksSettings)target;

            GameSparksSettings.SetInstance(settings);

            GUILayout.TextArea("SDK Version : " + GameSparks.Core.GS.Version, EditorStyles.wordWrappedLabel);

            EditorGUILayout.HelpBox("Add the GameSparks Api Key and Secret associated with this game", MessageType.None);

            EditorGUILayout.BeginHorizontal();
            GameSparksSettings.ApiKey = EditorGUILayout.TextField(apiKeyLabel, GameSparksSettings.ApiKey).Trim();
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            GameSparksSettings.ApiSecret = EditorGUILayout.TextField(apiSecretLabel, GameSparksSettings.ApiSecret).Trim();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GameSparksSettings.Credential = EditorGUILayout.TextField(credentialLabel, GameSparksSettings.Credential);
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            GameSparksSettings.PreviewBuild = EditorGUILayout.Toggle(previewLabel, GameSparksSettings.PreviewBuild);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GameSparksSettings.DebugBuild = EditorGUILayout.Toggle(debugLabel, GameSparksSettings.DebugBuild);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();


            String testScenePath = "Assets/GameSparks/TestUI/GameSparksTestUI.unity";

            String testButtonText = "Test Configuration";

            if (EditorApplication.currentScene.Equals(testScenePath) && EditorApplication.isPlaying)
            {
                testButtonText = "Stop Test";
            }

            if (GameSparksSettings.ApiKey != null && GameSparksSettings.ApiSecret != null)
            {
                String myApiPath = "Assets/GameSparks/MyGameSparks.cs";
                GUILayout.TextArea("Download your custom data structures into your own SDK. Be sure to update this if you change the structure of Events and Leaderboards within the developer portal", EditorStyles.wordWrappedLabel);
                if (GUILayout.Button("Get My Custom SDK"))
                {
                    String myApi = GameSparksRestApi.getApi();
                    if (myApi != null)
                    {
                        Debug.Log("Updating GameSparks Api for game." + GameSparksSettings.ApiKey);
                        Directory.CreateDirectory(Path.GetDirectoryName(myApiPath));
                        using (StreamWriter outfile = new StreamWriter(myApiPath))
                        {
                            outfile.Write(myApi);
                        }
                    }
                    EditorUtility.SetDirty(settings);
                    AssetDatabase.Refresh();
                }

                GUILayout.TextArea("Get the latest GameSparks SDK version.", EditorStyles.wordWrappedLabel);

                if (GUILayout.Button("Update SDK"))
                {
                    UpdateSDK(false);
                }
            }

            GUILayout.TextArea("Run the GameSparks test harness in the editor. ", EditorStyles.wordWrappedLabel);
            if (GUILayout.Button(testButtonText))
            {
                EditorUtility.SetDirty(settings);
                if (EditorApplication.currentScene.Equals(testScenePath) && EditorApplication.isPlaying)
                {
                    EditorApplication.isPlaying = false;
                }
                else
                {
                    if (!EditorApplication.currentScene.Equals(testScenePath))
                    {
                        if (EditorApplication.SaveCurrentSceneIfUserWantsTo())
                        {
                            if (!EditorApplication.OpenScene(testScenePath))
                            {
                                EditorApplication.NewScene();
                                new GameObject("GameSparks", typeof(GameSparksTestUI), typeof(GameSparksUnity));
                                EditorApplication.SaveScene(testScenePath);
                            }
                            EditorApplication.isPlaying = true;
                        }
                    }
                    else
                    {
                        EditorApplication.isPlaying = true;
                    }
                }
            }
            if (GUI.changed)
            {
                EditorUtility.SetDirty(settings);
                AssetDatabase.SaveAssets();
            }
        }
	public override void OnInspectorGUI()
	{
		instance = (GameSparksSettings)target;
		AppIdGUI();
		
	}
        public override void OnInspectorGUI()
        {
            GameSparksSettings settings = (GameSparksSettings)target;

            GameSparksSettings.SetInstance(settings);

            GUILayout.TextArea("SDK Version : " + GameSparks.Core.GS.Version, EditorStyles.wordWrappedLabel);

            EditorGUILayout.HelpBox("Add the GameSparks Api Key and Secret associated with this game", MessageType.None);

            EditorGUILayout.BeginHorizontal();
            GameSparksSettings.ApiKey = EditorGUILayout.TextField(apiKeyLabel, GameSparksSettings.ApiKey);
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            GameSparksSettings.ApiSecret = EditorGUILayout.TextField(apiSecretLabel, GameSparksSettings.ApiSecret);
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            GameSparksSettings.PreviewBuild = EditorGUILayout.Toggle(previewLabel, GameSparksSettings.PreviewBuild);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GameSparksSettings.DebugBuild = EditorGUILayout.Toggle(debugLabel, GameSparksSettings.DebugBuild);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();


            String testScenePath = "Assets/GameSparks/TestUI/GameSparksTestUI.unity";

            String testButtonText = "Test Configuration";

            if (EditorApplication.currentScene.Equals(testScenePath) && EditorApplication.isPlaying)
            {
                testButtonText = "Stop Test";
            }

            if (GameSparksSettings.ApiKey != null && GameSparksSettings.ApiSecret != null)
            {
                String myApiPath = "Assets/GameSparks/MyGameSparks.cs";
                GUILayout.TextArea("Download your custom data structures into your own SDK. Be sure to update this if you change the structure of Events and Leaderboards within the developer portal", EditorStyles.wordWrappedLabel);
                if (GUILayout.Button("Get My Custom SDK"))
                {
                    String myApi = GameSparksRestApi.getApi();
                    if (myApi != null)
                    {
                        Debug.Log("Updating GameSparks Api for game." + GameSparksSettings.ApiKey);
                        Directory.CreateDirectory(Path.GetDirectoryName(myApiPath));
                        using (StreamWriter outfile = new StreamWriter(myApiPath))
                        {
                            outfile.Write(myApi);
                        }
                    }
                    EditorUtility.SetDirty(settings);
                    AssetDatabase.Refresh();
                }

                //			GUILayout.TextArea("Get the latest GameSparks SDK version.", EditorStyles.wordWrappedLabel);
                //
                //			if(GUILayout.Button("Update SDK")){
                //				System.Xml.XmlReader sdkInfo = GameSparksRestApi.GetSDKInfo();
                //				if(sdkInfo != null){
                //					while(sdkInfo.Read()){
                //
                //						if((sdkInfo.NodeType == System.Xml.XmlNodeType.Element) && (sdkInfo.Name == "sdk"))
                //						{
                //							string serverVersion = sdkInfo.GetAttribute("version");
                //							Debug.Log ("Server Version " + serverVersion);
                //							if(GameSparksSettings.SdkVersion == null || !GameSparksSettings.SdkVersion.Equals(serverVersion)){
                //								Debug.Log ("Updating GameSparks SDK");
                //								System.Xml.XmlReader files = sdkInfo.ReadSubtree();
                //								while(files.Read()){
                //									if((files.NodeType == System.Xml.XmlNodeType.Element) && (files.Name == "file")){
                //										GameSparksRestApi.UpdateSDKFile(files.GetAttribute("source"), files.GetAttribute("target"));
                //									}
                //								}
                //								Debug.Log ("Updating GameSparks Version: from (" + GameSparksSettings.SdkVersion + ") to (" + serverVersion + ")");
                //								GameSparksSettings.SdkVersion = serverVersion;
                //								EditorUtility.SetDirty(instance);
                //								AssetDatabase.Refresh();
                //							} else {
                //								break;
                //							}
                //						}
                //					}
                //				}
                //
                //			}
            }

            GUILayout.TextArea("Run the GameSparks test harness in the editor. ", EditorStyles.wordWrappedLabel);
            if (GUILayout.Button(testButtonText))
            {
                EditorUtility.SetDirty(settings);
                if (EditorApplication.currentScene.Equals(testScenePath) && EditorApplication.isPlaying)
                {
                    EditorApplication.isPlaying = false;
                }
                else
                {
                    if (!EditorApplication.currentScene.Equals(testScenePath))
                    {
                        if (EditorApplication.SaveCurrentSceneIfUserWantsTo())
                        {
                            if (!EditorApplication.OpenScene(testScenePath))
                            {
                                EditorApplication.NewScene();
                                new GameObject("GameSparks", typeof(GameSparksTestUI), typeof(GameSparksUnity));
                                EditorApplication.SaveScene(testScenePath);
                            }
                            EditorApplication.isPlaying = true;
                        }
                    }
                    else
                    {
                        EditorApplication.isPlaying = true;
                    }
                }
            }
            if (GUI.changed)
            {
                EditorUtility.SetDirty(settings);
                AssetDatabase.SaveAssets();
            }
        }
 public static void SetInstance(GameSparksSettings settings)
 {
     instance = settings;
 }