Example #1
0
    /// <summary>
    /// Create a new dialog sequence.
    /// </summary>
    /// <param name="sequenceName">The name of the new sequence.</param>
    /// <param name="list">An arbitrary collection of dialogs that will be made part of this sequence.</param>
    /// <returns>The constructed dialog sequence</returns>
    public HybrasylDialogSequence NewDialogSequence(string sequenceName, params object[] list)
    {
        if (string.IsNullOrEmpty(sequenceName))
        {
            GameLog.ScriptingError($"NewDialogSequence: Sequence name (first argument) was null / empty");
            return(null);
        }

        var dialogSequence = new HybrasylDialogSequence(sequenceName);

        foreach (var entry in list)
        {
            if (entry is HybrasylDialog)
            {
                var newdialog = entry as HybrasylDialog;
                dialogSequence.AddDialog(newdialog);
                newdialog.Sequence = dialogSequence.Sequence;
            }
            else if (entry is not null)
            {
                GameLog.ScriptingError($"NewDialogSequence: Unknown argument of type {entry.GetType()} was passed for a dialog - ignored");
            }
            else
            {
                GameLog.ScriptingError($"NewDialogSequence: null argument passed as dialog - ignored");
            }
        }
        return(dialogSequence);
    }
Example #2
0
 /// <summary>
 /// Register a dialog sequence as a "global" sequence, meaning any object in the game can reference and use it.
 /// </summary>
 /// <param name="globalSequence">The dialog sequence to be registered as a global seqeunce.</param>
 public void RegisterGlobalSequence(HybrasylDialogSequence globalSequence)
 {
     if (globalSequence is null || globalSequence.Sequence.Dialogs.Count == 0)
     {
         GameLog.ScriptingError("RegisterGlobalSequence: sequence (first argument) was null, or the sequence contained no dialogs");
     }
     Game.World.RegisterGlobalSequence(globalSequence.Sequence);
 }
Example #3
0
 /// <summary>
 /// Add a dialog option that will start a new sequence when selected by a player.
 /// </summary>
 /// <param name="option">The option text</param>
 /// <param name="sequence">The DialogSequence that wil be started when the option is selected by a player</param>
 public void AddOption(string option, HybrasylDialogSequence sequence) => Options.Add(option, sequence);