scripts
This commit is contained in:
@@ -0,0 +1,367 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.SocialPlatforms.Impl;
|
||||
|
||||
namespace UnityEngine.SocialPlatforms
|
||||
{
|
||||
// Token: 0x02000383 RID: 899
|
||||
public class Local : ISocialPlatform
|
||||
{
|
||||
// Token: 0x17000C6A RID: 3178
|
||||
// (get) Token: 0x060035E5 RID: 13797 RVA: 0x0005A578 File Offset: 0x00058778
|
||||
public ILocalUser localUser
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Local.m_LocalUser == null)
|
||||
{
|
||||
Local.m_LocalUser = new LocalUser();
|
||||
}
|
||||
return Local.m_LocalUser;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035E6 RID: 13798 RVA: 0x0005A5A8 File Offset: 0x000587A8
|
||||
void ISocialPlatform.Authenticate(ILocalUser user, Action<bool> callback)
|
||||
{
|
||||
LocalUser localUser = (LocalUser)user;
|
||||
this.m_DefaultTexture = this.CreateDummyTexture(32, 32);
|
||||
this.PopulateStaticData();
|
||||
localUser.SetAuthenticated(true);
|
||||
localUser.SetUnderage(false);
|
||||
localUser.SetUserID("1000");
|
||||
localUser.SetUserName("Lerpz");
|
||||
localUser.SetImage(this.m_DefaultTexture);
|
||||
if (callback != null)
|
||||
{
|
||||
callback(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035E7 RID: 13799 RVA: 0x0005A610 File Offset: 0x00058810
|
||||
void ISocialPlatform.Authenticate(ILocalUser user, Action<bool, string> callback)
|
||||
{
|
||||
((ISocialPlatform)this).Authenticate(user, delegate(bool success)
|
||||
{
|
||||
callback(success, null);
|
||||
});
|
||||
}
|
||||
|
||||
// Token: 0x060035E8 RID: 13800 RVA: 0x0005A640 File Offset: 0x00058840
|
||||
void ISocialPlatform.LoadFriends(ILocalUser user, Action<bool> callback)
|
||||
{
|
||||
if (this.VerifyUser())
|
||||
{
|
||||
((LocalUser)user).SetFriends(this.m_Friends.ToArray());
|
||||
if (callback != null)
|
||||
{
|
||||
callback(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035E9 RID: 13801 RVA: 0x0005A678 File Offset: 0x00058878
|
||||
public void LoadUsers(string[] userIDs, Action<IUserProfile[]> callback)
|
||||
{
|
||||
List<UserProfile> list = new List<UserProfile>();
|
||||
if (this.VerifyUser())
|
||||
{
|
||||
foreach (string text in userIDs)
|
||||
{
|
||||
foreach (UserProfile userProfile in this.m_Users)
|
||||
{
|
||||
if (userProfile.id == text)
|
||||
{
|
||||
list.Add(userProfile);
|
||||
}
|
||||
}
|
||||
foreach (UserProfile userProfile2 in this.m_Friends)
|
||||
{
|
||||
if (userProfile2.id == text)
|
||||
{
|
||||
list.Add(userProfile2);
|
||||
}
|
||||
}
|
||||
}
|
||||
callback(list.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035EA RID: 13802 RVA: 0x0005A78C File Offset: 0x0005898C
|
||||
public void ReportProgress(string id, double progress, Action<bool> callback)
|
||||
{
|
||||
if (this.VerifyUser())
|
||||
{
|
||||
foreach (Achievement achievement in this.m_Achievements)
|
||||
{
|
||||
if (achievement.id == id && achievement.percentCompleted <= progress)
|
||||
{
|
||||
if (progress >= 100.0)
|
||||
{
|
||||
achievement.SetCompleted(true);
|
||||
}
|
||||
achievement.SetHidden(false);
|
||||
achievement.SetLastReportedDate(DateTime.Now);
|
||||
achievement.percentCompleted = progress;
|
||||
if (callback != null)
|
||||
{
|
||||
callback(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
foreach (AchievementDescription achievementDescription in this.m_AchievementDescriptions)
|
||||
{
|
||||
if (achievementDescription.id == id)
|
||||
{
|
||||
bool flag = progress >= 100.0;
|
||||
Achievement achievement2 = new Achievement(id, progress, flag, false, DateTime.Now);
|
||||
this.m_Achievements.Add(achievement2);
|
||||
if (callback != null)
|
||||
{
|
||||
callback(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
Debug.LogError("Achievement ID not found");
|
||||
if (callback != null)
|
||||
{
|
||||
callback(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035EB RID: 13803 RVA: 0x0005A90C File Offset: 0x00058B0C
|
||||
public void LoadAchievementDescriptions(Action<IAchievementDescription[]> callback)
|
||||
{
|
||||
if (this.VerifyUser())
|
||||
{
|
||||
if (callback != null)
|
||||
{
|
||||
callback(this.m_AchievementDescriptions.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035EC RID: 13804 RVA: 0x0005A938 File Offset: 0x00058B38
|
||||
public void LoadAchievements(Action<IAchievement[]> callback)
|
||||
{
|
||||
if (this.VerifyUser())
|
||||
{
|
||||
if (callback != null)
|
||||
{
|
||||
callback(this.m_Achievements.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035ED RID: 13805 RVA: 0x0005A964 File Offset: 0x00058B64
|
||||
public void ReportScore(long score, string board, Action<bool> callback)
|
||||
{
|
||||
if (this.VerifyUser())
|
||||
{
|
||||
foreach (Leaderboard leaderboard in this.m_Leaderboards)
|
||||
{
|
||||
if (leaderboard.id == board)
|
||||
{
|
||||
leaderboard.SetScores(new List<Score>((Score[])leaderboard.scores)
|
||||
{
|
||||
new Score(board, score, this.localUser.id, DateTime.Now, score + " points", 0)
|
||||
}.ToArray());
|
||||
if (callback != null)
|
||||
{
|
||||
callback(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
Debug.LogError("Leaderboard not found");
|
||||
if (callback != null)
|
||||
{
|
||||
callback(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035EE RID: 13806 RVA: 0x0005AA54 File Offset: 0x00058C54
|
||||
public void LoadScores(string leaderboardID, Action<IScore[]> callback)
|
||||
{
|
||||
if (this.VerifyUser())
|
||||
{
|
||||
foreach (Leaderboard leaderboard in this.m_Leaderboards)
|
||||
{
|
||||
if (leaderboard.id == leaderboardID)
|
||||
{
|
||||
this.SortScores(leaderboard);
|
||||
if (callback != null)
|
||||
{
|
||||
callback(leaderboard.scores);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
Debug.LogError("Leaderboard not found");
|
||||
if (callback != null)
|
||||
{
|
||||
callback(new Score[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035EF RID: 13807 RVA: 0x0005AB0C File Offset: 0x00058D0C
|
||||
void ISocialPlatform.LoadScores(ILeaderboard board, Action<bool> callback)
|
||||
{
|
||||
if (this.VerifyUser())
|
||||
{
|
||||
Leaderboard leaderboard = (Leaderboard)board;
|
||||
foreach (Leaderboard leaderboard2 in this.m_Leaderboards)
|
||||
{
|
||||
if (leaderboard2.id == leaderboard.id)
|
||||
{
|
||||
leaderboard.SetTitle(leaderboard2.title);
|
||||
leaderboard.SetScores(leaderboard2.scores);
|
||||
leaderboard.SetMaxRange((uint)leaderboard2.scores.Length);
|
||||
}
|
||||
}
|
||||
this.SortScores(leaderboard);
|
||||
this.SetLocalPlayerScore(leaderboard);
|
||||
if (callback != null)
|
||||
{
|
||||
callback(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035F0 RID: 13808 RVA: 0x0005ABD8 File Offset: 0x00058DD8
|
||||
bool ISocialPlatform.GetLoading(ILeaderboard board)
|
||||
{
|
||||
return this.VerifyUser() && ((Leaderboard)board).loading;
|
||||
}
|
||||
|
||||
// Token: 0x060035F1 RID: 13809 RVA: 0x0005AC0C File Offset: 0x00058E0C
|
||||
private void SortScores(Leaderboard board)
|
||||
{
|
||||
List<Score> list = new List<Score>((Score[])board.scores);
|
||||
list.Sort((Score s1, Score s2) => s2.value.CompareTo(s1.value));
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
list[i].SetRank(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035F2 RID: 13810 RVA: 0x0005AC74 File Offset: 0x00058E74
|
||||
private void SetLocalPlayerScore(Leaderboard board)
|
||||
{
|
||||
foreach (Score score in board.scores)
|
||||
{
|
||||
if (score.userID == this.localUser.id)
|
||||
{
|
||||
board.SetLocalUserScore(score);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060035F3 RID: 13811 RVA: 0x0005ACD4 File Offset: 0x00058ED4
|
||||
public void ShowAchievementsUI()
|
||||
{
|
||||
Debug.Log("ShowAchievementsUI not implemented");
|
||||
}
|
||||
|
||||
// Token: 0x060035F4 RID: 13812 RVA: 0x0005ACE4 File Offset: 0x00058EE4
|
||||
public void ShowLeaderboardUI()
|
||||
{
|
||||
Debug.Log("ShowLeaderboardUI not implemented");
|
||||
}
|
||||
|
||||
// Token: 0x060035F5 RID: 13813 RVA: 0x0005ACF4 File Offset: 0x00058EF4
|
||||
public ILeaderboard CreateLeaderboard()
|
||||
{
|
||||
return new Leaderboard();
|
||||
}
|
||||
|
||||
// Token: 0x060035F6 RID: 13814 RVA: 0x0005AD10 File Offset: 0x00058F10
|
||||
public IAchievement CreateAchievement()
|
||||
{
|
||||
return new Achievement();
|
||||
}
|
||||
|
||||
// Token: 0x060035F7 RID: 13815 RVA: 0x0005AD2C File Offset: 0x00058F2C
|
||||
private bool VerifyUser()
|
||||
{
|
||||
bool flag;
|
||||
if (!this.localUser.authenticated)
|
||||
{
|
||||
Debug.LogError("Must authenticate first");
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x060035F8 RID: 13816 RVA: 0x0005AD64 File Offset: 0x00058F64
|
||||
private void PopulateStaticData()
|
||||
{
|
||||
this.m_Friends.Add(new UserProfile("Fred", "1001", true, UserState.Online, this.m_DefaultTexture));
|
||||
this.m_Friends.Add(new UserProfile("Julia", "1002", true, UserState.Online, this.m_DefaultTexture));
|
||||
this.m_Friends.Add(new UserProfile("Jeff", "1003", true, UserState.Online, this.m_DefaultTexture));
|
||||
this.m_Users.Add(new UserProfile("Sam", "1004", false, UserState.Offline, this.m_DefaultTexture));
|
||||
this.m_Users.Add(new UserProfile("Max", "1005", false, UserState.Offline, this.m_DefaultTexture));
|
||||
this.m_AchievementDescriptions.Add(new AchievementDescription("Achievement01", "First achievement", this.m_DefaultTexture, "Get first achievement", "Received first achievement", false, 10));
|
||||
this.m_AchievementDescriptions.Add(new AchievementDescription("Achievement02", "Second achievement", this.m_DefaultTexture, "Get second achievement", "Received second achievement", false, 20));
|
||||
this.m_AchievementDescriptions.Add(new AchievementDescription("Achievement03", "Third achievement", this.m_DefaultTexture, "Get third achievement", "Received third achievement", false, 15));
|
||||
Leaderboard leaderboard = new Leaderboard();
|
||||
leaderboard.SetTitle("High Scores");
|
||||
leaderboard.id = "Leaderboard01";
|
||||
leaderboard.SetScores(new List<Score>
|
||||
{
|
||||
new Score("Leaderboard01", 300L, "1001", DateTime.Now.AddDays(-1.0), "300 points", 1),
|
||||
new Score("Leaderboard01", 255L, "1002", DateTime.Now.AddDays(-1.0), "255 points", 2),
|
||||
new Score("Leaderboard01", 55L, "1003", DateTime.Now.AddDays(-1.0), "55 points", 3),
|
||||
new Score("Leaderboard01", 10L, "1004", DateTime.Now.AddDays(-1.0), "10 points", 4)
|
||||
}.ToArray());
|
||||
this.m_Leaderboards.Add(leaderboard);
|
||||
}
|
||||
|
||||
// Token: 0x060035F9 RID: 13817 RVA: 0x0005AFB8 File Offset: 0x000591B8
|
||||
private Texture2D CreateDummyTexture(int width, int height)
|
||||
{
|
||||
Texture2D texture2D = new Texture2D(width, height);
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
for (int j = 0; j < width; j++)
|
||||
{
|
||||
Color color = (((j & i) <= 0) ? Color.gray : Color.white);
|
||||
texture2D.SetPixel(j, i, color);
|
||||
}
|
||||
}
|
||||
texture2D.Apply();
|
||||
return texture2D;
|
||||
}
|
||||
|
||||
// Token: 0x04000C1B RID: 3099
|
||||
private static LocalUser m_LocalUser = null;
|
||||
|
||||
// Token: 0x04000C1C RID: 3100
|
||||
private List<UserProfile> m_Friends = new List<UserProfile>();
|
||||
|
||||
// Token: 0x04000C1D RID: 3101
|
||||
private List<UserProfile> m_Users = new List<UserProfile>();
|
||||
|
||||
// Token: 0x04000C1E RID: 3102
|
||||
private List<AchievementDescription> m_AchievementDescriptions = new List<AchievementDescription>();
|
||||
|
||||
// Token: 0x04000C1F RID: 3103
|
||||
private List<Achievement> m_Achievements = new List<Achievement>();
|
||||
|
||||
// Token: 0x04000C20 RID: 3104
|
||||
private List<Leaderboard> m_Leaderboards = new List<Leaderboard>();
|
||||
|
||||
// Token: 0x04000C21 RID: 3105
|
||||
private Texture2D m_DefaultTexture;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user