using System.Collections.Generic;
using UnityEngine;
using System;
using EasyTalk.Nodes.Core;
using EasyTalk.Localization;
namespace EasyTalk.Nodes
{
///
/// Defines the structure for an EasyTalk Dialogue asset.
///
[CreateAssetMenu(fileName = "Dialogue", menuName = "EasyTalk/Dialogue", order = 1)]
[Serializable]
public class Dialogue : ScriptableObject
{
///
/// A string indicating the current version of EasyTalk in use.
///
public static string VERSION = "1.9.0";
///
/// The version number of the dialogue asset.
///
[SerializeField]
private string version = VERSION;
///
/// The original creation time of the dialogue (in yyyy-MM-dd@HH:mm:ss format).
///
[SerializeField]
private string creationTime = null;
///
/// The last edit time of the dialogue (in yyyy-MM-dd@HH:mm:ss format).
///
[SerializeField]
private string editTime = null;
///
/// The List of nodes in the Dialogue.
///
[SerializeReference]
private List nodes = new List();
///
/// The library of translations for the Dialogue.
///
[SerializeField]
private TranslationLibrary translationLibrary;
///
/// The maximum ID used in the dialogue.
///
[SerializeField]
private int maxID = 0;
///
/// Gets or sets the version number of the dialogue.
///
public string Version
{
get { return version; }
set { version = value; }
}
///
/// Gets or sets the time string (yyyy-MM-dd@HH:mm:ss format) at which the dialogue was created.
///
public string CreationTime
{
get { return creationTime; }
set { creationTime = value; }
}
///
/// Gets or sets the time string (yyyy-MM-dd@HH:mm:ss format) at which the dialogue was edited.
///
public string EditTime
{
get { return editTime; }
set { editTime = value; }
}
///
/// Gets or sets the List of nodes in the dialogue.
///
public List Nodes
{
get { return nodes; }
set { nodes = value; }
}
///
/// Gets or sets the maximum ID used in the Dialogue.
///
public int MaxID
{
get { return maxID; }
set { this.maxID = value; }
}
///
/// Gets or sets the translation library to use for the Dialogue.
///
public TranslationLibrary TranslationLibrary
{
get { return translationLibrary; }
set { this.translationLibrary = value; }
}
///
/// Returns the center point for the Dialogue.
///
/// The center location of the Dialogue (the average of all of the node positions).
public Vector2 GetCenter()
{
Vector2 center = Vector2.zero;
foreach(Node node in nodes)
{
center += new Vector2(node.XPosition, node.YPosition);
}
return center / nodes.Count;
}
}
}