Exemplo n.º 1
0
    public override void DidShow(ResourcePanelData<CharacterMessage> data)
    {
        TablePanel.Clear();

        foreach (var response in data.Resource.Responses)
        {
            var item = TablePanel.AddItem(ResponseItem);

            item.Populate(response);

            var evtid = response.Event;

            item.Button.onClick.AddListener(() =>
            {
                if (evtid != null)
                {
                    data.ActivationContext.FireEvent(evtid);
                }

                Back();
            });
        }

        base.DidShow(data);
    }
Exemplo n.º 2
0
        void ApplyObjectAction(string objectId, string action, bool oneShot)
        {
            if (objectId == null)
            {
                return;
            }

            ResourceActivationContext inspectorCtxt = m_inspectors.GetLastOrDefault(objectId);

            if (inspectorCtxt != null && inspectorCtxt.InstanceId != m_currInspectorId)
            {
                // There's an inspector that matches this object
                m_currAction      = action;
                m_currObjId       = objectId;
                m_isOneShotAction = oneShot;

                var inspector = inspectorCtxt.Resource as ObjectInspector;

                if (inspector.Content is ScreenMessage)
                {
                    var screenMsg = (ScreenMessage)inspector.Content;

                    var data = new ResourcePanelData <ScreenMessage>(inspectorCtxt, screenMsg);

                    // Set curr id here so that a "pop" doesn't clear it.
                    m_currInspectorId = inspectorCtxt.InstanceId;

                    Action onClose = () =>
                    {
                        inspectorCtxt.Close();

                        m_currInspectorId = null;

                        if (m_isOneShotAction)
                        {
                            EndObjectAction(objectId, action);
                        }
                    };

                    if (screenMsg.Responses != null && screenMsg.Responses.Length > 0)
                    {
                        m_currPanel = ScreenDialogPanel;

                        PanelManager.Instance.Push(ScreenDialogPanel, data, onClose);
                    }
                    else
                    {
                        m_currPanel = ScreenMessagePanel;

                        PanelManager.Instance.Push(ScreenMessagePanel, data, onClose);
                    }
                }
            }
        }
        protected virtual void PlayScreenContent(ResourceActivationContext context, PlayableContent playable, Action onClose)
        {
            if (playable.Content is ScreenMessage)
            {
                var screenMsg = playable.Content as ScreenMessage;

                var data = new ResourcePanelData <ScreenMessage>(context, screenMsg);

                if (screenMsg.Responses != null && screenMsg.Responses.Length > 0)
                {
                    PushScreenDialogPanel(context, playable, screenMsg, data, onClose);
                }
                else
                {
                    PushScreenMessagePanel(context, playable, screenMsg, data, onClose);
                }
            }
            else if (playable.Content is CharacterMessage)
            {
                var charMsg = playable.Content as CharacterMessage;

                var data = new ResourcePanelData <CharacterMessage>(context, charMsg);

                if (charMsg.Responses != null && charMsg.Responses.Length > 0)
                {
                    PushCharacterDialogPanel(context, playable, charMsg, data, onClose);
                }
                else
                {
                    PushCharacterMessagePanel(context, playable, charMsg, data, onClose);
                }
            }
            else if (playable.Content is Notification)
            {
                var notification = playable.Content as Notification;

                var data = new ResourcePanelData <Notification>(context, notification);

                PlayNotification(context, playable, playable.Content as Notification, data, onClose);
            }
            else if (playable.Content is MediaContent)
            {
                var media = playable.Content as MediaContent;

                var data = new ResourcePanelData <MediaContent>(context, media);

                PlayMediaContent(context, playable, media, data, onClose);
            }
            else
            {
                m_logger.Error("Unsupported content type with route=screen: {0}",
                               playable.Content == null ? "null" : playable.Content.Type);
            }
        }
        protected virtual void PlayNotification(ResourceActivationContext context, PlayableContent playable, Notification notification, ResourcePanelData <Notification> data, Action onClose)
        {
            if (Platform.Instance.IsInBackground)
            {
                context.Open();

                if (!BackgroundNotifier.Instance.HasNotification(context.InstanceId))
                {
                    var localNotification = new Motive.Core.Notifications.LocalNotification();

                    localNotification.Title = notification.Title;
                    localNotification.Text  = notification.Message;

                    Platform.Instance.LocalNotificationManager.PostNotification(playable.Id, localNotification);
                }

                BackgroundNotifier.Instance.RemoveNotification(context.InstanceId);

                /*
                 * if (notification.SoundUrl != null)
                 * {
                 *  var path = WebServices.Instance.MediaDownloadManager.GetPathForItem(notification.SoundUrl);
                 *  m_channel.Play(new Uri(path));
                 * }*/

                if (onClose != null)
                {
                    onClose();
                }
            }
            else
            {
                if (notification.Title != null ||
                    notification.Message != null)
                {
                    Push(context, PanelStack, NotificationPanel, data, onClose);
                }
                else
                {
                    context.Open();

                    if (notification.Vibrate)
                    {
                        Platform.Instance.LocalNotificationManager.Vibrate();
                    }

                    if (notification.Sound != null)
                    {
                        Platform.Instance.PlaySound(notification.Sound.Url);
                    }

                    if (onClose != null)
                    {
                        onClose();
                    }
                }
            }
        }
 protected virtual void PlayMediaContent(ResourceActivationContext context, PlayableContent playable, MediaContent media, ResourcePanelData <MediaContent> data, Action onClose)
 {
     if (IsAudioContent(playable.Content))
     {
         PushAudioPanel(context, playable, media, data, onClose);
     }
     else if (IsImageContent(playable.Content))
     {
         PushImagePanel(context, playable, media, data, onClose);
     }
     else if (IsVideoContent(media))
     {
         PushVideoPanel(context, playable, media, data, onClose);
     }
     else
     {
         m_logger.Error("Unsupported content type with route=screen: {0}",
                        playable.Content == null ? "null" : playable.Content.Type);
     }
 }
 protected virtual void PushAudioPanel(ResourceActivationContext context, PlayableContent playable, MediaContent media, ResourcePanelData <MediaContent> data, Action onClose)
 {
     Push(context, PanelStack, GetAudioPanel(context, playable), data, onClose);
 }
 protected virtual void PushCharacterMessagePanel(ResourceActivationContext context, PlayableContent playable, CharacterMessage charMsg, ResourcePanelData <CharacterMessage> data, Action onClose)
 {
     Push(context, PanelStack, GetCharacterMessagePanel(context, playable), data, onClose);
 }
 protected virtual void PushScreenMessagePanel(ResourceActivationContext context, PlayableContent playable, ScreenMessage screenMsg, ResourcePanelData <ScreenMessage> data, Action onClose)
 {
     Push(context, PanelStack, GetScreenMessagePanel(context, playable), data, onClose);
 }