浏览代码

Added the ability to talk

/main
Ciro Continisio 4 年前
当前提交
3db2e782
共有 16 个文件被更改,包括 123 次插入15 次删除
  1. 3
      UOP1_Project/Assets/Prefabs/Characters/PigChef.prefab
  2. 2
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/MoveInTheAir.asset
  3. 4
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/SetIsTalking_False.asset
  4. 2
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_JumpHoldButton.asset
  5. 12
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset
  6. 1
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/Idle.asset
  7. 2
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/Talk.asset
  8. 22
      UOP1_Project/Assets/Scripts/Characters/Protagonist.cs
  9. 15
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/IsHoldingExtraAction.asset
  10. 8
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/IsHoldingExtraAction.asset.meta
  11. 16
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_Talking.asset
  12. 8
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_Talking.asset.meta
  13. 32
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsHoldingExtraActionConditionSO.cs
  14. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsHoldingExtraActionConditionSO.cs.meta
  15. 0
      /UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_JumpHoldButton.asset.meta
  16. 0
      /UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_JumpHoldButton.asset

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


m_EditorClassIdentifier:
_transitionTableSO: {fileID: 11400000, guid: f0baa4ca2bfa24e4cb6d1efe9fa81ea3, type: 2}
_debugger:
debugTransitions: 0
debugTransitions: 1
appendConditionsInfo: 1
appendActionsInfo: 1
currentState:

_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
gameplayCamera: {fileID: 0}
jumpInput: 0
extraActionInput: 0
movementInput: {x: 0, y: 0, z: 0}
movementVector: {x: 0, y: 0, z: 0}
--- !u!1001 &616254372594363816

2
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/MoveInTheAir.asset


m_Script: {fileID: 11500000, guid: 09fcb347b6cb3524c9f59fbde36ec7c7, type: 3}
m_Name: MoveInTheAir
m_EditorClassIdentifier:
_speed: 6
_speed: 3.5

4
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/SetIsTalking_False.asset


m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4c70afd7f911db7449d578cc18700875, type: 3}
m_Name: SetIsTalking_True
m_Name: SetIsTalking_False
_newValue: 1
_newValue: 0

2
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_JumpHoldButton.asset


m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8139f9f328ed1144690b7a9ffca2d5b4, type: 3}
m_Name: JumpHoldTimer
m_Name: Timer_JumpHoldButton
m_EditorClassIdentifier:
cacheResult: 1
_timerLength: 0.4

12
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/PigChef_TransitionTable.asset


- ExpectedResult: 1
Condition: {fileID: 11400000, guid: c5090b215e4f1594f9d1ef6680cd15bb, type: 2}
Operator: 0
- FromState: {fileID: 11400000, guid: e128814ff6dbf63449bbc4dc8b6dc066, type: 2}
ToState: {fileID: 11400000, guid: ff92a93d8a8694247b507d811c88e402, type: 2}
Conditions:
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: b33fba8c83df19f4ead430fbcc728687, type: 2}
Operator: 0
- FromState: {fileID: 11400000, guid: ff92a93d8a8694247b507d811c88e402, type: 2}
ToState: {fileID: 11400000, guid: e128814ff6dbf63449bbc4dc8b6dc066, type: 2}
Conditions:
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: 2bfa25e0277246b4ba0ea0117c40c18b, type: 2}
Operator: 0

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


_actions:
- {fileID: 11400000, guid: 99b804881a9d5744fb4784c30000c0b5, type: 2}
- {fileID: 11400000, guid: c0d0573a78e4c6245ab9676e7af35880, type: 2}
- {fileID: 11400000, guid: 7ad91f04f328d9d42a677833fa39748d, type: 2}
- {fileID: 11400000, guid: bd85c54d16eb60c4c99504f1679af851, type: 2}
- {fileID: 11400000, guid: 47d9da417e68970419335f80f4395239, type: 2}

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


m_Name: Talk
m_EditorClassIdentifier:
_actions:
- {fileID: 0}
- {fileID: 11400000, guid: 988d4d429b1d3484e8b15f3735c804ec, type: 2}

22
UOP1_Project/Assets/Scripts/Characters/Protagonist.cs


using UnityEngine;
using System;
using UnityEngine;
/// <para>This class listens to the input and it deposits it on the <c>Character</c> component, ready to be used by the <c>StateMachine</c></para>
/// <para>This component consumes input on the InputReader and stores its values. The input is then read, and manipulated, by the StateMachines's Actions.</para>
/// </summary>
public class Protagonist : MonoBehaviour
{

private Protagonist _charScript;
//These fields are manipulated by the StateMachine actions
//These fields are read and manipulated by the StateMachine actions
[HideInInspector] public bool extraActionInput;
private void Awake()
{
_charScript = GetComponent<Protagonist>();
}
private void OnControllerColliderHit(ControllerColliderHit hit)
{
lastHit = hit;

_inputReader.jumpEvent += OnJumpInitiated;
_inputReader.jumpCanceledEvent += OnJumpCanceled;
_inputReader.moveEvent += OnMove;
_inputReader.extraActionEvent += OnExtraAction;
//...
}

_inputReader.jumpEvent -= OnJumpInitiated;
_inputReader.jumpCanceledEvent -= OnJumpCanceled;
_inputReader.moveEvent -= OnMove;
_inputReader.extraActionEvent -= OnExtraAction;
//...
}

private void OnJumpCanceled()
{
jumpInput = false;
}
// This handler is just used for debug, for now
private void OnExtraAction()
{
extraActionInput = true;
}
}

15
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/IsHoldingExtraAction.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: 5a9702ec6c86b134b9ed9963dc30d7bc, type: 3}
m_Name: IsHoldingExtraAction
m_EditorClassIdentifier:
cacheResult: 1

8
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/IsHoldingExtraAction.asset.meta


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

16
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_Talking.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: 8139f9f328ed1144690b7a9ffca2d5b4, type: 3}
m_Name: Timer_Talking
m_EditorClassIdentifier:
cacheResult: 1
_timerLength: 3

8
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_Talking.asset.meta


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

32
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsHoldingExtraActionConditionSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "IsHoldingExtraAction", menuName = "State Machines/Conditions/Is Holding ExtraAction")]
public class IsHoldingExtraActionConditionSO : StateConditionSO<IsHoldingExtraActionCondition> { }
public class IsHoldingExtraActionCondition : Condition
{
//Component references
private Protagonist _protagonistScript;
public override void Awake(StateMachine stateMachine)
{
_protagonistScript = stateMachine.GetComponent<Protagonist>();
}
protected override bool Statement()
{
if(_protagonistScript.extraActionInput)
{
// Consume the input
_protagonistScript.extraActionInput = false;
return true;
}
else
{
return false;
}
}
}

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsHoldingExtraActionConditionSO.cs.meta


fileFormatVersion: 2
guid: 5a9702ec6c86b134b9ed9963dc30d7bc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/JumpHoldTimer.asset.meta → /UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_JumpHoldButton.asset.meta

/UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/JumpHoldTimer.asset → /UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions/Timer_JumpHoldButton.asset

正在加载...
取消
保存