123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using UnityEngine;
- using System.Collections;
- public class LifeMessagesList : ListBase
- {
- public LifeRequestItem lifeRequestItemPrefab;
- public LifeGivenItem lifeGivenItemPrefab;
- protected override Transform CreateRandomItemForTestingInEditor(int index)
- {
- if (Random.value < 0.5f)
- {
- RequestInfo data = new RequestInfo();
- data.senderName = "Avatar "+index;
- LifeRequestItem item = (LifeRequestItem)Instantiate(lifeRequestItemPrefab);
- item.SetData(data);
- return item.transform;
- } else
- {
- RequestInfo data = new RequestInfo();
- data.senderName = "Avatar "+index;
- LifeGivenItem item = (LifeGivenItem)Instantiate(lifeGivenItemPrefab);
- item.SetData(data);
- return item.transform;
- }
- }
- protected override bool HasItems()
- {
- return (FacebookHelper.Instance.lastReceivedRequests != null &&
- (FacebookHelper.Instance.lastReceivedRequests.lifeDemandRequests.Count > 0 ||
- FacebookHelper.Instance.lastReceivedRequests.lifeRequests.Count > 0));
- }
- protected override void CreateItems()
- {
- int row = 0;
- //Life Demands
- foreach (RequestInfo data in FacebookHelper.Instance.lastReceivedRequests.lifeDemandRequests)
- {
- LifeRequestItem item = (LifeRequestItem)Instantiate(lifeRequestItemPrefab);
- item.SetData(data);
- PlaceItem(item.transform, row);
- ++row;
- }
- //Life Gifts
- foreach (RequestInfo data in FacebookHelper.Instance.lastReceivedRequests.lifeRequests)
- {
- LifeGivenItem item = (LifeGivenItem)Instantiate(lifeGivenItemPrefab);
- item.SetData(data);
- PlaceItem(item.transform, row);
- ++row;
- }
- }
- }
|