2022-12-04 18:42:34 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2022-12-27 15:16:59 +01:00
|
|
|
|
using System.Linq;
|
2022-12-04 18:42:34 +01:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
//[Serializable]
|
2022-12-27 15:16:59 +01:00
|
|
|
|
|
2022-12-04 18:42:34 +01:00
|
|
|
|
//[CreateAssetMenu(fileName = "New Mission", menuName = "Mission/New Mission")]
|
2022-12-27 15:16:59 +01:00
|
|
|
|
public class NpcMissionManager : DialogueManager // ScriptableObject
|
2022-12-04 18:42:34 +01:00
|
|
|
|
{
|
2022-12-27 15:16:59 +01:00
|
|
|
|
[SerializeField]
|
|
|
|
|
public Mission MissionTemplate;
|
|
|
|
|
|
|
|
|
|
/* We user object CLONED TO PREVENT overwritting changes in main object inassets */
|
|
|
|
|
[SerializeField]
|
|
|
|
|
public Mission Mission;
|
|
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
|
public DialogueStepModel FreeDialogue;
|
|
|
|
|
|
|
|
|
|
// List<Key<mission No, mission step No>, Value : UnityEvent>
|
|
|
|
|
public List<IndexValuePair<IndexValuePair<int, int>, MissionProcess>> EndactionEventList;
|
2022-12-04 18:42:34 +01:00
|
|
|
|
|
2022-12-27 15:16:59 +01:00
|
|
|
|
|
|
|
|
|
public void Start()
|
2022-12-04 18:42:34 +01:00
|
|
|
|
{
|
2022-12-27 15:16:59 +01:00
|
|
|
|
Mission = Instantiate(MissionTemplate);
|
|
|
|
|
Mission.SetSpeakerName(gameObject.GetComponent<NPC>().Name);
|
|
|
|
|
//Mission.BuildMission();
|
|
|
|
|
|
|
|
|
|
if (FreeDialogue != null)
|
|
|
|
|
FreeDialogue.Build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update() { }
|
|
|
|
|
|
|
|
|
|
public override void OnTriggerEnter2D(Collider2D collision)
|
|
|
|
|
{
|
|
|
|
|
// don't listen when component is disabled
|
|
|
|
|
if (ComponentEnabledCondition())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (collision.gameObject.tag == "Player" && !GetCurrentDialoguePanelStatus())
|
2022-12-04 18:42:34 +01:00
|
|
|
|
{
|
2022-12-27 15:16:59 +01:00
|
|
|
|
CanBeOpened = true;
|
|
|
|
|
|
|
|
|
|
SpeakerName = collision.gameObject.name;
|
|
|
|
|
|
|
|
|
|
Mission.StartDialogue();
|
2022-12-04 18:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 15:16:59 +01:00
|
|
|
|
public override void OnTriggerExit2D(Collider2D collision)
|
2022-12-04 18:42:34 +01:00
|
|
|
|
{
|
2022-12-27 15:16:59 +01:00
|
|
|
|
// don't listen when component is disabled
|
|
|
|
|
if (ComponentEnabledCondition())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (collision.gameObject.tag == "Player")
|
2022-12-04 18:42:34 +01:00
|
|
|
|
{
|
2022-12-27 15:16:59 +01:00
|
|
|
|
CanBeOpened = false;
|
2022-12-04 18:42:34 +01:00
|
|
|
|
|
2022-12-27 15:16:59 +01:00
|
|
|
|
if (GetCurrentDialoguePanelStatus())
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("BreakDialogueStep");
|
|
|
|
|
Mission.BreakDialogueStep();
|
2022-12-04 18:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-27 15:16:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* public void Talk()
|
|
|
|
|
{
|
|
|
|
|
if (Mission == null || Mission.Status == MissionStatusEnum.Finished)
|
|
|
|
|
{
|
|
|
|
|
// show free dialogue
|
|
|
|
|
//if(FreeDialogue != null)
|
|
|
|
|
//FreeDialogue.DialogueController.
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
// continue mission
|
|
|
|
|
Mission.StartDialogue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
protected override bool ComponentEnabledCondition()
|
|
|
|
|
{
|
|
|
|
|
return !gameObject.GetComponent<NpcMissionManager>().enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool GetCurrentDialoguePanelStatus()
|
|
|
|
|
{
|
|
|
|
|
Debug.Log(Mission
|
|
|
|
|
.GetCurrentStep()
|
|
|
|
|
.DialogueStep.CurrentStep
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Debug.Log(Mission
|
|
|
|
|
.GetCurrentStep()
|
|
|
|
|
.DialogueStep
|
|
|
|
|
.GetCurrentStep()
|
|
|
|
|
.DialogueController
|
|
|
|
|
.CurrentPanel
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return Mission
|
|
|
|
|
.GetCurrentStep()
|
|
|
|
|
.DialogueStep
|
|
|
|
|
.GetCurrentStep() // ?
|
|
|
|
|
.DialogueController
|
|
|
|
|
.CurrentPanel != null;
|
|
|
|
|
}
|
2022-12-04 18:42:34 +01:00
|
|
|
|
}
|