Browse Source

Fixed dialog layout. Initial coroutine say command.

master
chrisgregan 10 years ago
parent
commit
61db98ac83
  1. 16
      Assets/Fungus/Dialog/Commands/Say.cs
  2. 2
      Assets/Fungus/Dialog/Commands/SetDialog.cs
  3. 1
      Assets/Fungus/Dialog/Editor/CharacterEditor.cs
  4. 24
      Assets/Fungus/Dialog/Scripts/Dialog.cs
  5. BIN
      Assets/Shuttle/ShuttleGame.unity

16
Assets/Fungus/Dialog/Commands/Say.cs

@ -9,7 +9,7 @@ namespace Fungus.Script
[HelpText("Writes a line of story text to the dialog. A list of options can be specified for the player to choose from. Use a non-zero timeout to give the player a limited time to choose.")]
public class Say : FungusCommand
{
static public Dialog dialogController;
static public Dialog dialog;
public Character character;
public string storyText;
@ -30,7 +30,7 @@ namespace Fungus.Script
public override void OnEnter()
{
if (dialogController == null)
if (dialog == null)
{
Continue();
return;
@ -44,9 +44,9 @@ namespace Fungus.Script
executionCount++;
dialogController.ShowDialog(true);
dialog.ShowDialog(true);
dialogController.SetCharacter(character);
dialog.SetCharacter(character);
if (options.Count > 0)
{
@ -59,7 +59,7 @@ namespace Fungus.Script
dialogOption.onSelect = delegate {
dialogController.ShowDialog(false);
dialog.ShowDialog(false);
if (onSelectSequence == null)
{
@ -74,12 +74,12 @@ namespace Fungus.Script
dialogOptions.Add(dialogOption);
}
dialogController.Say(storyText, dialogOptions);
dialog.Say(storyText, dialogOptions);
}
else
{
dialogController.Say(storyText, delegate {
dialogController.ShowDialog(false);
dialog.Say(storyText, delegate {
dialog.ShowDialog(false);
Continue();
});
}

2
Assets/Fungus/Dialog/Commands/SetDialog.cs

@ -16,7 +16,7 @@ namespace Fungus.Script
{
if (dialogController != null)
{
Say.dialogController = dialogController;
Say.dialog = dialogController;
}
Continue();

1
Assets/Fungus/Dialog/Editor/CharacterEditor.cs

@ -16,6 +16,7 @@ namespace Fungus.Script
if (shader != null)
{
spriteMaterial = new Material(shader);
spriteMaterial.hideFlags = HideFlags.DontSave;
}
}

24
Assets/Fungus/Dialog/Scripts/Dialog.cs

@ -107,27 +107,39 @@ namespace Fungus.Script
storyText.text = text;
}
// TODO: Wait for text to finish writing
StartCoroutine(WriteText(text, delegate {
ShowContinueIcon(true);
StartCoroutine(WaitForInput(onComplete));
}));
}
public void Say(string text, List<Option> options)
{
Clear();
ShowContinueIcon(false);
StartCoroutine(WriteText(text, delegate {
foreach (Option option in options)
{
AddOption(option.text, option.onSelect);
}
}));
}
IEnumerator WriteText(string text, Action onWritingComplete)
{
if (storyText != null)
{
storyText.text = text;
}
ShowContinueIcon(false);
foreach (Option option in options)
if (onWritingComplete != null)
{
AddOption(option.text, option.onSelect);
onWritingComplete();
}
yield break;
}
IEnumerator WaitForInput(Action onComplete)

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save