From bc19ac92f1a56ac33f70c5dc3fcd5ea14e997077 Mon Sep 17 00:00:00 2001 From: Lynxelia Date: Fri, 12 Dec 2014 22:01:26 -0800 Subject: [PATCH] added system for static portraits --- .../Fungus/Dialog/Editor/CharacterEditor.cs | 2 +- Assets/Fungus/Dialog/Editor/ChooseEditor.cs | 43 +- Assets/Fungus/Dialog/Editor/SayEditor.cs | 47 +- Assets/Fungus/Dialog/Scripts/Character.cs | 3 +- .../Fungus/Dialog/Scripts/Commands/Choose.cs | 66 +-- Assets/Fungus/Dialog/Scripts/Commands/Say.cs | 6 +- Assets/Fungus/Dialog/Scripts/Dialog.cs | 1 - .../FungusScript/Editor/CommandEditor.cs | 14 +- .../JumpingPrax/JumpingPrax.unity | 527 ++++++------------ .../TheFacility/TheFacility.unity | 143 +++-- .../TheHunter/Audio/BearRoar.wav | Bin 0 -> 397116 bytes .../TheHunter/Audio/BearRoar.wav.meta | 12 + .../FungusExamples/TheHunter/TheHunter.unity | 262 ++++++--- Assets/FungusExamples/iTween/iTween.unity | 10 +- 14 files changed, 612 insertions(+), 524 deletions(-) create mode 100644 Assets/FungusExamples/TheHunter/Audio/BearRoar.wav create mode 100644 Assets/FungusExamples/TheHunter/Audio/BearRoar.wav.meta diff --git a/Assets/Fungus/Dialog/Editor/CharacterEditor.cs b/Assets/Fungus/Dialog/Editor/CharacterEditor.cs index e51dde0d..52864289 100644 --- a/Assets/Fungus/Dialog/Editor/CharacterEditor.cs +++ b/Assets/Fungus/Dialog/Editor/CharacterEditor.cs @@ -49,8 +49,8 @@ namespace Fungus EditorGUILayout.PropertyField(nameColorProp, new GUIContent("Name Color", "Color of name text display in the dialog")); EditorGUILayout.PropertyField(sayDialogBoxProp, new GUIContent("Say Dialog", "Say dialog box this character should use")); EditorGUILayout.PropertyField(chooseDialogBoxProp, new GUIContent("Choose Dialog", "Choose dialog box this character should use")); - EditorGUILayout.PropertyField(portraitsProp, new GUIContent("Portraits", "Character image sprites to display in the dialog"),true); EditorGUILayout.PropertyField(soundEffectProp, new GUIContent("Sound Effect", "Sound to play when the character is talking. Overrides the setting in the Dialog.")); + EditorGUILayout.PropertyField(portraitsProp, new GUIContent("Portraits", "Character image sprites to display in the dialog"),true); EditorGUILayout.PropertyField(notesProp, new GUIContent("Notes", "Notes about this story character (personality, attibutes, etc.)")); EditorGUILayout.Separator(); diff --git a/Assets/Fungus/Dialog/Editor/ChooseEditor.cs b/Assets/Fungus/Dialog/Editor/ChooseEditor.cs index 7ea2a051..ce4a94f7 100644 --- a/Assets/Fungus/Dialog/Editor/ChooseEditor.cs +++ b/Assets/Fungus/Dialog/Editor/ChooseEditor.cs @@ -16,6 +16,7 @@ namespace Fungus protected SerializedProperty chooseTextProp; protected SerializedProperty characterProp; protected SerializedProperty chooseDialogProp; + protected SerializedProperty portraitProp; protected SerializedProperty voiceOverClipProp; protected SerializedProperty timeoutDurationProp; @@ -23,6 +24,7 @@ namespace Fungus { chooseTextProp = serializedObject.FindProperty("chooseText"); characterProp = serializedObject.FindProperty("character"); + portraitProp = serializedObject.FindProperty("portrait"); chooseDialogProp = serializedObject.FindProperty("chooseDialog"); voiceOverClipProp = serializedObject.FindProperty("voiceOverClip"); timeoutDurationProp = serializedObject.FindProperty("timeoutDuration"); @@ -31,25 +33,44 @@ namespace Fungus public override void DrawCommandGUI() { serializedObject.Update(); + + Choose t = target as Choose; + bool showPortraits = false; + // Only show portrait selection if... + if (t.character != null && // Character is selected + t.character.portraits.Count > 0 && // Selected Character has at least 1 portrait + t.chooseDialog.characterImage != null) // Selected Say Dialog has a character image + { + showPortraits = true; + } + CommandEditor.ObjectField(characterProp, new GUIContent("Character", "Character to display in dialog"), new GUIContent(""), Character.activeCharacters); - + CommandEditor.ObjectField(chooseDialogProp, new GUIContent("Choose Dialog", "Choose Dialog object to use to display the multiple player choices"), new GUIContent(""), ChooseDialog.activeDialogs); - EditorGUILayout.BeginHorizontal(); + if (showPortraits) + { + CommandEditor.ObjectField(portraitProp, + new GUIContent("Portrait", "Portrait representing speaking character"), + new GUIContent(""), + t.character.portraits); + } + else + { + t.portrait = null; + } EditorGUILayout.PropertyField(chooseTextProp); - EditorGUILayout.EndHorizontal(); - EditorGUILayout.BeginHorizontal(); - + GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton))) { @@ -68,18 +89,14 @@ namespace Fungus EditorGUILayout.PropertyField(timeoutDurationProp, new GUIContent("Timeout Duration", "Time limit for player to make a choice. Set to 0 for no limit.")); - Choose t = target as Choose; - - if (t.character != null && - t.character.profileSprite != null && - t.character.profileSprite.texture != null) + if (showPortraits && t.portrait != null) { - Texture2D characterTexture = t.character.profileSprite.texture; + Texture2D characterTexture = t.portrait.texture; float aspect = (float)characterTexture.width / (float)characterTexture.height; - + Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true)); - + CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor; characterEditor.DrawPreview(previewRect, characterTexture); DestroyImmediate(characterEditor); diff --git a/Assets/Fungus/Dialog/Editor/SayEditor.cs b/Assets/Fungus/Dialog/Editor/SayEditor.cs index 0cc2fd16..90301dfa 100644 --- a/Assets/Fungus/Dialog/Editor/SayEditor.cs +++ b/Assets/Fungus/Dialog/Editor/SayEditor.cs @@ -31,19 +31,21 @@ namespace Fungus float pixelHeight = EditorStyles.miniLabel.CalcHeight(new GUIContent(tagsText), EditorGUIUtility.currentViewWidth); EditorGUILayout.SelectableLabel(tagsText, EditorStyles.miniLabel, GUILayout.MinHeight(pixelHeight)); } - - protected SerializedProperty storyTextProp; + protected SerializedProperty characterProp; protected SerializedProperty sayDialogProp; + protected SerializedProperty portraitProp; + protected SerializedProperty storyTextProp; protected SerializedProperty voiceOverClipProp; protected SerializedProperty showAlwaysProp; protected SerializedProperty showCountProp; protected virtual void OnEnable() { - storyTextProp = serializedObject.FindProperty("storyText"); characterProp = serializedObject.FindProperty("character"); sayDialogProp = serializedObject.FindProperty("sayDialog"); + portraitProp = serializedObject.FindProperty("portrait"); + storyTextProp = serializedObject.FindProperty("storyText"); voiceOverClipProp = serializedObject.FindProperty("voiceOverClip"); showAlwaysProp = serializedObject.FindProperty("showAlways"); showCountProp = serializedObject.FindProperty("showCount"); @@ -52,23 +54,42 @@ namespace Fungus public override void DrawCommandGUI() { serializedObject.Update(); - + + Say t = target as Say; + + bool showPortraits = false; + // Only show portrait selection if... + if (t.character != null && // Character is selected + t.character.portraits.Count > 0 && // Selected Character has at least 1 portrait + t.sayDialog.characterImage != null) // Selected Say Dialog has a character image + { + showPortraits = true; + } + CommandEditor.ObjectField(characterProp, new GUIContent("Character", "Character to display in dialog"), new GUIContent(""), Character.activeCharacters); - + CommandEditor.ObjectField(sayDialogProp, new GUIContent("Say Dialog", "Say Dialog object to use to display the story text"), new GUIContent(""), SayDialog.activeDialogs); - - EditorGUILayout.BeginHorizontal(); + + if (showPortraits) + { + CommandEditor.ObjectField(portraitProp, + new GUIContent("Portrait", "Portrait representing speaking character"), + new GUIContent(""), + t.character.portraits); + } + else + { + t.portrait = null; + } EditorGUILayout.PropertyField(storyTextProp); - EditorGUILayout.EndHorizontal(); - EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); @@ -96,13 +117,9 @@ namespace Fungus EditorGUILayout.PropertyField(showCountProp); } - Say t = target as Say; - - if (t.character != null && - t.character.profileSprite != null && - t.character.profileSprite.texture != null) + if (showPortraits && t.portrait != null) { - Texture2D characterTexture = t.character.profileSprite.texture; + Texture2D characterTexture = t.portrait.texture; float aspect = (float)characterTexture.width / (float)characterTexture.height; diff --git a/Assets/Fungus/Dialog/Scripts/Character.cs b/Assets/Fungus/Dialog/Scripts/Character.cs index 932b337e..d5f328ad 100644 --- a/Assets/Fungus/Dialog/Scripts/Character.cs +++ b/Assets/Fungus/Dialog/Scripts/Character.cs @@ -14,8 +14,7 @@ namespace Fungus public ChooseDialog chooseDialogBox; public AudioClip soundEffect; public Sprite profileSprite; - public List portraits; - + public List portraits; [TextArea(5,10)] public string notes; diff --git a/Assets/Fungus/Dialog/Scripts/Commands/Choose.cs b/Assets/Fungus/Dialog/Scripts/Commands/Choose.cs index 94e187b6..04f02feb 100644 --- a/Assets/Fungus/Dialog/Scripts/Commands/Choose.cs +++ b/Assets/Fungus/Dialog/Scripts/Commands/Choose.cs @@ -18,27 +18,30 @@ namespace Fungus public Sequence targetSequence; public Action action; } - + static public List