浏览代码

[Bugfix] New condition prevents Critter from attacking when dialogue on (#420)

* New condition prevents Critter from attacking when dialogue on

* Remove test temp clutter

* Undo changes to testing ground
/main
GitHub 3 年前
当前提交
0e084a6f
共有 5 个文件被更改,包括 109 次插入0 次删除
  1. 6
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_TransitionTable.asset
  2. 17
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/Conditions/IsDialogueActiveCondition.asset
  3. 8
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/Conditions/IsDialogueActiveCondition.asset.meta
  4. 67
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsDialogueActiveConditionSO.cs
  5. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsDialogueActiveConditionSO.cs.meta

6
UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_TransitionTable.asset


- ExpectedResult: 0
Condition: {fileID: 11400000, guid: 27c06ead5f7a1ed4d89197fe9a61d0c2, type: 2}
Operator: 0
- ExpectedResult: 1
Condition: {fileID: 11400000, guid: 050fbbaa48ac74961952b20dabfd6e88, type: 2}
Operator: 0
- FromState: {fileID: 11400000, guid: ea7a8e48b1a87c241bb721da98d1d812, type: 2}
ToState: {fileID: 11400000, guid: 5b0e38103a74c054cb968153b3227b71, type: 2}
Conditions:

Conditions:
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: 27c06ead5f7a1ed4d89197fe9a61d0c2, type: 2}
Operator: 0
- ExpectedResult: 1
Condition: {fileID: 11400000, guid: 050fbbaa48ac74961952b20dabfd6e88, type: 2}
Operator: 0
- FromState: {fileID: 11400000, guid: 658f06f54a3654c498a26d9714beaff0, type: 2}
ToState: {fileID: 11400000, guid: 05826b0374eccc245b9b1da390ab7d04, type: 2}

17
UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/Conditions/IsDialogueActiveCondition.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: 5be74e14d569340ea88bda4cb6de35da, type: 3}
m_Name: IsDialogueActiveCondition
m_EditorClassIdentifier:
_startDialogueEvent: {fileID: 11400000, guid: 5cfe626f5482b914a9e46ebbe35ea1a8,
type: 2}
_endDialogueEvent: {fileID: 11400000, guid: b8f14d59bc3b10e4f9bdf1e65c3c6280, type: 2}

8
UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/Conditions/IsDialogueActiveCondition.asset.meta


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

67
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsDialogueActiveConditionSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "IsDialogueActiveCondition", menuName = "State Machines/Conditions/Is Dialogue Active Condition")]
public class IsDialogueActiveConditionSO : StateConditionSO
{
[SerializeField] private DialogueDataChannelSO _startDialogueEvent = default;
[SerializeField] private DialogueDataChannelSO _endDialogueEvent = default;
protected override Condition CreateCondition() => new IsDialogueActiveCondition(_startDialogueEvent, _endDialogueEvent);
}
public class IsDialogueActiveCondition : Condition
{
private DialogueDataChannelSO _startDialogueEvent;
private DialogueDataChannelSO _endDialogueEvent;
private bool _isDialogueActive = false;
public IsDialogueActiveCondition(DialogueDataChannelSO startDialogueEvent, DialogueDataChannelSO endDialogueEvent)
{
_startDialogueEvent = startDialogueEvent;
_endDialogueEvent = endDialogueEvent;
}
protected override bool Statement()
{
return _isDialogueActive;
}
public override void OnStateEnter()
{
if (_startDialogueEvent != null)
{
_startDialogueEvent.OnEventRaised += OnDialogueStart;
}
if (_endDialogueEvent != null)
{
_endDialogueEvent.OnEventRaised += OnDialogueEnd;
}
}
public override void OnStateExit()
{
if (_startDialogueEvent != null)
{
_startDialogueEvent.OnEventRaised -= OnDialogueStart;
}
if (_endDialogueEvent != null)
{
_endDialogueEvent.OnEventRaised -= OnDialogueEnd;
}
}
private void OnDialogueStart(DialogueDataSO dialogue)
{
_isDialogueActive = true;
}
private void OnDialogueEnd(DialogueDataSO dialogue)
{
_isDialogueActive = false;
}
}

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


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