浏览代码

wip fixing townsfolk state machine on talk and listen

/main
Amel 3 年前
当前提交
03aa1941
共有 13 个文件被更改,包括 202 次插入37 次删除
  1. 60
      UOP1_Project/Assets/Scenes/WIP/TestingGround.unity
  2. 15
      UOP1_Project/Assets/ScriptableObjects/StateMachine/NPC/Townsfolk/Townsfolk_TransitionTable.asset
  3. 2
      UOP1_Project/Assets/Scripts/Characters/NPC.cs
  4. 29
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsNPCSayingTheLineSO.cs
  5. 2
      UOP1_Project/Assets/Scripts/Quests/StepController.cs
  6. 14
      UOP1_Project/Assets/ScriptableObjects/StateMachine/NPC/Actions/SetLineSaid.asset
  7. 8
      UOP1_Project/Assets/ScriptableObjects/StateMachine/NPC/Actions/SetLineSaid.asset.meta
  8. 14
      UOP1_Project/Assets/ScriptableObjects/StateMachine/NPC/Conditions/HasTheLineBeenSaid.asset
  9. 8
      UOP1_Project/Assets/ScriptableObjects/StateMachine/NPC/Conditions/HasTheLineBeenSaid.asset.meta
  10. 32
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/SetLineSaidSO.cs
  11. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/SetLineSaidSO.cs.meta
  12. 33
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/HasTheLineBeenSaidSO.cs
  13. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/HasTheLineBeenSaidSO.cs.meta

60
UOP1_Project/Assets/Scenes/WIP/TestingGround.unity
文件差异内容过多而无法显示
查看文件

15
UOP1_Project/Assets/ScriptableObjects/StateMachine/NPC/Townsfolk/Townsfolk_TransitionTable.asset


- ExpectedResult: 0
Condition: {fileID: 11400000, guid: f4c89ffbe6ca8fe46ae22ec9d191671a, type: 2}
Operator: 0
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: 4f15fe7b4afb565469f360b403d50f64, type: 2}
Operator: 0
- FromState: {fileID: 11400000, guid: 3388e91c73e51e845a78aa522a2f2bda, type: 2}
ToState: {fileID: 11400000, guid: 7aedcd9c179a4824eaf24451ab5689ba, type: 2}
Conditions:

- ExpectedResult: 0
Condition: {fileID: 11400000, guid: f4c89ffbe6ca8fe46ae22ec9d191671a, type: 2}
Operator: 0
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: 4f15fe7b4afb565469f360b403d50f64, type: 2}
Operator: 0
- FromState: {fileID: 11400000, guid: 3388e91c73e51e845a78aa522a2f2bda, type: 2}
ToState: {fileID: 11400000, guid: 0e91b8fa2c44dc346b693ecfce70a7f1, type: 2}
Conditions:

- ExpectedResult: 0
Condition: {fileID: 11400000, guid: f4c89ffbe6ca8fe46ae22ec9d191671a, type: 2}
Operator: 0
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: 4f15fe7b4afb565469f360b403d50f64, type: 2}
Operator: 0
- FromState: {fileID: 11400000, guid: 3388e91c73e51e845a78aa522a2f2bda, type: 2}
ToState: {fileID: 11400000, guid: 1aad0cd7a387c6544a113d9fa8df1ce3, type: 2}
Conditions:

- ExpectedResult: 0
Condition: {fileID: 11400000, guid: 5ef92fc56785ca244a1415862e4e8e6e, type: 2}
Operator: 1
- ExpectedResult: 1
Condition: {fileID: 11400000, guid: 4f15fe7b4afb565469f360b403d50f64, type: 2}
Operator: 0
Operator: 0
- ExpectedResult: 1
Condition: {fileID: 11400000, guid: d69fc1702147f7640be8b4c4c88cac42, type: 2}
Operator: 1
- ExpectedResult: 1
Condition: {fileID: 11400000, guid: f4c89ffbe6ca8fe46ae22ec9d191671a, type: 2}

2
UOP1_Project/Assets/Scripts/Characters/NPC.cs


{
public NPCState npcState; //This is checked by conditions in the StateMachine
public GameObject[] talkingTo;
public bool hasSaidLine=false;
}

