浏览代码

Fix Interaction System doesn't follow the FSM

/devlogs-3-input
alex 4 年前
当前提交
9fd881be
共有 11 个文件被更改,包括 120 次插入8 次删除
  1. 6
      UOP1_Project/Assets/Prefabs/Characters/PigChef.prefab
  2. 1
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/PickUp.asset
  3. 1
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/Talk.asset
  4. 28
      UOP1_Project/Assets/Scripts/Interaction/InteractionManager.cs
  5. 2
      UOP1_Project/Assets/Scripts/Interaction/InteractionManager.cs.meta
  6. 16
      UOP1_Project/Assets/ScriptableObjects/EventChannels/InteractionResponse.asset
  7. 8
      UOP1_Project/Assets/ScriptableObjects/EventChannels/InteractionResponse.asset.meta
  8. 15
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/ActiveInteractionResponse_OnEnter.asset
  9. 8
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/ActiveInteractionResponse_OnEnter.asset.meta
  10. 32
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ActiveInteractionResponse_OnEnterSO.cs
  11. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ActiveInteractionResponse_OnEnterSO.cs.meta

6
UOP1_Project/Assets/Prefabs/Characters/PigChef.prefab


value:
objectReference: {fileID: 11400000, guid: 582b52ca2b84a41528fe274eea1ced6a,
type: 2}
- target: {fileID: 3466124848074566184, guid: f8b7770f18df7614e90765b366548764,
type: 3}
propertyPath: _oninteractResponsed
value:
objectReference: {fileID: 11400000, guid: cc6333f29e3561040b0420b725091f63,
type: 2}
- target: {fileID: 7947030310713933739, guid: f8b7770f18df7614e90765b366548764,
type: 3}
propertyPath: m_Name

1
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/PickUp.asset


m_EditorClassIdentifier:
_actions:
- {fileID: 11400000, guid: c59d2da85947b33468828f95284faec4, type: 2}
- {fileID: 11400000, guid: cf80877aa39a92945a1b883ba13978a4, type: 2}

1
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/Talk.asset


_actions:
- {fileID: 11400000, guid: 7ad91f04f328d9d42a677833fa39748d, type: 2}
- {fileID: 11400000, guid: 1cbeab9d369d57546a33afac8ca7810f, type: 2}
- {fileID: 11400000, guid: cf80877aa39a92945a1b883ba13978a4, type: 2}

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


[Header("Listening to")]
//Check if the interaction ended
[SerializeField] private VoidEventChannelSO _onInteractionEnded = default;
[SerializeField] private VoidEventChannelSO _oninteractResponsed = default;
_oninteractResponsed.OnEventRaised += OninteractionResponseActivated;
_oninteractResponsed.OnEventRaised -= OninteractionResponseActivated;
_onInteractionEnded.OnEventRaised -= OnInteractionEnd;
}

}
}
void OnInteractionButtonPress()
// interaction button press event handler activated by the StateMachine
void OninteractionResponseActivated()
{
//remove interaction after press
Interaction onGoingInteraction = _ongoingInteractions.Count > 0 ?

Item currentItem = itemObject.GetComponent<CollectibleItem>().GetItem();
_onObjectPickUp.RaiseEvent(currentItem);
//Debug.Log("PickUp event raised");
//set current interaction for state machine
currentInteraction = InteractionType.PickUp;
//destroy the GO
Destroy(itemObject);
break;
case InteractionType.Cook:

//Change the action map
_inputReader.EnableMenuInput();
//set current interaction for state machine
currentInteraction = InteractionType.Cook;
if (_onCookingStart != null)
if (_startTalking != null)
{
//raise an event with an actor as parameter
//Actor currentActor = currentInteractableObject.GetComponent<Dialogue>().GetActor();

_inputReader.EnableDialogueInput();
//set current interaction for state machine
currentInteraction = InteractionType.Talk;
}
}
void OnInteractionButtonPress()
{
Interaction onGoingInteraction = _ongoingInteractions.Count > 0 ?
_ongoingInteractions.First.Value : Interaction.NONE;
//set current interaction for state machine
if (onGoingInteraction.Type != InteractionType.None)
{
currentInteraction = onGoingInteraction.Type;
}
}

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


type: 2}
- _onInteractionEnded: {fileID: 11400000, guid: c499d87f35465124f8fb2751b150430d,
type: 2}
- _oninteractResponsed: {fileID: 11400000, guid: cc6333f29e3561040b0420b725091f63,
type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:

16
UOP1_Project/Assets/ScriptableObjects/EventChannels/InteractionResponse.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7fafac715ff920c4383fed91a38a351e, type: 3}
m_Name: InteractionResponse
m_EditorClassIdentifier:
description: used by the statemachine for activate a response to an interactEvent
from interactionManager

8
UOP1_Project/Assets/ScriptableObjects/EventChannels/InteractionResponse.asset.meta


fileFormatVersion: 2
guid: cc6333f29e3561040b0420b725091f63
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/ActiveInteractionResponse_OnEnter.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b6369aa6a2e82e64c9beb56fbfeea9be, type: 3}
m_Name: ActiveInteractionResponse_OnEnter
m_EditorClassIdentifier:
interactResponse: {fileID: 11400000, guid: cc6333f29e3561040b0420b725091f63, type: 2}

8
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/ActiveInteractionResponse_OnEnter.asset.meta


fileFormatVersion: 2
guid: cf80877aa39a92945a1b883ba13978a4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

32
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ActiveInteractionResponse_OnEnterSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "ActiveInteractionResponse_OnEnter", menuName = "State Machines/Actions/Active Interaction Response On Enter")]
public class ActiveInteractionResponse_OnEnterSO : StateActionSO
{
public VoidEventChannelSO interactResponse;
protected override StateAction CreateAction() => new ActiveInteractionResponse_OnEnter();
}
public class ActiveInteractionResponse_OnEnter : StateAction
{
protected new ActiveInteractionResponse_OnEnterSO OriginSO => (ActiveInteractionResponse_OnEnterSO)base.OriginSO;
public override void Awake(StateMachine stateMachine)
{
}
public override void OnUpdate()
{
OriginSO.interactResponse.RaiseEvent();
}
public override void OnStateEnter()
{
}
public override void OnStateExit()
{
}
}

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ActiveInteractionResponse_OnEnterSO.cs.meta


fileFormatVersion: 2
guid: b6369aa6a2e82e64c9beb56fbfeea9be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存