浏览代码

Added is NPC saying line condition

/main
Amel Negra 4 年前
当前提交
b4c11041
共有 4 个文件被更改,包括 100 次插入0 次删除
  1. 16
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Townsfolk/Conditions/IsNPCSayingTheLine.asset
  2. 8
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Townsfolk/Conditions/IsNPCSayingTheLine.asset.meta
  3. 65
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsNPCSayingTheLineSO.cs
  4. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsNPCSayingTheLineSO.cs.meta

16
UOP1_Project/Assets/ScriptableObjects/StateMachine/Townsfolk/Conditions/IsNPCSayingTheLine.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: 3825e04f735c90044b181d4320d8e5d9, type: 3}
m_Name: IsNPCSayingTheLine
m_EditorClassIdentifier:
_sayLineEvent: {fileID: 11400000, guid: d987db4881d794f2da0013a89588d890, type: 2}
_protagonistActor: {fileID: 11400000, guid: c7902af5c8e25244f94914ce51e7ea8a, type: 2}

8
UOP1_Project/Assets/ScriptableObjects/StateMachine/Townsfolk/Conditions/IsNPCSayingTheLine.asset.meta


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

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


using UnityEngine;
using UnityEngine.Localization;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "IsNPCSayingTheLine", menuName = "State Machines/Conditions/Is NPC Saying The Line")]
public class IsNPCSayingTheLineSO : StateConditionSO {
[SerializeField] private DialogueLineChannelSO _sayLineEvent = default;
[SerializeField] private ActorSO _protagonistActor;
protected override Condition CreateCondition() => new IsNPCSayingTheLineCondition(_sayLineEvent, _protagonistActor);
}
public class IsNPCSayingTheLineCondition : Condition
{
private DialogueLineChannelSO _sayLineEvent;
private ActorSO _protagonistActor;
private bool _isNPCSayingTheLine = false;
public IsNPCSayingTheLineCondition(DialogueLineChannelSO sayLineEvent, ActorSO protagonistActor)
{
_sayLineEvent = sayLineEvent;
_protagonistActor = protagonistActor;
}
protected override bool Statement()
{
return _isNPCSayingTheLine;
}
public override void OnStateEnter()
{
if (_sayLineEvent != null)
{
_sayLineEvent.OnEventRaised += OnLineSaid;
}
}
public override void OnStateExit()
{
if (_sayLineEvent != null)
{
_sayLineEvent.OnEventRaised -= OnLineSaid;
}
}
private void OnLineSaid(LocalizedString line, ActorSO actor)
{
Debug.Log("name of the actor " + actor);
if(actor.ActorName == _protagonistActor.ActorName)
{
_isNPCSayingTheLine = false;
}
else
{
_isNPCSayingTheLine = true;
}
Debug.Log("is it true " + _isNPCSayingTheLine);
}
}

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


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