alex_gs 3 lat temu
rodzic
commit
0a31d3b199

+ 6 - 2
Unity3/Assets/2021/Scenes/Main.unity

@@ -41754,7 +41754,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!224 &1189456005
 RectTransform:
   m_ObjectHideFlags: 0
@@ -47189,7 +47189,6 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   elements:
   - {fileID: 49151293}
-  - {fileID: 1189456006}
   - {fileID: 904891310}
 --- !u!114 &1300409921
 MonoBehaviour:
@@ -58400,6 +58399,11 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   _userAccessToken: 
   userID: 
+  _name: 
+  _surname: 
+  _username: 
+  _usermail: 
+  _deviceId: 
 --- !u!114 &1572223166
 MonoBehaviour:
   m_ObjectHideFlags: 0

+ 1 - 2
Unity3/Assets/GameCore/FacebookHelper.cs

@@ -191,7 +191,6 @@ public class FacebookHelper : MonoBehaviour
 			Debug.Log("Not internet");
             return false;
         }
-		Debug.Log("Not internet");
 		return PlayerPrefs.GetInt("IsFacebookLoggedIn", 0) == 1;
     }
 
@@ -883,7 +882,7 @@ public class FacebookHelper : MonoBehaviour
 		//Submit score to game database and facebook
 		int score = GameDataManager.Instance.Score;
 		string replayData = RecordingManager.Instance.GetReplayData();
-		Debug.Log("Score " + score);
+		Debug.Log("Score " + score + " " + LevelsManager.Instance.CurrentLevelIndex);
 		SubmitScore(LevelsManager.Instance.CurrentLevelIndex, score, replayData);
 	}
 

+ 3 - 1
Unity3/Assets/SocialNetworking/Scripts/FaceBook/SocialManager.cs

@@ -71,6 +71,7 @@ public class SocialManager : MonoBehaviour
 	public string _surname;
 	public string _username;
 	public string _usermail;
+	public string _deviceId;
 	private string _gender;
 	private string _ageRange;
 
@@ -246,8 +247,9 @@ public class SocialManager : MonoBehaviour
         PlayerPrefs.SetString(FACEBOOK_NAME_PLAYER_PREFS_KEY, _name);
         PlayerPrefs.SetString(FACEBOOK_SURNAME_PLAYER_PREFS_KEY, _surname);
         PlayerPrefs.SetString(FACEBOOK_USERNAME_PLAYER_PREFS_KEY, _username);
+		_deviceId = SystemInfo.deviceUniqueIdentifier;
 
-        GameDatabaseManager.Instance.RegisterUser(userID, _name, _surname, _username, _usermail, _onLoginCompleted);
+		GameDatabaseManager.Instance.RegisterUser(userID, _name, _surname, _username, _usermail, _deviceId, _onLoginCompleted);
     }
     private void LoginFailedHandler(object target)
 	{

+ 57 - 7
Unity3/Assets/SocialNetworking/Scripts/SocialPlatform/GameDatabaseManager.cs

@@ -19,6 +19,7 @@ public class User
 	public string usermail = string.Empty;
 	public string gender = string.Empty;
 	public string ageRange = string.Empty;
+	public string device = string.Empty;
 	public User()
 	{
 		//Required for JSON serialization and deserialization
@@ -26,7 +27,7 @@ public class User
 	
 	public override string ToString()
 	{
-		return string.Format("{0}, {1}, {2}, {3}", id, name, surname, username, usermail, gender, ageRange);
+		return string.Format("{0}, {1}, {2}, {3}, {4}", id, name, surname, username, usermail, device, gender, ageRange);
 	}
 }
 
@@ -232,14 +233,27 @@ public class GameDatabaseManager : MonoBehaviour
 		
 		_instance = this;
 		DontDestroyOnLoad(gameObject);
+		CheckDeviceID(SystemInfo.deviceUniqueIdentifier, OnCheckDevice);
 	}
-	
-	public void RegisterUser(string userId, string name, string surname, string username, string usermail,Action<bool, string> onComplete)
+
+    private void OnCheckDevice(bool arg1, User arg2)
+    {
+		SocialManager.Instance.userID = arg2.id;
+		if(!string.IsNullOrEmpty(SocialManager.Instance.userID))
+        {
+			Debug.LogError(arg2.ToString());
+			PlayerPrefs.SetInt("APPLE", 1);
+			PlayerPrefs.Save();
+		}
+		Debug.LogError(arg2.ToString());
+    }
+
+    public void RegisterUser(string userId, string name, string surname, string username, string usermail, string deviceId, Action<bool, string> onComplete)
 	{
-		StartCoroutine(RegisterUserCoroutine(userId, name, surname, username, usermail, onComplete));
+		StartCoroutine(RegisterUserCoroutine(userId, name, surname, username, usermail, deviceId, onComplete));
 	}
 	
