2022-12-04 18:42:34 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
2022-12-20 03:30:37 +01:00
|
|
|
[RequireComponent(typeof(NPC))]
|
2022-12-23 16:02:04 +01:00
|
|
|
public class NpcDialogueManager : DialogueManager
|
2022-12-04 18:42:34 +01:00
|
|
|
{
|
2022-12-23 16:02:04 +01:00
|
|
|
public override void Start()
|
2022-12-20 15:23:09 +01:00
|
|
|
{
|
2022-12-23 16:02:04 +01:00
|
|
|
base.Start();
|
2022-12-20 15:23:09 +01:00
|
|
|
|
2022-12-23 16:02:04 +01:00
|
|
|
CanBeOpened = false;
|
2022-12-20 15:23:09 +01:00
|
|
|
}
|
2022-12-23 16:02:04 +01:00
|
|
|
public override bool OpenPanelCondition()
|
2022-12-20 15:23:09 +01:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Conditions:
|
|
|
|
* - npc bust me in Talking mode
|
2022-12-23 16:02:04 +01:00
|
|
|
* - player is in collision range
|
2022-12-20 15:23:09 +01:00
|
|
|
* - panel assigned to next sentence in dialogue must be closed
|
|
|
|
*/
|
2022-12-23 16:02:04 +01:00
|
|
|
return gameObject.GetComponent<NPC>().State == NPCStateEnum.Talking && base.OpenPanelCondition();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual bool ColliderTypeCondition()
|
|
|
|
{
|
|
|
|
return !gameObject.GetComponent<NpcDialogueManager>().enabled;
|
2022-12-20 15:23:09 +01:00
|
|
|
}
|
2022-12-04 18:42:34 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Function to invoke actions declared in manager on object from scene not onto asset
|
|
|
|
///
|
|
|
|
/// Used in Dialogue ScriptableObject Template
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dialogueIndex"></param>
|
|
|
|
public void DialogueEndAction(int dialogueIndex)
|
|
|
|
{
|
|
|
|
GameObject.FindObjectsOfType<NpcDialogueManager>().Where(obj => obj.name == gameObject.name).First().GetComponent<NpcDialogueManager>().InvokeDialogueEndAction(dialogueIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Function to invoke actions declared in manager (on current object)
|
|
|
|
///
|
|
|
|
/// Use this to invoke actions which we want to occured after specific Dialogue
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dialogueIndex"></param>
|
|
|
|
protected void InvokeDialogueEndAction(int dialogueIndex)
|
|
|
|
{
|
|
|
|
EndactionEventList.Where(el => el.Key.Key == dialogueIndex).ToList().ForEach(el => el.Value.Invoke());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Function to invoke actions declared in manager on object from scene not onto asset
|
|
|
|
///
|
|
|
|
/// Used in Dialogue ScriptableObject Template
|
|
|
|
/// </summary>
|
|
|
|
public void StepEndAction()
|
|
|
|
{
|
|
|
|
GameObject.FindObjectsOfType<NpcDialogueManager>().Where(obj => obj.name == gameObject.name).First().GetComponent<NpcDialogueManager>().InvokeStepEndAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Function to invoke actions declared in manager (on current object)
|
|
|
|
///
|
|
|
|
/// Use this to invoke actions which we want to occured after specific Dialogue Step
|
|
|
|
/// </summary>
|
|
|
|
protected void InvokeStepEndAction()
|
|
|
|
{
|
|
|
|
var dialogueProgress = Dialogue.DialogueStepStatus();
|
|
|
|
|
|
|
|
EndactionEventList.Where(el => el.Key.Key == dialogueProgress.Item1 & el.Key.Value == dialogueProgress.Item2).ToList().ForEach(el => el.Value.Invoke());
|
|
|
|
}
|
|
|
|
}
|