29
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsNPCSayingTheLineSO.cs


private DialogueLineChannelSO _sayLineEvent;
private ActorSO _protagonistActor;
private bool _isNPCSayingTheLine = false;
private NPC _npcScript;
public IsNPCSayingTheLineCondition(DialogueLineChannelSO sayLineEvent, ActorSO protagonistActor)
{

public override void Awake(StateMachine stateMachine)
{
_npcScript = stateMachine.gameObject.GetComponent<NPC>();
}
return _isNPCSayingTheLine;
}

{
_sayLineEvent.OnEventRaised += OnLineSaid;
_sayLineEvent.OnEventRaised += OnLineDisplay;
}
}

{
_sayLineEvent.OnEventRaised -= OnLineSaid;
_sayLineEvent.OnEventRaised -= OnLineDisplay;
private void OnLineSaid(LocalizedString line, ActorSO actor)
private void OnLineDisplay(LocalizedString line, ActorSO actor)
Debug.Log("name of the actor " + actor);
if(actor.ActorName == _protagonistActor.ActorName)
//why is it not possible to do this from here?
//SetTheLineToNotSaidYet();
if (actor.ActorName == _protagonistActor.ActorName)
_isNPCSayingTheLine = false;
_isNPCSayingTheLine = true;
Debug.Log("is it true " + _isNPCSayingTheLine);
}
private void SetTheLineToNotSaidYet()
{
_npcScript.hasSaidLine = false;
}

2
UOP1_Project/Assets/Scripts/Quests/StepController.cs


_winDialogueEvent.OnEventRaised += PlayWinDialogue;
_loseDialogueEvent.OnEventRaised += PlayLoseDialogue;
isInDialogue = true;
gameObject.GetComponent<NPC>().hasSaidLine = false;
}
void EndDialogue()
{

{
_currentDialogue = displayDialogue;
StartDialogue();
}
}

14
UOP1_Project/Assets/ScriptableObjects/StateMachine/NPC/Actions/SetLineSaid.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: f4aac5d3cf204b74eb6305752b714f1f, type: 3}
m_Name: SetLineSaid
m_EditorClassIdentifier:

8
UOP1_Project/Assets/ScriptableObjects/StateMachine/NPC/Actions/SetLineSaid.asset.meta


fileFormatVersion: 2
guid: be8f6701fa4f0db45ad7ae715ac49230
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

14
UOP1_Project/Assets/ScriptableObjects/StateMachine/NPC/Conditions/HasTheLineBeenSaid.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: dd262779da1c69e43856cadf0825800f, type: 3}
m_Name: HasTheLineBeenSaid
m_EditorClassIdentifier:

8
UOP1_Project/Assets/ScriptableObjects/StateMachine/NPC/Conditions/HasTheLineBeenSaid.asset.meta


fileFormatVersion: 2
guid: d69fc1702147f7640be8b4c4c88cac42
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

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


using UnityEngine;
using UnityEngine.AI;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "SetLineSaidToTrue", menuName = "State Machines/Actions/Set Line Said To True SO")]
public class SetLineSaidSO : StateActionSO
{
protected override StateAction CreateAction() => new SetLineSaid();
}
public class SetLineSaid : StateAction
{
private NPC _npcScript;
public override void Awake(StateMachine stateMachine)
{
_npcScript = stateMachine.gameObject.GetComponent<NPC>();
}
public override void OnUpdate()
{
}
public override void OnStateExit()
{
_npcScript.hasSaidLine = true;
}
}

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


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

33
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/HasTheLineBeenSaidSO.cs


using UnityEngine;
using UnityEngine.Localization;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "HasTheLineBeenSaid", menuName = "State Machines/Conditions/Has The Line Been Said")]
public class HasTheLineBeenSaidSO : StateConditionSO<HasTheLineBeenSaidCondition> { }
public class HasTheLineBeenSaidCondition : Condition
{
//Component references
private NPC _npcScript;
public override void Awake(StateMachine stateMachine)
{
_npcScript = stateMachine.GetComponent<NPC>();
}
protected override bool Statement()
{
if (_npcScript.hasSaidLine)
{
return true;
}
else
{
return false;
}
}
}

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


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