浏览代码

Updates on interaction manager

/main
Amel 4 年前
当前提交
c4c8c250
共有 2 个文件被更改,包括 38 次插入36 次删除
  1. 66
      UOP1_Project/Assets/Scripts/Interaction/InteractionManager.cs
  2. 8
      UOP1_Project/Assets/Scripts/Interaction/InteractionManager.cs.meta

66
UOP1_Project/Assets/Scripts/Interaction/InteractionManager.cs


public class InteractionManager : MonoBehaviour
{
public Interaction _interaction;
public InputReader inputReader;
private Interaction _interaction;
[SerializeField] private InputReader _inputReader = default;
GameObject currentInteractableObject = null;
private GameObject _currentInteractableObject = null;
//Or do we want to have stg specific for every type of interaction like:
//Item for pickup?
//Character (or other relevant type) for talk?

[Header("Broadcasting on")]
[SerializeField] private GameObjectEventChannelSO _OnObjectPickUp = default;
[SerializeField] private GameObjectEventChannelSO _onObjectPickUp = default;
[SerializeField] private VoidEventChannelSO _OnCookingStart = default;
[SerializeField] private GameObjectEventChannelSO _StartTalking = default;
[SerializeField] private VoidEventChannelSO _onCookingStart = default;
[SerializeField] private GameObjectEventChannelSO _startTalking = default;
[SerializeField] private InteractionUIEventChannelSO _ToggleInteractionUI = default;
//Check if the interaction ended
[SerializeField] private VoidEventChannelSO _InteractionEnded = default;
[SerializeField] private InteractionUIEventChannelSO _toggleInteractionUI = default;
[Header("Listening to")]
//Check if the interaction ended
[SerializeField] private VoidEventChannelSO _onInteractionEnded = default;
inputReader.interactEvent += OnInteractionButtonPress;
_InteractionEnded.OnEventRaised += OnInteractionEnd;
_inputReader.interactEvent += OnInteractionButtonPress;
_onInteractionEnded.OnEventRaised += OnInteractionEnd;
inputReader.interactEvent -= OnInteractionButtonPress;
_InteractionEnded.OnEventRaised -= OnInteractionEnd;
_inputReader.interactEvent -= OnInteractionButtonPress;
_onInteractionEnded.OnEventRaised -= OnInteractionEnd;
inputReader.EnableGameplayInput();
_inputReader.EnableGameplayInput();
//We don't show the interaction UI when we already picked up the object
case Interaction.None:
case Interaction.PickUp:
return;
_ToggleInteractionUI.RaiseEvent(true, _interaction);
_toggleInteractionUI.RaiseEvent(true, _interaction);
Debug.Log("Display interaction UI");
break;
default:

case Interaction.None:
return;
case Interaction.PickUp:
if(currentInteractableObject != null)
if(_currentInteractableObject != null)
//pass the item SO to the UI?
_OnObjectPickUp.RaiseEvent(currentInteractableObject);
//pass the item SO to the UI? we do it once we merge with inventory stuff
//Item currentItem = currentInteractableObject.GetComponent<Pickable>.item;
_onObjectPickUp.RaiseEvent(_currentInteractableObject);
//bool for SM
Destroy(_currentInteractableObject);
_OnCookingStart.RaiseEvent();
_onCookingStart.RaiseEvent();
//inputReader.EnableUIInput();
_inputReader.EnableUIInput();
if (currentInteractableObject != null)
if (_currentInteractableObject != null)
_StartTalking.RaiseEvent(currentInteractableObject);
//raise an event with an actor: DialogueEventChannelSo
_startTalking.RaiseEvent(_currentInteractableObject);
inputReader.EnableDialogueInput();
_inputReader.EnableDialogueInput();
}
break;
default:

Debug.Log("I triggered an NPC!");
DisplayInteractionUI();
}
currentInteractableObject = other.gameObject;
_currentInteractableObject = other.gameObject;
_ToggleInteractionUI.RaiseEvent(true, _interaction);
_toggleInteractionUI.RaiseEvent(true, _interaction);
}
private void OnTriggerExit(Collider other)

private void ResetInteraction()
{
_interaction = Interaction.None;
currentInteractableObject = null;
_currentInteractableObject = null;
//Do we need to detect the button press first of the trigger first
//If we detect trigger first, to destroy the object later we need to keep a ref
//I think the dialogue and UI should switch the action maps? for now I do here but maybe to change later

8
UOP1_Project/Assets/Scripts/Interaction/InteractionManager.cs.meta


MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
defaultReferences:
- _inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
- _onObjectPickUp: {instanceID: 0}
- _onCookingStart: {instanceID: 0}
- _startTalking: {instanceID: 0}
- _toggleInteractionUI: {instanceID: 0}
- _onInteractionEnded: {instanceID: 0}
executionOrder: 0
icon: {instanceID: 0}
userData:
正在加载...
取消
保存