Scriptum/Assets/Scripts/REFACTORING/Application/Dialogue/MissionDialogue.cs
2023-01-12 15:22:49 +01:00

118 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
[Serializable]
[CreateAssetMenu(fileName = "New Mission Dialogue", menuName = "Dialogue/New Mission Dialogue")]
public class MissionDialogue : Dialogue
{
[NonSerialized]
private MissionStepModel Parent;
public void BindParent(MissionStepModel parent)
{
Parent = parent;
}
#region Mission API for button actions
/// <summary>
/// Api for mission allowing to bind action to button
/// </summary>
public void AcceptMission()
{
Parent.GetOriginMission().Accept();
Parent.RegisterCondition();
// show next panel if exists
//ShowNextPanel();
// no we allow to decide programers which one use GoToNextSentence or ShowNextPanel
}
/// <summary>
/// Api for mission allowing to bind action to button
/// </summary>
public void RejectMission()
{
Parent.GetOriginMission().Reject();
Parent.Status = MissionStepStatusEnum.Finished;
GetCurrentStep().DialogueController.CloseCurrentPanel();
}
/// <summary>
/// Function to bind checking condition method from associated Mission (parent)
/// to specifi button in dialogue step structure
/// </summary>
public void HandleCondition()
{
Debug.Log("Handle Conditoion");
var result = Parent.HanldeMissionStepCondition();
if (result) GoToNextSentence();
else BreakDialogueStep();
}
public void GiveReward()
{
Debug.Log("Give reward");
Parent.GetOriginMission().GiveReward();
}
public void FinishMission()
{
Parent.GetOriginMission().FinishMission();
}
public void FinishMissionStep()
{
Parent.GetOriginMission().FinishMissionStep();
}
public void FinishMissionStepAndGoToNext()
{
Parent.GetOriginMission().FinishMissionStepAndGoToNext();
}
public void PlayerQuestContentManage(string newMissionIssue)
{
Parent.PlayerQuestContentManage(newMissionIssue);
}
public void PlayerQuestContentManage()
{
Parent.PlayerQuestContentManage();
}
public void CreateQuestOnList()
{
Parent.GetOriginMission().CreateQuestOnList();
}
public void RemoveQuestFromList()
{
Parent.GetOriginMission().RemoveQuestFromList();
}
#endregion
#region Dialogue Status API
public void UpdateDialogueState(MissionDialogueData dialogueData)
{
CurrentStep = dialogueData.CurrentStep;
for (int i = 0; i < dialogueData.DialogueStepModelDataList.Count; i++)
{
DialogueSteps[i].WasDisplayed = dialogueData.DialogueStepModelDataList[i].WasDisplayed;
}
}
#endregion
}