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. 28
      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.")] [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 public class Say : FungusCommand
{ {
static public Dialog dialogController; static public Dialog dialog;
public Character character; public Character character;
public string storyText; public string storyText;
@ -30,7 +30,7 @@ namespace Fungus.Script
public override void OnEnter() public override void OnEnter()
{ {
if (dialogController == null) if (dialog == null)
{ {
Continue(); Continue();
return; return;
@ -44,9 +44,9 @@ namespace Fungus.Script
executionCount++; executionCount++;
dialogController.ShowDialog(true); dialog.ShowDialog(true);
dialogController.SetCharacter(character); dialog.SetCharacter(character);
if (options.Count > 0) if (options.Count > 0)
{ {
@ -59,7 +59,7 @@ namespace Fungus.Script
dialogOption.onSelect = delegate { dialogOption.onSelect = delegate {
dialogController.ShowDialog(false); dialog.ShowDialog(false);
if (onSelectSequence == null) if (onSelectSequence == null)
{ {
@ -74,12 +74,12 @@ namespace Fungus.Script
dialogOptions.Add(dialogOption); dialogOptions.Add(dialogOption);
} }
dialogController.Say(storyText, dialogOptions); dialog.Say(storyText, dialogOptions);
} }
else else
{ {
dialogController.Say(storyText, delegate { dialog.Say(storyText, delegate {
dialogController.ShowDialog(false); dialog.ShowDialog(false);
Continue(); Continue();
}); });
} }

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

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

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

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

28
Assets/Fungus/Dialog/Scripts/Dialog.cs

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

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save