Browse Source

Added per-character typing sound effect. Added continue click cool down timer.

master
chrisgregan 10 years ago
parent
commit
f442561d38
  1. 40
      Assets/Examples/TheHunter/TheHunter.unity
  2. 6
      Assets/Fungus/Dialog/Editor/CharacterEditor.cs
  3. 1
      Assets/Fungus/Dialog/Scripts/Character.cs
  4. 32
      Assets/Fungus/Dialog/Scripts/Dialog.cs

40
Assets/Examples/TheHunter/TheHunter.unity

@ -506,6 +506,14 @@ Prefab:
propertyPath: nameColor.b
value: .949019611
objectReference: {fileID: 0}
- target: {fileID: 11400000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
propertyPath: typingSound
value:
objectReference: {fileID: 8300000, guid: 0dc7e509ace954462bc8ab20fcb68d60, type: 3}
- target: {fileID: 11400000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
propertyPath: soundEffect
value:
objectReference: {fileID: 8300000, guid: 0dc7e509ace954462bc8ab20fcb68d60, type: 3}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
m_RootGameObject: {fileID: 339869592}
@ -575,6 +583,14 @@ Prefab:
propertyPath: nameColor.b
value: .168685108
objectReference: {fileID: 0}
- target: {fileID: 11400000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
propertyPath: typingSound
value:
objectReference: {fileID: 8300000, guid: 9b3be2062b59848a2bd178f5748b386d, type: 3}
- target: {fileID: 11400000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
propertyPath: soundEffect
value:
objectReference: {fileID: 8300000, guid: 9b3be2062b59848a2bd178f5748b386d, type: 3}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
m_RootGameObject: {fileID: 686889651}
@ -845,6 +861,14 @@ Prefab:
propertyPath: nameColor.b
value: .349019617
objectReference: {fileID: 0}
- target: {fileID: 11400000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
propertyPath: typingSound
value:
objectReference: {fileID: 8300000, guid: 23e52ab29f28743309c85b6d7bdc8ad6, type: 3}
- target: {fileID: 11400000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
propertyPath: soundEffect
value:
objectReference: {fileID: 8300000, guid: 23e52ab29f28743309c85b6d7bdc8ad6, type: 3}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
m_RootGameObject: {fileID: 338947446}
@ -914,6 +938,14 @@ Prefab:
propertyPath: nameColor.b
value: .196078435
objectReference: {fileID: 0}
- target: {fileID: 11400000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
propertyPath: typingSound
value:
objectReference: {fileID: 8300000, guid: 124184555ec434aa68814be3bd116c26, type: 3}
- target: {fileID: 11400000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
propertyPath: soundEffect
value:
objectReference: {fileID: 8300000, guid: 124184555ec434aa68814be3bd116c26, type: 3}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: b20518d45890e4be59ba82946f88026c, type: 2}
m_RootGameObject: {fileID: 1712414753}
@ -1086,7 +1118,7 @@ MonoBehaviour:
nameText: Shay
nameColor: {r: .933333337, g: .772549033, b: .349019617, a: 1}
profileSprite: {fileID: 21300000, guid: f7484a661774243b193bebc6e3ae5120, type: 3}
typingSound: {fileID: 0}
soundEffect: {fileID: 8300000, guid: 23e52ab29f28743309c85b6d7bdc8ad6, type: 3}
notes:
--- !u!1 &339869592
GameObject:
@ -1119,7 +1151,7 @@ MonoBehaviour:
nameText: Skipper
nameColor: {r: .294117659, g: .650980413, b: .949019611, a: 1}
profileSprite: {fileID: 21300000, guid: 3c64e30cbefbe4e768ef68d85c85061e, type: 3}
typingSound: {fileID: 0}
soundEffect: {fileID: 8300000, guid: 0dc7e509ace954462bc8ab20fcb68d60, type: 3}
notes:
--- !u!4 &339869594
Transform:
@ -1999,7 +2031,7 @@ MonoBehaviour:
nameText: Badly Drawn Bear
nameColor: {r: .95588237, g: .347840369, b: .168685108, a: 1}
profileSprite: {fileID: 21300000, guid: 62955e2782fd34c5ca3e78712625ae50, type: 3}
typingSound: {fileID: 0}
soundEffect: {fileID: 8300000, guid: 9b3be2062b59848a2bd178f5748b386d, type: 3}
notes:
--- !u!4 &686889653
Transform:
@ -5018,7 +5050,7 @@ MonoBehaviour:
nameText: Ciara
nameColor: {r: .925490201, g: .482352942, b: .196078435, a: 1}
profileSprite: {fileID: 21300000, guid: 05ccd53483a554ca9b31f685fa76154a, type: 3}
typingSound: {fileID: 0}
soundEffect: {fileID: 8300000, guid: 124184555ec434aa68814be3bd116c26, type: 3}
notes:
--- !u!1001 &1725106525
Prefab:

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

@ -13,6 +13,7 @@ namespace Fungus
protected SerializedProperty nameTextProp;
protected SerializedProperty nameColorProp;
protected SerializedProperty profileSpriteProp;
protected SerializedProperty soundEffectProp;
protected SerializedProperty notesProp;
protected virtual void OnEnable()
@ -20,6 +21,7 @@ namespace Fungus
nameTextProp = serializedObject.FindProperty ("nameText");
nameColorProp = serializedObject.FindProperty ("nameColor");
profileSpriteProp = serializedObject.FindProperty ("profileSprite");
soundEffectProp = serializedObject.FindProperty ("soundEffect");
notesProp = serializedObject.FindProperty ("notes");
Shader shader = Shader.Find("Sprites/Default");
@ -40,11 +42,9 @@ namespace Fungus
serializedObject.Update();
EditorGUILayout.PropertyField(nameTextProp, new GUIContent("Name Text", "Name of the character display in the dialog"));
EditorGUILayout.PropertyField(nameColorProp, new GUIContent("Name Color", "Color of name text display in the dialog"));
EditorGUILayout.PropertyField(profileSpriteProp, new GUIContent("Image", "Character image sprite to display in the dialog"));
EditorGUILayout.PropertyField(soundEffectProp, new GUIContent("Sound Effect", "Sound to play when the character is talking. Overrides the setting in the Dialog."));
EditorGUILayout.PropertyField(notesProp, new GUIContent("Notes", "Notes about this story character (personality, attibutes, etc.)"));
EditorGUILayout.Separator();

1
Assets/Fungus/Dialog/Scripts/Character.cs

@ -11,6 +11,7 @@ namespace Fungus
public string nameText; // We need a separate name as the object name is used for character variations (e.g. "Smurf Happy", "Smurf Sad")
public Color nameColor = Color.white;
public Sprite profileSprite;
public AudioClip soundEffect;
[TextArea(5,10)]
public string notes;

32
Assets/Fungus/Dialog/Scripts/Dialog.cs

@ -23,6 +23,7 @@ namespace Fungus
public Text nameText;
public Text storyText;
public Image characterImage;
public AudioClip characterTypingSound;
protected float currentSpeed;
protected float currentPunctuationPause;
@ -30,6 +31,7 @@ namespace Fungus
protected bool italicActive;
protected bool colorActive;
protected string colorText;
protected float clickCooldownTimer;
protected bool wasPointerClicked;
@ -61,10 +63,18 @@ namespace Fungus
{
wasPointerClicked = false;
if (clickAnywhere &&
if (clickCooldownTimer > 0f)
{
clickCooldownTimer -= Time.deltaTime;
clickCooldownTimer = Mathf.Max(0, clickCooldownTimer);
}
if (clickCooldownTimer == 0f &&
clickAnywhere &&
Input.GetMouseButtonDown(0))
{
wasPointerClicked = true;
clickCooldownTimer = 0.2f;
}
}
@ -84,6 +94,7 @@ namespace Fungus
characterImage.enabled = false;
if (nameText != null)
nameText.text = "";
characterTypingSound = null;
}
else
{
@ -96,8 +107,11 @@ namespace Fungus
characterName = character.name;
}
characterTypingSound = character.soundEffect;
SetCharacterName(characterName, character.nameColor);
}
}
public virtual void SetCharacterImage(Sprite image)
@ -159,7 +173,14 @@ namespace Fungus
{
typingAudio = new GameObject("WritingSound");
typingAudio.AddComponent<AudioSource>();
typingAudio.audio.clip = writingSound;
if (characterTypingSound != null)
{
typingAudio.audio.clip = characterTypingSound;
}
else
{
typingAudio.audio.clip = writingSound;
}
typingAudio.audio.loop = loopWritingSound;
typingAudio.audio.Play();
}
@ -320,6 +341,7 @@ namespace Fungus
typingAudio.audio.Play();
timeAccumulator = 0f;
currentSpeed = writingSpeed;
OnWaitForInputTag(false);
break;
@ -336,6 +358,7 @@ namespace Fungus
OnWaitForInputTag(false);
timeAccumulator = 0f;
currentSpeed = writingSpeed;
storyText.text = "";
break;
@ -589,7 +612,10 @@ namespace Fungus
public virtual void OnPointerClick()
{
wasPointerClicked = true;
if (clickCooldownTimer == 0f)
{
wasPointerClicked = true;
}
}
}

Loading…
Cancel
Save