示例#1
0
        void Start()
        {
            InitializeInfo();

            _musicAudioSource = GetComponents <AudioSource>()[1];

            // Reminder and Facebook aren't supported in Unity Editor.
#if !UNITY_EDITOR && UNITY_WINRT_8_1
            if (ReminderManager.AreRemindersEnabled() && DateTime.TryParse(PlayerPrefs.GetString("_reminderStartTime", string.Empty), out _reminderStartTime))
            {
                CheckReminder();

                if (ReminderScheduled)
                {
                    ReminderInfo = ReminderTextPrefix + _reminderStartTime.AddSeconds(ReminderTime).ToString("hh:mm tt");
                }
            }
            else
            {
                ReminderScheduled = false;
                ReminderInfo      = NoReminderText;
            }
#else
            ReminderScheduled = false;
            ReminderInfo      = NoReminderText;
#endif

            CreateTiles();
            DoChangeState(GAME_STATE.GS_START);

#if !UNITY_EDITOR && UNITY_WINRT_8_1
            FBWin.Init(SetFBInit, GameController.Instance.GameConfig.FacebookAppId, null);
#endif
        }
示例#2
0
        // Request the players friends.
        // As per FB API v2.0 You can only request friends that have installed and logged in on the app,
        // you can no longer poll all the players friends.
        // https://developers.facebook.com/bugs/1502515636638396/
        public void PopulateFriends()
        {
            Debug.Log("Populate Friends.");
#if !UNITY_EDITOR && UNITY_WINRT_8_1
            if (FBWin.IsLoggedIn)
            {
                // Get the friends
                FBWin.API("/me/friends", HttpMethod.GET, GetFriendsCallback);
            }
#endif
        }
        void FacebookIntegrationGUI(int windowID)
        {
            if (!FBWin.IsLoggedIn)
            {
                if (GUILayout.Button("Login", GUILayout.MinHeight(ButtonHeight)))
                {
#if !UNITY_EDITOR && UNITY_WINRT_8_1
                    FBWin.Login("email,publish_actions,user_friends", _gameMasterScript.FBLoginCallback);
#endif
                }
            }
            else
            {
                TextAnchor originalAlign = GUI.skin.label.alignment;
                GUI.skin.label.alignment = TextAnchor.MiddleCenter;

                // Display Facebook user name.
                GUILayout.Label(_gameMasterScript.FacebookName);

                // Display Facebook user image.
                if (_gameMasterScript.FacebookImage != null)
                {
                    GUILayout.Label(_gameMasterScript.FacebookImage, GUILayout.MinHeight(ButtonHeight * 2));
                }

                // Display number of Facebook friends.
                GUILayout.Label(_gameMasterScript.FacebookFriends);

                GUILayout.Label(Separator, GUILayout.MaxWidth(WindowWidth));

                GUI.skin.label.alignment = originalAlign;

                if (GUILayout.Button("Invite Friends", GUILayout.MinHeight(ButtonHeight)))
                {
                    _gameMasterScript.InviteFriends();
                }

                if (GUILayout.Button("Post to Feed", GUILayout.MinHeight(ButtonHeight)))
                {
                    _gameMasterScript.PostFeed();
                }

                if (GUILayout.Button("Logout", GUILayout.MinHeight(ButtonHeight)))
                {
                    FBWin.Logout();
                    StartCoroutine(_gameMasterScript.FBLogoutCallback());
                }
            }
        }
示例#4
0
        public void InviteFriends()
        {
            Debug.Log("Invite Friends.");
#if !UNITY_EDITOR && UNITY_WINRT_8_1
            if (FBWin.IsLoggedIn)
            {
                // title param only supported in WP8 (FBNative) at the moment.
                FBWin.AppRequest(message: "Come Play FaceFlip!", callback: (result) =>
                {
                    Debug.Log("AppRequest result: " + result.Text);
                    if (result.Json != null)
                    {
                        Debug.Log("AppRequest Json: " + result.Json.ToString());
                    }
#if UNITY_WP_8_1
                }, title: "FaceFlip Invite");
#else
                });