-	private IEnumerator RegisterUserCoroutine(string userId, string name, string surname, string username, string usermail, Action<bool, string> onComplete)
+	private IEnumerator RegisterUserCoroutine(string userId, string name, string surname, string username, string usermail, string deviceId, Action<bool, string> onComplete)
 	{
 		string registerUserUrl = URL + "RegisterUser.php";
 		
@@ -249,9 +263,10 @@ public class GameDatabaseManager : MonoBehaviour
 		form.AddField("surname", surname);
 		form.AddField("username", username);
 		form.AddField("usermail", usermail);
+		form.AddField("deviceID", deviceId);
 		//form.AddField("userage", gender);
 		//form.AddField("usergender", ageRange);
-		form.AddField("hash", ComputeHash(userId + name + surname + username+ usermail + GameConstants.SECRET_KEY));
+		form.AddField("hash", ComputeHash(userId + name + surname + username+ usermail + deviceId + GameConstants.SECRET_KEY));
 
 		WWW w = new WWW(registerUserUrl, form);	
 		yield return w;
@@ -276,7 +291,42 @@ public class GameDatabaseManager : MonoBehaviour
 			}
 		}
 	}
-	
+	public void CheckDeviceID(string deviceID, Action<bool, User> onComplete)
+	{
+		StartCoroutine(CheckDeviceCoroutine(deviceID, onComplete));
+	}
+
+	private IEnumerator CheckDeviceCoroutine(string deviceID, Action<bool, User> onComplete)
+	{
+		string loadDeviceUrl = URL + "RequestCheckDeviceID.php";
+
+		WWWForm form = new WWWForm();
+		form.AddField("userDeviceId", deviceID);
+
+		WWW w = new WWW(loadDeviceUrl, form);
+		yield return w;
+
+		Debug.Log(w.text);
+
+		if (w.error != null)
+		{
+			AVDebug.LogError(w.error);
+			onComplete(false, null);
+		}
+		else
+		{
+			try
+			{
+				User user = JsonReader.Deserialize<User>(w.text);
+				onComplete(true, user);
+			}
+			catch (JsonDeserializationException ex)
+			{
+				AVDebug.LogError(ex.Message);
+				onComplete(false, null);
+			}
+		}
+	}
 	public void LoadUser(string userId, Action<bool, User> onComplete)
 	{
 		StartCoroutine(LoadUserCoroutine(userId, onComplete));

+ 2 - 2
Unity3/Assets/SocialNetworking/Scripts/SocialPlatform/Stubs/GameDatabaseManagerStub.cs

@@ -44,7 +44,7 @@ public class GameDatabaseManagerStub : MonoBehaviour {
 	{		
 		if(GUILayout.Button("Register User", GUILayout.Width(200), GUILayout.Height(80)))
 		{
-			GameDatabaseManager.Instance.RegisterUser(_userId, _firstName, _lastName, _username, _usermail, (success, errorReason) => {
+			GameDatabaseManager.Instance.RegisterUser(_userId, _firstName, _lastName, _username, _usermail, SystemInfo.deviceUniqueIdentifier,(success, errorReason) => {
 				AVDebug.Log(success ? "Successful" : "Failed");
 			});
 		}
@@ -53,7 +53,7 @@ public class GameDatabaseManagerStub : MonoBehaviour {
 		{
 			foreach(User u in _challengeParticipants)
 			{
-				GameDatabaseManager.Instance.RegisterUser(u.id, u.name, u.surname, u.username,u.usermail, (success, errorReason) => { 
+				GameDatabaseManager.Instance.RegisterUser(u.id, u.name, u.surname, u.username,u.usermail, SystemInfo.deviceUniqueIdentifier,(success, errorReason) => { 
 					AVDebug.Log(success ? "Successful" : "Failed");
 				});
 			}

+ 6 - 2
Unity3/Assets/Unity Technologies/SignInWithApple/Samples/Scripts/SignInWithAppleTest_Callbacks.cs

@@ -10,7 +10,10 @@ public class SignInWithAppleTest_Callbacks : MonoBehaviour
     public void ButtonPress()
     {
         var siwa = gameObject.GetComponent<SignInWithApple>();
-        siwa.Login(OnLogin);
+        if(PlayerPrefs.GetInt("APPLE") == 0)
+        {
+            siwa.Login(OnLogin);
+        }
     }
 
     public void CredentialButton()
@@ -50,10 +53,11 @@ public class SignInWithAppleTest_Callbacks : MonoBehaviour
         SocialManager.Instance._surname = _surname;
         SocialManager.Instance._usermail= userInfo.email;
         SocialManager.Instance._username = userInfo.userId;
+        SocialManager.Instance._deviceId = SystemInfo.deviceUniqueIdentifier;
         PlayerPrefs.SetString("UserID", userInfo.userId);
         PlayerPrefs.SetInt("Login", 1);
         PlayerPrefs.Save();
-        GameDatabaseManager.Instance.RegisterUser(userInfo.userId, _name, _surname, userInfo.displayName, userInfo.email, OnLoginCompleted);
+        GameDatabaseManager.Instance.RegisterUser(userInfo.userId, _name, _surname, userInfo.displayName, userInfo.email, SystemInfo.deviceUniqueIdentifier, OnLoginCompleted);
         Debug.Log(
             string.Format("Display Name: {0}\nEmail: {1}\nUser ID: {2}\nID Token: {3}", userInfo.displayName ?? "",
                 userInfo.email ?? "", userInfo.userId ?? "", userInfo.idToken ?? ""));