/// <summary>
 /// Generates a password based on the IMEI or Wifi Mac adress
 /// </summary>
 /// <param name="ImeiMac">The IMEI number or the Wifi Mac Adress</param>
 /// <param name="OS">The mobile operating system the account was registered on.</param>
 /// <returns>The generated password</returns>
 public string generatePassword(string ImeiMac, DeviceOS OS)
 {
     if (OS == DeviceOS.iOS)
     {
         return md5(ImeiMac.Trim() + ImeiMac.Trim());
     }
     else
     {
         string Reversed = new string(ImeiMac.Trim().ToCharArray().Reverse().ToArray());
         return md5(Reversed);
     }
 }
示例#2
0
        virtual protected void Start()
        {
            DeviceName = SystemInfo.deviceName.ToString();
            DeviceType = SystemInfo.deviceType.ToString();
            if (Application.platform == RuntimePlatform.PS4 || Application.platform == RuntimePlatform.XboxOne)
            {
#if GS_DONT_USE_PLAYER_PREFS || UNITY_SWITCH
                DeviceId = SystemInfo.deviceUniqueIdentifier.ToString();
#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[] 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;

            case "SAMSUNGTV":
                manufacturer = "Samsung";

                break;

            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);

            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"));*/

#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();
            ExtraDebug = GameSparksSettings.DebugBuild;

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

            GS.Initialise(this);

            DontDestroyOnLoad(this);
        }