Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using PixelCrushers.DialogueSystem;
  5. using com.ootii.Actors.AnimationControllers;
  6.  
  7. public class OnTalking : MonoBehaviour
  8. {
  9.  
  10.     public GameObject pPlayer;
  11.  
  12.     public string conversationName;
  13.     public int conversationID;
  14.  
  15.     private bool inputEnable = false;
  16.     private MotionController mMotionController;
  17.  
  18.     // Use this for initialization
  19.     void Start()
  20.     {
  21.  
  22.     }
  23.  
  24.     // Update is called once per frame
  25.     void Update()
  26.     {
  27.         SetInput();
  28.         CheckIsConversationActive();
  29.     }
  30.  
  31.     void Reset()
  32.     {
  33.         pPlayer = null;
  34.         conversationName = null;
  35.         conversationID = 0;
  36.         inputEnable = false;
  37.     }
  38.  
  39.     void OnInteract()
  40.     {
  41.         DialogueManager.StartConversation(conversationName, pPlayer.transform, gameObject.transform, conversationID);
  42.     }
  43.  
  44.     void SetInput()
  45.     {
  46.         mMotionController = pPlayer.GetComponent<MotionController>();
  47.  
  48.         if (mMotionController != null)
  49.         {
  50.             if (inputEnable)
  51.             {
  52.                 mMotionController.InputSource.IsEnabled = false;
  53.             }
  54.             else
  55.             {
  56.                 mMotionController.InputSource.IsEnabled = true;
  57.             }
  58.         }
  59.     }
  60.  
  61.     void CheckIsConversationActive()
  62.     {
  63.         bool isConversationActive = DialogueManager.IsConversationActive;
  64.  
  65.         if (isConversationActive)
  66.         {
  67.             Debug.Log("Active");
  68.             inputEnable = true;
  69.         }
  70.         else
  71.         {
  72.             Debug.Log("Inactive");
  73.             inputEnable = false;
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement