ChallengeRequestList.cs 1013 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. using System.Collections;
  3. public class ChallengeRequestList : ListBase
  4. {
  5. public ChallengeRequestItem challengeRequestItemPrefab;
  6. protected override Transform CreateRandomItemForTestingInEditor(int index)
  7. {
  8. RequestInfo r = new RequestInfo();
  9. r.senderName = "Avatar "+index;
  10. r.data = "{ score : "+ Random.Range(100, 500) +" }";
  11. ChallengeRequestItem item = (ChallengeRequestItem)Instantiate(challengeRequestItemPrefab);
  12. item.SetData(r);
  13. return item.transform;
  14. }
  15. protected override bool HasItems()
  16. {
  17. return (FacebookHelper.Instance.lastReceivedRequests != null &&
  18. FacebookHelper.Instance.lastReceivedRequests.challengeRequests.Count > 0);
  19. }
  20. protected override void CreateItems()
  21. {
  22. int row = 0;
  23. foreach (RequestInfo data in FacebookHelper.Instance.lastReceivedRequests.challengeRequests)
  24. {
  25. ChallengeRequestItem item = (ChallengeRequestItem)Instantiate(challengeRequestItemPrefab);
  26. item.SetData(data);
  27. PlaceItem(item.transform, row);
  28. ++row;
  29. }
  30. }
  31. }