Browse Source

Add <<< and >>> to stage commands

master
lealeelu 8 years ago
parent
commit
1312b78001
  1. 32
      Assets/Fungus/Narrative/Scripts/ConversationManager.cs
  2. 21
      Assets/FungusExamples/Conversation/Conversation.unity

32
Assets/Fungus/Narrative/Scripts/ConversationManager.cs

@ -16,6 +16,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;
@ -104,7 +106,8 @@ namespace Fungus
if (stage != null && currentCharacter != null &&
(currentPortrait != currentCharacter.state.portrait ||
currentPosition != currentCharacter.state.position))
currentPosition != currentCharacter.state.position ||
item.Flip))
{
var portraitOptions = new PortraitOptions(true);
portraitOptions.display = item.Hide ? DisplayType.Hide : DisplayType.Show;
@ -113,6 +116,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)
@ -157,7 +163,7 @@ namespace Fungus
{
//find SimpleScript say strings with portrait options
//You can test regex matches here: http://regexstorm.net/tester
var sayRegex = new Regex(@"((?<sayParams>[\w ""]*):)?(?<text>.*)\r*(\n|$)");
var sayRegex = new Regex(@"((?<sayParams>[\w ""><]*):)?(?<text>.*)\r*(\n|$)");
MatchCollection sayMatches = sayRegex.Matches(conv);
var items = new List<ConversationItem>(sayMatches.Count);
@ -253,6 +259,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;
@ -263,7 +288,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)

21
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.

Loading…
Cancel
Save