-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayfabManager.cs
682 lines (614 loc) · 26.6 KB
/
PlayfabManager.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using PlayFab;
using PlayFab.ClientModels;
using PlayFab.GroupsModels;
using PlayFab.DataModels;
using PlayFab.AuthenticationModels;
using Photon;
using Photon.Pun;
using Photon.Realtime;
using PN = Photon.Pun.PhotonNetwork;
using System.Linq;
using UnityEngine.EventSystems;
public class PlayfabManager : MonoBehaviourPunCallbacks
{
private PlayfabManager() { }
private static PlayfabManager instance;
public static PlayfabManager Instance
{
get
{
if(instance == null)
{
var obj = FindObjectOfType<PlayfabManager>();
if(obj != null)
{
instance = obj;
}
}
return instance;
}
}
public PlayerLeaderboardEntry MyPlayFabInfo;
public NetworkManager networkManager;
public InputField emailInput, passwordInput, usernameInput;
public Toggle studentToggle, instructorToggle;
public PlayFab.AuthenticationModels.EntityKey playerEntity;
public string tmpEntityId;
public string tmpEntityType;
string myPlayfabId;
public string playerJob;
public string playerName;
public string playerSchoolId;
bool isAuthenticate;
#region Events
public delegate void GetPlayerInfoEvent(string studentId, string studentName);
public delegate void GetPlayfabIdEvent(string playfabId);
public UnityEvent<string> getPlayfabIdEventArg1;
public UnityEvent<string, string> getPlayfabIdEventArg2;
public UnityEvent<string> getLeaderBoardUserIDEvent;
public UnityEvent<int> getLeaderBoardValueEvent;
public UnityEvent<string, string> getUserDataEvent;
public UnityEvent invitingGroupEvent;
public event GetPlayerInfoEvent getPlayerInfoEvent;
#endregion
void Awake()
{
if(instance == null)
{
instance = gameObject.GetComponent<PlayfabManager>();
}
else
{
//Destroy(gameObject);
}
}
private void Start()
{
networkManager = NetworkManager.Instance;
}
public void ClickStudentToggle()
{
instructorToggle.isOn = false;
studentToggle.isOn = true;
}
public void ClickInstructorToggle()
{
studentToggle.isOn = false;
instructorToggle.isOn = true;
}
#region PlayFab Login, Register
public void LoginBtn()
{
if (!emailInput.text.Contains("@inha.edu"))
{
emailInput.text += "@inha.edu";
}
var request = new LoginWithEmailAddressRequest { Email = emailInput.text, Password = passwordInput.text };
PlayFabClientAPI.LoginWithEmailAddress(request, (result) => { OnLoginSuccess(result); }, (error) => OnLoginFailure(error));
}
public void RegisterBtn()
{
var request = new RegisterPlayFabUserRequest { Email = emailInput.text, Password = passwordInput.text, Username = emailInput.text.Substring(0, 8), DisplayName = usernameInput.text };
SelectJob();
PlayFabClientAPI.RegisterPlayFabUser(request, (result) => { OnRegisterSuccess(result); }, (error) => OnRegisterFailure(error));
}
public void LoginMaster()
{
SelectJob();
if (playerJob == "")
{
Debug.Log("직업을 선택해주세요.");
return;
}
if (playerJob.Equals("학생"))
{
emailInput.text = "11111111@inha.edu";
passwordInput.text = "master1234";
}
else
{
emailInput.text = "22222222@inha.edu";
passwordInput.text = "master4321";
}
LoginBtn();
}
public void OnToggleCharacter()
{
NetworkManager.Instance.characterName = EventSystem.current.currentSelectedGameObject.name;
}
public void SelectCharacterBtn()
{
GetMyInfo();
GetUserJob();
PlayFabAuthenticationAPI.GetEntityToken(new GetEntityTokenRequest(),
(result) =>
{
playerEntity = result.Entity;
AcceptGroupInvitationWithUpdateData();
},
(error) => { });
invitingGroupEvent.AddListener(AcceptGroupInvitationWithUpdateData);
emailInput.text = "";
passwordInput.text = "";
usernameInput.text = "";
PN.ConnectUsingSettings();
// UpdateLeaderBoard("CSE1111001Attendance", 4063);
}
private void OnLoginSuccess(LoginResult result)
{
UIManager.Instance.ShowUI(Define.UI.PORTRAIT);
UIManager.Instance.GetComponent<InputTabMove>().enabled = false;
myPlayfabId = result.PlayFabId;
}
private void OnLoginFailure(PlayFabError error)
{
emailInput.text = "";
passwordInput.text = "";
usernameInput.text = "";
UIManager.Instance.StopCoroutine(UIManager.Instance.FadeOutwarningMessageUI(""));
UIManager.Instance.StopCoroutine(UIManager.Instance.FadeOutCoroutine());
UIManager.Instance.StartCoroutine(UIManager.Instance.FadeOutwarningMessageUI("아이디 또는 패스워드가 틀렸습니다"));
}
void OnRegisterSuccess(RegisterPlayFabUserResult result)
{
SetUserData("Job", playerJob);
UpdateLeaderBoard("IDInfo", int.Parse(emailInput.text.Substring(0, 8)));
Debug.Log("회원가입 성공");
}
void OnRegisterFailure(PlayFabError error)
{
Debug.Log("회원가입 실패 " + error);
}
#endregion
public void SetUserData(string key, string value)
{
var request = new UpdateUserDataRequest
{
Data = new Dictionary<string, string>() { { key, value } },
Permission = UserDataPermission.Public
};
PlayFabClientAPI.UpdateUserData(request, (result) => { Debug.Log("데이터 업데이트 성공"); }, (error) => Debug.Log("데이터 업데이트 성공" + error));
}
public void GetUserData(string key, string use)
{
var request = new GetUserDataRequest { Keys = new List<string>() { key } };
PlayFabClientAPI.GetUserData(request,
(result) =>
{
if (use.Equals("JoinToClass"))
{
NetworkManager.Instance.JoinToClass(key, result.Data[key].Value);
}
else if (use.Equals("InstantiateClassInfo"))
{
UIManager.Instance.InstantiateClassInfo(key, result.Data[key].Value);
}
}, (error) => { Debug.Log(error); });
}
void GetUserJob()
{
var request = new GetUserDataRequest { PlayFabId = myPlayfabId };
PlayFabClientAPI.GetUserData(request, (result) =>
{
foreach (var eachData in result.Data)
{
if (eachData.Key == "Job")
{
if (eachData.Value.Value.Equals("학생"))
{
playerJob = "학생";
}
else if (eachData.Value.Value == "교수")
{
playerJob = "교수";
}
break;
}
}
Debug.Log("직업 정보 불러오기 성공. Job : " + playerJob);
}, (error) => Debug.Log("직업 정보 불러오기 실패 " + error));
}
public void GetMyInfo()
{
var request = new GetAccountInfoRequest { PlayFabId = myPlayfabId };
PlayFabClientAPI.GetAccountInfo(request,
(result) =>
{
playerName = result.AccountInfo.TitleInfo.DisplayName;
playerSchoolId = result.AccountInfo.Username;
UIManager.Instance.UIInitFromPlayfabLogin(playerName, playerSchoolId);
ChatManager.Instance.ChatStart();
ChatManager.Instance.enabled = true;
Debug.Log("정보 불러오기 성공, 이름 : " + playerName + ", 학번 : " + playerSchoolId);
}, (error) => Debug.Log("정보 불러오기 실패"));
}
public void GetPlayerInfoUsingStudentId(string studentIdString)
{
int studentId = int.Parse(studentIdString);
var request = new GetLeaderboardRequest
{
StartPosition = 0,
StatisticName = "IDInfo",
MaxResultsCount = 100,
ProfileConstraints = new PlayerProfileViewConstraints() { ShowDisplayName = true }
};
PlayFabClientAPI.GetLeaderboard(request, (result) =>
{
string playerId = "";
for (int count = 0; count < result.Leaderboard.Count; count++)
{
if (result.Leaderboard[count].StatValue.Equals(studentId))
{
playerId = result.Leaderboard[count].PlayFabId;
break;
}
}
if (playerId.Equals(""))
{
Debug.Log("플레이어에 대한 정보가 존재하지 않습니다.");
return;
}
var request = new GetAccountInfoRequest { PlayFabId = playerId };
PlayFabClientAPI.GetAccountInfo(request,
(result) =>
{
if (getPlayerInfoEvent != null)
{
getPlayerInfoEvent(result.AccountInfo.Username, result.AccountInfo.TitleInfo.DisplayName);
}
Debug.Log("계정 정보 불러오기 성공");
}, (error) => Debug.Log("계정 정보 불러오기 실패"));
}, (error) => Debug.Log(error.ErrorMessage));
}
public void GetPlayfabIdUsingStudentId(string studentIdString)
{
int studentId = int.Parse(studentIdString);
var request = new GetLeaderboardRequest
{
StartPosition = 0,
StatisticName = "IDInfo",
MaxResultsCount = 100,
ProfileConstraints = new PlayerProfileViewConstraints() { ShowDisplayName = true }
};
PlayFabClientAPI.GetLeaderboard(request, (result) =>
{
for (int count = 0; count < result.Leaderboard.Count; count++)
{
if (result.Leaderboard[count].StatValue.Equals(studentId))
{
getPlayfabIdEventArg1.Invoke(result.Leaderboard[count].PlayFabId);
break;
}
}
}, (error) => Debug.Log(error.ErrorMessage));
}
public void UpdateLeaderBoard(string statisticName, int statisticValue)
{
Debug.Log(statisticName + statisticValue);
var request = new UpdatePlayerStatisticsRequest { Statistics = new List<StatisticUpdate> { new StatisticUpdate { StatisticName = statisticName, Value = statisticValue } } };
PlayFabClientAPI.UpdatePlayerStatistics(request, (result) => Debug.Log("리더보드 업데이트 성공"), (error) => Debug.Log("리더보드 업데이트 실패")); ;
}
public void UpdateLeaderBoardStudentOnClass(string groupId, string groupType)
{
var request = new GetObjectsRequest { Entity = new PlayFab.DataModels.EntityKey { Id = groupId, Type = groupType } };
PlayFabDataAPI.GetObjects(request,
(objectResult) =>
{
ClassData classData = JsonUtility.FromJson<ClassData>(objectResult.Objects["ClassData"].DataObject.ToString());
Debug.Log(classData.classId + classData.classNumber);
UpdateLeaderBoard(classData.classId + classData.classNumber + "Attendance", 0);
},
(error) => { Debug.Log("수업 내 학생 정보 업데이트 실패" + error); });
}
public void GetLeaderBoard(string statisticName, string userName, string callbackMethodName)
{
var request = new GetLeaderboardRequest
{
StartPosition = 0,
StatisticName = statisticName,
MaxResultsCount = 100,
ProfileConstraints = new PlayerProfileViewConstraints() { ShowDisplayName = true }
};
PlayFabClientAPI.GetLeaderboard(request, (result) =>
{
if (callbackMethodName.Equals("CountStudentNumber"))
{
Debug.Log(statisticName + " " + result.Leaderboard.Count);
ClassProcessManager.Instance.CountStudentNumber(result.Leaderboard.Count);
return;
}
for (int count = 0; count < result.Leaderboard.Count; count++)
{
if (result.Leaderboard[count].DisplayName.Equals(userName))
{
if (callbackMethodName.Equals("LoadAttendanceCount"))
{
ClassProcessManager.Instance.LoadAttendanceCount(result.Leaderboard[count].StatValue);
return;
}
else if (callbackMethodName.Equals("UpdateAttendance"))
{
ClassProcessManager.Instance.UpdateAttendance(result.Leaderboard[count].StatValue);
return;
}
}
}
if (callbackMethodName.Equals("UpdateAttendance"))
{
Debug.Log("UP");
ClassProcessManager.Instance.UpdateAttendance(0);
return;
}
}, (error) => Debug.Log(error.ErrorMessage));
}
public void GetLeaderBoardForTotalAttendanceUI(string statisticName, string userName, Text textComponent)
{
Debug.Log(statisticName);
var request = new GetLeaderboardRequest
{
StartPosition = 0,
StatisticName = statisticName,
MaxResultsCount = 100,
ProfileConstraints = new PlayerProfileViewConstraints() { ShowDisplayName = true }
};
PlayFabClientAPI.GetLeaderboard(request,
(result) =>
{
for (int count = 0; count < result.Leaderboard.Count; count++)
{
if (result.Leaderboard[count].DisplayName.Equals(userName))
{
string attendance = UtilityMethods.ReverseString(Convert.ToString(result.Leaderboard[count].StatValue, 2).ToString());
for(int attenCount = attendance.Length; attenCount < 16; attenCount++)
{
attendance = attendance + "0";
}
attendance = attendance.Replace("1", "O\t\t");
attendance = attendance.Replace("0", "X\t\t");
textComponent.text = attendance;
return;
}
}
textComponent.alignment = TextAnchor.MiddleCenter;
textComponent.text = "출석 정보가 존재하지 않습니다.";
}, (error) => { Debug.Log(error); });
}
void SelectJob()
{
if (studentToggle.isOn)
{
playerJob = "학생";
}
else if (instructorToggle.isOn)
{
playerJob = "교수";
}
}
public void CreateGroup(string groupName)
{
PlayFab.GroupsModels.EntityKey entity = new PlayFab.GroupsModels.EntityKey { Id = playerEntity.Id, Type = playerEntity.Type };
var request = new CreateGroupRequest { GroupName = groupName, Entity = entity };
PlayFabGroupsAPI.CreateGroup(request,
(result) =>
{
Debug.Log("그룹 생성 성공, id : " + result.Group.Id + " name : " + result.GroupName);
},
(error) => Debug.Log("그룹 생성 실패" + error));
}
public void CreateGroup(string groupName, string dataKey, object dataValue)
{
PlayFab.GroupsModels.EntityKey entity = new PlayFab.GroupsModels.EntityKey { Id = playerEntity.Id, Type = playerEntity.Type };
var request = new CreateGroupRequest { GroupName = groupName, Entity = entity };
PlayFabGroupsAPI.CreateGroup(request,
(result) =>
{
Debug.Log("그룹 생성 성공, id : " + result.Group.Id + " name : " + result.GroupName);
List<string> studentIds = UtilityMethods.ListUpInvitingStudents(dataValue);
for(int count = 0; count < studentIds.Count; count++)
{
InviteToGroup(groupName, studentIds[count]);
Debug.Log(studentIds[count] + "가 수업에 입력되었습니다.");
}
UpdateObjectDataUsingEntity(result.Group.Id, result.Group.Type, dataKey, dataValue);
},
(error) =>
{
Debug.Log("그룹 생성 실패" + error.Error);
if (error.Error.ToString().Equals("GroupNameNotAvailable"))
{
var request = new GetGroupRequest { GroupName = groupName };
PlayFabGroupsAPI.GetGroup(request,
(result) =>
{
UpdateObjectDataUsingEntity(result.Group.Id, result.Group.Type, dataKey, dataValue);
Debug.Log("그룹 정보 가져오기 성공");
}, (error) => { });
List<string> studentIds = UtilityMethods.ListUpInvitingStudents(dataValue);
for (int count = 0; count < studentIds.Count; count++)
{
InviteToGroup(groupName, studentIds[count]);
Debug.Log(studentIds[count] + "가 수업에 입력되었습니다.");
}
}
});
}
public void GetGroupList(string use)
{
var groups = new List<GroupWithRoles>();
var request = new ListMembershipRequest { Entity = new PlayFab.GroupsModels.EntityKey { Id = playerEntity.Id, Type = playerEntity.Type } };
PlayFabGroupsAPI.ListMembership(request,
(result) =>
{
groups = result.Groups.ToList();
Debug.Log("그룹 정보 가져오기 성공. Count = " + groups.Count);
if (use.Equals("OpenClassListWindow"))
UIManager.Instance.OpenClassListWindowCallBack(groups);
else if (use.Equals("ShowClassInfo"))
UIManager.Instance.ShowClassInfoBtnCallBack(groups);
},
(error) => { Debug.Log("그룹 정보 가져오기 성공 " + error); groups = null; });
}
public void InviteToGroup(string groupName, string studentIdString)
{
PlayFab.GroupsModels.EntityKey groupEntity = new PlayFab.GroupsModels.EntityKey();
PlayFabGroupsAPI.GetGroup(new GetGroupRequest { GroupName = groupName },
(result) =>
{
groupEntity = result.Group;
PlayFabClientAPI.GetAccountInfo(new GetAccountInfoRequest { Username = studentIdString },
(result) => {
var request = new InviteToGroupRequest
{
Group = groupEntity,
Entity = new PlayFab.GroupsModels.EntityKey { Id = result.AccountInfo.TitleInfo.TitlePlayerAccount.Id, Type = result.AccountInfo.TitleInfo.TitlePlayerAccount.Type },
RoleId = "members"
};
PlayFabGroupsAPI.InviteToGroup(request,
(invitationResult) =>
{
Debug.Log("Invited!");
invitingGroupEvent.Invoke();
}, (error) => { Debug.Log(error); });
}, (error) => { });
}, (error) => Debug.Log(error.ErrorMessage));
}
public void AcceptGroupInvitation()
{
var request = new ListMembershipOpportunitiesRequest { Entity = new PlayFab.GroupsModels.EntityKey { Id = playerEntity.Id, Type = playerEntity.Type } };
PlayFabGroupsAPI.ListMembershipOpportunities(request,
(result) =>
{
for(int count = 0; count < result.Invitations.Count; count++)
{
var request = new AcceptGroupInvitationRequest {
Group = result.Invitations[count].Group,
Entity = new PlayFab.GroupsModels.EntityKey { Id = playerEntity.Id, Type = playerEntity.Type }
};
PlayFabGroupsAPI.AcceptGroupInvitation(request, (result) => { Debug.Log("그룹 가입 성공"); }, (error) => { Debug.Log("그룹 가입 실패 " + error); });
}
}, (error) => { Debug.Log("그룹 초대 정보 불러오기 실패 " + error); });
}
public void AcceptGroupInvitationWithUpdateData()
{
var request = new ListMembershipOpportunitiesRequest { Entity = new PlayFab.GroupsModels.EntityKey { Id = playerEntity.Id, Type = playerEntity.Type } };
PlayFabGroupsAPI.ListMembershipOpportunities(request,
(listResult) =>
{
for (int count = 0; count < listResult.Invitations.Count; count++)
{
var request = new AcceptGroupInvitationRequest
{
Group = listResult.Invitations[count].Group,
Entity = new PlayFab.GroupsModels.EntityKey { Id = playerEntity.Id, Type = playerEntity.Type }
};
PlayFabGroupsAPI.AcceptGroupInvitation(request,
(acceptResult) =>
{
for (int count = 0; count < listResult.Invitations.Count; count++)
{
Debug.Log("그룹 가입 성공");
UpdateClassTimeTable(listResult.Invitations[count].Group.Id, listResult.Invitations[count].Group.Type);
UpdateLeaderBoardStudentOnClass(listResult.Invitations[count].Group.Id, listResult.Invitations[count].Group.Type);
}
}, (error) => { Debug.Log("그룹 가입 실패 " + error); });
}
}, (error) => { Debug.Log("그룹 초대 정보 불러오기 실패 " + error); });
}
public void RemoveMemberFromGroup(string groupName, string playerName)
{
Debug.Log("Remove " + playerName + " from " + groupName);
var getGroupRequest = new GetGroupRequest { GroupName = groupName };
PlayFabGroupsAPI.GetGroup(getGroupRequest,
(getGroupResult) =>
{
var getUserRequest = new GetAccountInfoRequest { TitleDisplayName = playerName };
PlayFabClientAPI.GetAccountInfo(getUserRequest,
(getUserResult) =>
{
Debug.Log(getUserResult.AccountInfo.TitleInfo.TitlePlayerAccount.Id + " " + getUserResult.AccountInfo.TitleInfo.TitlePlayerAccount.Type);
var removeMemberRequest = new RemoveMembersRequest
{
Group = { Id = getGroupResult.Group.Id, Type = getGroupResult.Group.Type },
Members = new List<PlayFab.GroupsModels.EntityKey>
{
new PlayFab.GroupsModels.EntityKey { Id = getUserResult.AccountInfo.TitleInfo.TitlePlayerAccount.Id, Type = getUserResult.AccountInfo.TitleInfo.TitlePlayerAccount.Type }
}
};
PlayFabGroupsAPI.RemoveMembers(removeMemberRequest,
(result) =>
{
Debug.Log("그룹 내 멤버 삭제 성공");
}, (error) => { Debug.Log(error.Error); });
}, (error) => { Debug.Log(error.Error); });
}, (error) => { Debug.Log("그룹 내 멤버 삭제 실패" + error.Error); });
}
void UpdateClassTimeTable(string entityId, string entityType)
{
var request = new GetObjectsRequest { Entity = new PlayFab.DataModels.EntityKey { Id = entityId, Type = entityType } };
PlayFabDataAPI.GetObjects(request,
(objectResult) =>
{
ClassData classData = JsonUtility.FromJson<ClassData>(objectResult.Objects["ClassData"].DataObject.ToString());
if (!classData.secondEndTime.Equals(""))
SetUserData(classData.className + classData.classNumber,
classData.classNumber + "," + classData.classId + "," + classData.classInstructor + "," +
classData.firstDayOfWeek + "," + classData.firstStartTime + "~" + classData.firstEndTime + "," +
classData.secondDayOfWeek + "," + classData.secondStartTime + "~" + classData.secondEndTime);
else
SetUserData(classData.className + classData.classNumber,
classData.classNumber + "," + classData.classId + "," + classData.classInstructor + "," +
classData.firstDayOfWeek + "," + classData.firstStartTime + "~" + classData.firstEndTime);
Debug.Log("시간표 최신화 성공");
},
(error) => { Debug.Log("시간표 최신화 실패" + error); });
}
public GroupWithRoles FindSpecificGroup(List<GroupWithRoles> groups, string groupName)
{
GroupWithRoles result = new GroupWithRoles();
for(int count = groups.Count; count > 0; count--)
{
if(groups[count].GroupName == groupName)
{
result = groups[count];
}
}
return result;
}
public void UpdateObjectDataUsingEntity(string entityId, string entityType, string key, object value)
{
List<SetObject> setObjectsList = new List<SetObject>()
{
new SetObject()
{
ObjectName = key,
DataObject = value
}
};
var request = new SetObjectsRequest { Entity = new PlayFab.DataModels.EntityKey { Id = entityId, Type = entityType }, Objects = setObjectsList };
PlayFabDataAPI.SetObjects(request,
(result) => {
Debug.Log("그룹 업데이트 성공");
UpdateClassTimeTable(entityId, entityType);
}, (error) => Debug.Log("그룹 업데이트 실패" + error));
}
public void GetObjectData(string use, string entityId, string entityType, string key)
{
object returnObject = new object();
var request = new GetObjectsRequest { Entity = new PlayFab.DataModels.EntityKey { Id = entityId, Type = entityType } };
PlayFabDataAPI.GetObjects(request,
(result) =>
{
if (use.Equals("ClassData"))
{
UIManager.Instance.LoadModifyingClass(result.Objects[key].DataObject);
}
},
(error) => { Debug.LogError(error.GenerateErrorReport()); });
}
}