2025-06-06 10:14:55 -04:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Ichni.Story
|
|
|
|
|
{
|
|
|
|
|
public class DialogSentence
|
|
|
|
|
{
|
|
|
|
|
public string content;
|
|
|
|
|
public string audioEventName;
|
|
|
|
|
|
|
|
|
|
public string characterName;
|
|
|
|
|
|
|
|
|
|
public DialogSentence()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-13 14:59:58 -04:00
|
|
|
public DialogSentence(string content, string audioEventName, string characterName)
|
2025-06-06 10:14:55 -04:00
|
|
|
{
|
|
|
|
|
this.content = content;
|
|
|
|
|
this.audioEventName = audioEventName;
|
|
|
|
|
this.characterName = characterName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 匹配{@FUNCTION},解析函数并返回解析后的语句内容。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string GetInterpretedContent()
|
|
|
|
|
{
|
|
|
|
|
List<string> parts = new List<string>();
|
|
|
|
|
Regex regex = new Regex(@"\{\@.*?\}");
|
|
|
|
|
int lastIndex = 0;
|
|
|
|
|
|
|
|
|
|
foreach (Match match in regex.Matches(content))
|
|
|
|
|
{
|
|
|
|
|
if (match.Index > lastIndex)
|
|
|
|
|
{
|
|
|
|
|
parts.Add(content.Substring(lastIndex, match.Index - lastIndex));
|
|
|
|
|
}
|
|
|
|
|
parts.Add(match.Value);
|
|
|
|
|
lastIndex = match.Index + match.Length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lastIndex < content.Length)
|
|
|
|
|
{
|
|
|
|
|
parts.Add(content.Substring(lastIndex));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < parts.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (parts[i].StartsWith("{@") && parts[i].EndsWith("}"))
|
|
|
|
|
{
|
|
|
|
|
string expression = parts[i].Substring(2, parts[i].Length - 3);
|
|
|
|
|
object result = StoryInterpreters.FunctionInterpreter.Eval(expression);
|
|
|
|
|
parts[i] = result.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Join("", parts);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-13 14:59:58 -04:00
|
|
|
|
|
|
|
|
public class ChoiceGroup
|
|
|
|
|
{
|
|
|
|
|
public string choiceName;
|
|
|
|
|
public List<Choice> choices;
|
|
|
|
|
|
|
|
|
|
public ChoiceGroup(string choiceName)
|
|
|
|
|
{
|
|
|
|
|
this.choiceName = choiceName;
|
|
|
|
|
this.choices = new List<Choice>();
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-06 10:14:55 -04:00
|
|
|
|
|
|
|
|
public class Choice
|
|
|
|
|
{
|
|
|
|
|
public string choiceText;
|
|
|
|
|
public string nextDialogName;
|
2025-06-13 14:59:58 -04:00
|
|
|
|
|
|
|
|
public Choice(string choiceText, string nextDialogName)
|
|
|
|
|
{
|
|
|
|
|
this.choiceText = choiceText;
|
|
|
|
|
this.nextDialogName = nextDialogName;
|
|
|
|
|
}
|
2025-06-06 10:14:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Condition
|
|
|
|
|
{
|
|
|
|
|
public string conditionSentence;
|
|
|
|
|
public string nextDialogName;
|
|
|
|
|
|
|
|
|
|
public bool GetConditionResult()
|
|
|
|
|
{
|
|
|
|
|
bool result = StoryInterpreters.ConditionInterpreter.Eval<bool>(conditionSentence);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DialogCharacter
|
|
|
|
|
{
|
|
|
|
|
public string name;
|
|
|
|
|
public string title;
|
|
|
|
|
public Dictionary<string, Sprite> emotions;
|
|
|
|
|
}
|
|
|
|
|
}
|