Advertisement
SimonDarksideJ

MU2D - Broadcast receiver for new conversation

Aug 29th, 2015
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class GreandalMessagingReceiver : MonoBehaviour {
  5.  
  6.     void Start()
  7.     {
  8.         MessagingManager.Instance.GreandalSubscribe(GreandalConversations);
  9.     }
  10.  
  11.     void GreandalConversations()
  12.     {
  13.         Debug.Log("Starting conversation");
  14.         var dialog = GetComponent<ConversationComponent>();
  15.         if (dialog != null)
  16.         {
  17.             if (dialog.Conversations != null && dialog.Conversations.Length > 0)
  18.             {
  19.                 var conversation = dialog.Conversations[0];
  20.                 if (conversation != null && !conversation.Complete)
  21.                 {
  22.                     ConversationManager.Instance.StartConversation(conversation);
  23.                 }
  24.                             else
  25.             {
  26.                 Debug.Log("No active conversation found");
  27.             }
  28.             }
  29.             else
  30.             {
  31.                 Debug.Log("No conversation found");
  32.             }
  33.         }
  34.     }
  35.  
  36.     void OnDestroy()
  37.     {
  38.         if (MessagingManager.Instance != null)
  39.         {
  40.             MessagingManager.Instance.GreandalUnSubscribe(GreandalConversations);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement