Browse Source

Added configuration methods on DialogController

master
chrisgregan 11 years ago
parent
commit
f04387c197
  1. 133
      Assets/Fungus/Dialog/Scripts/DialogController.cs
  2. 2
      Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs
  3. BIN
      Assets/Shuttle/ShuttleGame.unity

133
Assets/Fungus/Dialog/Scripts/DialogController.cs

@ -1,18 +1,143 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;
using System.Collections;
using System.Collections.Generic;
public class DialogController : MonoBehaviour
{
public Button optionButton;
public GridLayoutGroup optionButtonGrid;
public Text storyText;
public Sprite testCharacter;
public Canvas dialogCanvas;
public List<Button> optionButtons = new List<Button>();
public Text nameText;
public Text storyText;
public Image continueImage;
public Image leftImage;
public Image rightImage;
public UnityEvent testEvent;
public enum ImageSide
{
Left,
Right
};
public void SetCharacterImage(Sprite image, ImageSide side)
{
if (leftImage != null)
{
if (image != null &&
side == ImageSide.Left)
{
leftImage.sprite = image;
leftImage.enabled = true;
}
else
{
leftImage.enabled = false;
}
}
if (rightImage != null)
{
rightImage.sprite = null;
if (image != null &&
side == ImageSide.Right)
{
rightImage.sprite = image;
rightImage.enabled = true;
}
else
{
rightImage.sprite = null;
rightImage.enabled = false;
}
}
}
public void SetCharacterName(string name, Color color)
{
if (nameText != null)
{
nameText.text = name;
nameText.color = color;
}
}
public void SetStoryText(string text)
{
if (storyText != null)
{
storyText.text = text;
}
}
public void ShowContinueIcon(bool visible)
{
if (continueImage != null)
{
continueImage.enabled = visible;
}
}
public void ClearOptions()
{
if (optionButtons == null)
{
return;
}
foreach (Button button in optionButtons)
{
button.gameObject.SetActive(false);
}
}
public void AddOption(string text, Action action)
{
if (optionButtons == null)
{
return;
}
foreach (Button button in optionButtons)
{
if (!button.gameObject.activeSelf)
{
button.gameObject.SetActive(true);
Text textComponent = button.GetComponentInChildren<Text>();
if (textComponent != null)
{
textComponent.text = text;
}
// TODO: Connect action
break;
}
}
}
public void Start()
{
SetCharacterImage(testCharacter, ImageSide.Left);
SetCharacterName("Podrick", Color.red);
SetStoryText("Simple story text");
ShowContinueIcon(false);
ClearOptions();
AddOption("Something 1", Callback );
AddOption("Something 2", Callback );
}
void Callback()
{
Debug.Log ("Callback");
}
//public UnityEvent testEvent;
// Write story text over time
// Show character image (with side, fade in?)

2
Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs

@ -77,7 +77,7 @@ namespace Fungus.Script
EditorGUI.BeginChangeCheck();
string name = EditorGUILayout.TextField(new GUIContent("Sequence Name", "Name of sequence displayed in editor window"), sequence.name);
string name = EditorGUILayout.TextField(new GUIContent("Name", "Name of sequence displayed in editor window"), sequence.name);
string desc = EditorGUILayout.TextField(new GUIContent("Description", "Sequence description displayed in editor window"), sequence.description);
EditorGUILayout.Separator();

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save