diff --git a/Assets/Fungus/Narrative/Scripts/ConversationManager.cs b/Assets/Fungus/Narrative/Scripts/ConversationManager.cs index 31403c9c..14610e15 100644 --- a/Assets/Fungus/Narrative/Scripts/ConversationManager.cs +++ b/Assets/Fungus/Narrative/Scripts/ConversationManager.cs @@ -18,6 +18,8 @@ namespace Fungus public Sprite Portrait { get; set; } public RectTransform Position { get; set; } public bool Hide { get; set; } + public FacingDirection FacingDirection { get; set; } + public bool Flip { get; set; } } protected Character[] characters; @@ -115,6 +117,9 @@ namespace Fungus portraitOptions.toPosition = currentPosition; portraitOptions.portrait = currentPortrait; + //Flip option - Flip the opposite direction the character is currently facing + if (item.Flip) portraitOptions.facing = item.FacingDirection; + // Do a move tween if the character is already on screen and not yet at the specified position if (currentCharacter.State.onScreen && currentPosition != currentCharacter.State.position) @@ -159,7 +164,7 @@ namespace Fungus { //find SimpleScript say strings with portrait options //You can test regex matches here: http://regexstorm.net/tester - var sayRegex = new Regex(@"((?[\w ""]*):)?(?.*)\r*(\n|$)"); + var sayRegex = new Regex(@"((?[\w ""><]*):)?(?.*)\r*(\n|$)"); MatchCollection sayMatches = sayRegex.Matches(conv); var items = new List(sayMatches.Count); @@ -255,6 +260,25 @@ namespace Fungus } } } + + int flipIndex = -1; + if (item.Character != null) + { + for (int i = 0; i < sayParams.Length; i++) + { + if (i != characterIndex && + i != hideIndex && + (string.Compare(sayParams[i], ">>>", true) == 0 + || string.Compare(sayParams[i], "<<<", true) == 0)) + { + if (string.Compare(sayParams[i], ">>>", true) == 0) item.FacingDirection = FacingDirection.Right; + if (string.Compare(sayParams[i], "<<<", true) == 0) item.FacingDirection = FacingDirection.Left; + flipIndex = i; + item.Flip = true; + break; + } + } + } // Next see if we can find a portrait for this character int portraitIndex = -1; @@ -265,7 +289,8 @@ namespace Fungus if (item.Portrait == null && item.Character != null && i != characterIndex && - i != hideIndex) + i != hideIndex && + i != flipIndex) { Sprite s = item.Character.GetPortrait(sayParams[i]); if (s != null) @@ -348,4 +373,4 @@ namespace Fungus return results.ToArray(); } } -} \ No newline at end of file +} diff --git a/Assets/FungusExamples/Conversation/Conversation.unity b/Assets/FungusExamples/Conversation/Conversation.unity index 71e3d7be..0ed4bd52 100644 --- a/Assets/FungusExamples/Conversation/Conversation.unity +++ b/Assets/FungusExamples/Conversation/Conversation.unity @@ -13,7 +13,7 @@ SceneSettings: --- !u!104 &2 RenderSettings: m_ObjectHideFlags: 0 - serializedVersion: 6 + serializedVersion: 7 m_Fog: 0 m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_FogMode: 3 @@ -37,12 +37,12 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 - serializedVersion: 6 + serializedVersion: 7 m_GIWorkflowMode: 1 - m_LightmapsMode: 1 m_GISettings: serializedVersion: 2 m_BounceScale: 1 @@ -53,17 +53,22 @@ LightmapSettings: m_EnableBakedLightmaps: 0 m_EnableRealtimeLightmaps: 0 m_LightmapEditorSettings: - serializedVersion: 3 + serializedVersion: 4 m_Resolution: 2 m_BakeResolution: 40 m_TextureWidth: 1024 m_TextureHeight: 1024 + m_AO: 0 m_AOMaxDistance: 1 - m_Padding: 2 m_CompAOExponent: 0 + m_CompAOExponentDirect: 0 + m_Padding: 2 m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 m_TextureCompression: 1 + m_DirectLightInLightProbes: 1 m_FinalGather: 0 + m_FinalGatherFiltering: 1 m_FinalGatherRayCount: 1024 m_ReflectionCompression: 2 m_LightingDataAsset: {fileID: 0} @@ -843,7 +848,7 @@ MonoBehaviour: portraits: - {fileID: 21300000, guid: b9482ea03e69b5a4aa5e7827da354549, type: 3} - {fileID: 21300000, guid: 7497fd82318972540af8666a234a9685, type: 3} - portraitsFace: 2 + portraitsFace: 1 setSayDialog: {fileID: 0} description: --- !u!4 &1745642869 @@ -941,6 +946,8 @@ MonoBehaviour: You catch on quickly don''t you? + sherlock >>>: + hide john "offscreen left": I sure do. @@ -1030,7 +1037,7 @@ MonoBehaviour: conversation [[ - sherlock excited: AHA! So that''s how you do a conversation from Lua! + sherlock excited <<<: AHA! So that''s how you do a conversation from Lua! Fascinating.