-
Notifications
You must be signed in to change notification settings - Fork 0
/
FillMissingController.cs
99 lines (99 loc) · 2.58 KB
/
FillMissingController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System.Collections;
using System.Collections.Generic;
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine;
public class FillMissingController : MonoBehaviour {
public static FillMissingController instance;
Dictionary<string, System.Action> data = new Dictionary<string, System.Action> ();
public List<string> MissingUserInventory = new List<string> ();
public List<string> MissingReadOnly = new List<string> ();
public List<string> MissingUserData = new List<string> ();
public Dictionary<string, string> UserDataDefaultValues = new Dictionary<string, string> {
{
"ChallengesCompleted",
"#"
},
{
"ChallengesFinished",
"#"
},
{
"HighScore",
"0"
},
{
"CurrentCar",
"C0002"
},
{
"CurrentTrail",
"T0001"
},
{
"AvatarUrl",
"https://res.cloudinary.com/moosepark/image/upload/v1534403658/fox.png"
},
{
"AvatarInd",
"0"
},
{
"UsernameSet",
"False"
},
};
// Use this for initialization
void Start () {
instance = this;
DontDestroyOnLoad (this);
data.Add ("UserInventory", SetUserInventory);
data.Add ("UserReadOnlyData", SetUserReadOnlyData);
data.Add ("UserData", SetUserData);
data.Add ("AccountInfo", SetAccountInfo);
data.Add ("PlayerTags", SetPlayerTags);
data.Add ("SetStatistics", SetStatistics);
}
private void SetUserInventory () { }
private void SetUserReadOnlyData () {
Dictionary<string, List<string>> data = new Dictionary<string, List<string>> { { "Referrals", new List<string> () }
};
PlayFabClientAPI.ExecuteCloudScript (new ExecuteCloudScriptRequest {
FunctionName = "CreateReadOnlyData",
FunctionParameter = new Dictionary<string, Dictionary<string, List<string>>> {
{
"Data",
data
}
}
}, (ExecuteCloudScriptResult res) => { }, (PlayFabError error) => {
if (Debug.isDebugBuild) {
error.GenerateErrorReport ();
}
});
}
private void SetUserData () {
Dictionary<string, string> data = new Dictionary<string, string> ();
for (int i = 0; i < MissingUserData.Count; i++) {
data.Add (MissingUserData[i], UserDataDefaultValues[MissingUserData[i]]);
}
PlayFabClientAPI.UpdateUserData (new UpdateUserDataRequest {
Data = data
}, (UpdateUserDataResult result) => {
if (Debug.isDebugBuild) {
print ("Succeeded setting " + data.Count + " User Data Values");
}
MissingUserData.Clear ();
}, (PlayFabError error) => {
if (Debug.isDebugBuild) {
print (error);
}
});
}
private void SetAccountInfo () { }
private void SetPlayerTags () { }
private void SetStatistics () { }
public void SetData (string id) {
data[id] ();
}
}