game: loading user profile
This commit is contained in:
parent
bfb61b2641
commit
8e8ae9257f
3 changed files with 61 additions and 7 deletions
|
@ -4894,10 +4894,6 @@ MonoBehaviour:
|
|||
npcBufferTime: 5
|
||||
playerFree: 0
|
||||
currentNpcs: []
|
||||
chairPositions:
|
||||
- {fileID: 9804464}
|
||||
- {fileID: 385635434}
|
||||
- {fileID: 720927106}
|
||||
despawnPoints: []
|
||||
desk: {fileID: 1068269875}
|
||||
--- !u!114 &520849220
|
||||
|
@ -7496,6 +7492,30 @@ MonoBehaviour:
|
|||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 387192628}
|
||||
m_TargetAssemblyTypeName: MenuButtons, Assembly-CSharp
|
||||
m_MethodName: LoadProfileData
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 1
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 0}
|
||||
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||
m_MethodName:
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName:
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 1
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 442984533}
|
||||
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||
m_MethodName: SetActive
|
||||
|
|
|
@ -83,6 +83,21 @@ public class Backend : MonoBehaviour
|
|||
{
|
||||
var result = await Client.From<Users>().Where(x => x.uid == uid).Get();
|
||||
User = result.Model;
|
||||
|
||||
if (User != null)
|
||||
{
|
||||
Debug.Log($"User: " + User.displayName);
|
||||
|
||||
MenuButtons profilePage = FindObjectOfType<MenuButtons>();
|
||||
if (profilePage != null)
|
||||
{
|
||||
profilePage.UpdateProfileUI(User);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Data cannot retrieve");
|
||||
}
|
||||
}
|
||||
|
||||
public NpcData FirebaseGet()
|
||||
|
|
|
@ -30,9 +30,28 @@ public class MenuButtons : MonoBehaviour
|
|||
/// </summary>
|
||||
public void LoadProfileData()
|
||||
{
|
||||
/*Backend.instance.GetData(Session.User.Id);*/
|
||||
|
||||
|
||||
if (Backend.instance.Session != null)
|
||||
{
|
||||
Backend.instance.GetData(Backend.instance.Session.User.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Session null, no user logged in");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateProfileUI(Users user)
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
var totalPeopleHelped = user.customersHelped + user.customersHelpedWrongly;
|
||||
var accuracy = (user.customersHelped/totalPeopleHelped)*100;
|
||||
|
||||
usernameText.text = user.displayName;
|
||||
daysPlayedText.text = user.daysPlayed.ToString();
|
||||
peopleHelpedText.text = totalPeopleHelped.ToString();
|
||||
accuracyText.text = accuracy.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue