Advertisement
Guest User

MessagingClientReceiver

a guest
Mar 25th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class MessagingClientReceiver : MonoBehaviour {
  6.  
  7.     // Use this for initialization
  8.     void Start()
  9.     {
  10.         //Debug.Log ("Starting Messaging Client Receiver");
  11.         MessagingManager.Instance.Subscribe(ThePlayerIsTryingToLeave);
  12.         //Debug.Log ("Ending Messaging Client Receiver");
  13.     }
  14.     void ThePlayerIsTryingToLeave()
  15.     {
  16.         //Debug.Log ("Starting getting Conversation Component");
  17.         var dialog = GetComponent<ConversationComponent>();
  18.         if (dialog != null)
  19.         {
  20.             if (dialog.Conversations != null && dialog.Conversations.Length > 0)
  21.             {
  22.                 var conversation = dialog.Conversations[0];
  23.                 if (conversation != null)
  24.                 {
  25.                     ConversationManager.Instance.StartConversation(conversation);
  26.                 }
  27.             }
  28.         }
  29.         //Debug.Log ("Ending getting Conversation Component");
  30.     }
  31.    
  32.     void OnDestroy()
  33.     {
  34.         if (MessagingManager.Instance != null)
  35.         {
  36.             MessagingManager.Instance.UnSubscribe(ThePlayerIsTryingToLeave);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement