//	void Start()
//	{
//		if (UserManager.Instance != null) {
//			UserManager.Instance.GetFacebookFriends(true, FriendsReceived/*(args) => {
//				friendsArgs = args;
//			}*/);
//	//		StartCoroutine(CheckFriendsReceived());
//		}
//	}

//	UserFriendsDelegateEventArgs friendsArgs = null;
//	IEnumerator CheckFriendsReceived()
//	{
//		Debug.Log("Start checking friends received");
//		while (friendsArgs == null) {
//			yield return null;
//		}
//		Debug.Log("Friends received, calling function");
//		FriendsReceived(friendsArgs);
//		friendsArgs = null;
//	}

//	void FriendsReceived(UserFriendsDelegateEventArgs args)
//	{
//		foreach (LoadLevelButton button in levelButtons) {
//			if (button != null && button.friend != null) {
//				Destroy(button.friend.gameObject);
//				button.friend = null;
//			}
//		}
//#if UNITY_EDITOR
//		CreateFriendAvatar(null);
//#endif
//
//		if (args.FriendsList == null || args.FriendsList.Count == 0) {
//			return;
//		}
//
//		foreach (User user in args.FriendsList) {
//			CreateFriendAvatar(user);
//		}
//	}
//
//	void CreateFriendAvatar(User friend)
//	{
//		LoadLevelButton button1 = null;
//		LoadLevelButton button2 = null;
//
//#if UNITY_EDITOR
//		button1 = levelButtons[18 * 2];
//		button2 = levelButtons[18 * 2 + 1];
//#else
//		Debug.Log("Creating friend avatar: " + friend.FBName + " level: " + friend.LastFinishedLvl);
//
//		if (friend.LastFinishedLvl < LoadLevelButton.maxLevels) {
//			button1 = levelButtons[(friend.LastFinishedLvl + 1) * 2]; //last unlocked level is +1
//			button2 = levelButtons[(friend.LastFinishedLvl + 1) * 2 + 1];
//		}
//		else if (friend.LastFinishedLvl == LoadLevelButton.maxLevels) {
//			button1 = levelButtons[friend.LastFinishedLvl * 2]; //all levels finished so last unlocked level is the last finished level
//			button2 = levelButtons[friend.LastFinishedLvl * 2 + 1];
//		}
//#endif
//
//		if (button1 != null && button1.friend == null) {
//			SetFriendAvatar(button1, friend);
//			SetFriendAvatar(button2, friend);
//		}
//	}
//
//	void SetFriendAvatar(LoadLevelButton button, User friend)
//	{
//		GameObject friendAvatarObj = GameObject.Instantiate(friendAvatarPrefab) as GameObject;
//		Transform friendTransform = friendAvatarObj.transform;
//		friendTransform.parent = button.transform;
//		friendTransform.localPosition = GetPositionOnButton(button.friendAvatarPos);
//		friendTransform.localScale = Vector3.one;
//
//		button.friend = friendAvatarObj.GetComponent<FriendAvatar>();
//		button.friend.friend = friend;
//		button.friend.Refresh();
//	}

    Vector3 GetPositionOnButton(LoadLevelButton.AvatarPos avatarPos)
    {
        if (avatarPos == LoadLevelButton.AvatarPos.Left)
        {
            return(new Vector3(-73f, 0f, -2f));
        }
        else if (avatarPos == LoadLevelButton.AvatarPos.Right)
        {
            return(new Vector3(73f, 0f, -2f));
        }
        else if (avatarPos == LoadLevelButton.AvatarPos.Top)
        {
            return(new Vector3(0f, 57f, -2f));
        }
        else if (avatarPos == LoadLevelButton.AvatarPos.Bottom)
        {
            return(new Vector3(0f, -50f, -2f));
        }

        return(Vector3.zero);
    }
 public void UpdateOldAvatarPosition(Vector3 pos, LoadLevelButton.AvatarPos avatarPos)
 {
     avatarOldPosition = pos + GetPositionOnButton(avatarPos);
 }
 public void UpdateAvatarPosition(Vector3 pos, LoadLevelButton.AvatarPos avatarPos)
 {
     avatarPosition = pos + GetPositionOnButton(avatarPos);
     avatarScale    = avatarPos == LoadLevelButton.AvatarPos.Right ? new Vector3(-1f, 1f, 1f) : Vector3.one;
 }