예제 #1
0
    void OnApplicationPause(bool paused)
    {
        if (paused)
        {
            Schedule(User.GetLifesManager.GetTimeWhenAllLifesWillRestored(), GameStrings.GetLocalizedString(GameStrings.LocalNotifications_AllLifesRestored), IdEvent_AllLifesRestored);

            DateTime date = DateTime.Now;
            date = date.AddDays(1);
            Schedule(date, GameStrings.GetLocalizedString(GameStrings.LocalNotifications_LaunchMe24Hours), IdEvent_RememberAfter24hours);

            date = date.AddDays(1);
            Schedule(date, GameStrings.GetLocalizedString(GameStrings.LocalNotifications_LaunchMe48Hours), IdEvent_RememberAfter48hours);

            date = date.AddDays(5);
            Schedule(date, GameStrings.GetLocalizedString(GameStrings.LocalNotifications_LaunchMe7Days), IdEvent_RememberAfter7Days);
        }
        else
        {
            LocalNotification setToZeroBadge = new LocalNotification();
            setToZeroBadge.fireDate = System.DateTime.Now;
            setToZeroBadge.applicationIconBadgeNumber = -1000;
            setToZeroBadge.hasAction = true;
            NotificationServices.PresentLocalNotificationNow(setToZeroBadge);

            CancelAllEvents();
        }
    }
예제 #2
0
    public static void PostScreenshot(Texture2D tex, FBManagerDelegate callback = null)
    {
        byte[] screenshot = tex.EncodeToPNG();

        WWWForm form = new WWWForm();

        form.AddBinaryData("image", screenshot);
        form.AddField("message", GameStrings.GetLocalizedString(GameStrings.FB_ShareScreenshot_message));

        if (callback != null)
        {
            Instance.callbacks[Instance.OnFBSendScreenshot] = callback;
        }

        if (FB.IsLoggedIn)
        {
            FB.API("me/photos", Facebook.HttpMethod.POST, Instance.OnFBSendScreenshot, form);

            SendToFlurryAboutScreenshot();
        }
        else
        {
            Instance.formWithScreenshot = form;
            FB.Login(mInstance.permissions, Instance.OnFBLoginBeforePostScreenshotEvent);
        }
    }
예제 #3
0
    private static List <LocalNotificationDesc> GetSortedEvents()
    {
        List <LocalNotificationDesc> arrEvents = new List <LocalNotificationDesc>(mInstance._allEvents);

        int countNightEvents = 0;

        foreach (LocalNotificationDesc desc in arrEvents)
        {
            if (IsNight(desc.fireDate))
            {
                ++countNightEvents;
            }
        }

        if (countNightEvents > 0)
        {
            LocalNotificationDesc newDesc = new LocalNotificationDesc();
            if (countNightEvents > 1)
            {
                newDesc.message = GameStrings.GetLocalizedString(GameStrings.LocalNotifications_CommonText);
            }

            bool isFound = false;
            do
            {
                isFound = false;
                foreach (LocalNotificationDesc desc in arrEvents)
                {
                    if (IsNight(desc.fireDate))
                    {
                        newDesc.fireDate = CreateDateByMorning(desc.fireDate);
                        if (countNightEvents == 1)
                        {
                            newDesc.message = desc.message;
                        }

                        isFound = true;
                        arrEvents.Remove(desc);
                        break;
                    }
                }
            } while (isFound);

            arrEvents.Add(newDesc);
        }

        arrEvents.Sort(ComparisonLocalNotifications);
        return(arrEvents);
    }