From 5e37a6fe0f33bda5a5b5bb4f05a60c44a2ae5609 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 6 Aug 2014 13:08:03 +0100 Subject: [PATCH] Added ShowConditions to Say command --- .../Editor/FungusScript/AddOptionEditor.cs | 1 - .../Fungus/Editor/FungusScript/SayEditor.cs | 20 ++++++- Assets/Fungus/VisualScripting/AddOption.cs | 1 - Assets/Fungus/VisualScripting/Say.cs | 56 +++++++++++++++++- Assets/Shuttle/ShuttleGame.unity | Bin 78500 -> 79300 bytes 5 files changed, 74 insertions(+), 4 deletions(-) diff --git a/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs b/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs index 00c3ff00..a2107d43 100644 --- a/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs @@ -16,7 +16,6 @@ namespace Fungus.Script EditorGUI.BeginChangeCheck(); - string optionText = EditorGUILayout.TextField(new GUIContent("Option Text", "Text for option button label"), t.optionText); Sequence targetSequence = SequenceEditor.SequenceField(new GUIContent("Target Sequence", "Sequence to execute when option is selected"), t.GetFungusScript(), t.targetSequence); AddOption.ShowCondition showCondition = (AddOption.ShowCondition)EditorGUILayout.EnumPopup(new GUIContent("Show Condition", "Condition when this option should be visible."), t.showCondition); diff --git a/Assets/Fungus/Editor/FungusScript/SayEditor.cs b/Assets/Fungus/Editor/FungusScript/SayEditor.cs index 23fcfd27..44510692 100644 --- a/Assets/Fungus/Editor/FungusScript/SayEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/SayEditor.cs @@ -22,12 +22,30 @@ namespace Fungus.Script EditorStyles.textField.wordWrap = true; string text = EditorGUILayout.TextArea(t.text, GUILayout.MinHeight(50)); + Say.ShowCondition showCondition = (Say.ShowCondition)EditorGUILayout.EnumPopup(new GUIContent("Show Condition", "Condition when this say text should be visible."), t.showCondition); + + string booleanVariableKey = t.booleanVariableKey; + + if (showCondition == Say.ShowCondition.BooleanIsFalse || + showCondition == Say.ShowCondition.BooleanIsTrue) + { + VariableType type = VariableType.Boolean; + booleanVariableKey = SequenceEditor.VariableField (new GUIContent ("Boolean Variable", "Boolean variable to test for condition"), + t.GetFungusScript (), + t.booleanVariableKey, + ref type, + v => { return v.type == VariableType.Boolean; }); + } + if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(t, "Set Say"); t.character = character; t.text = text; - } + t.showCondition = showCondition; + t.booleanVariableKey = booleanVariableKey; + } + } } diff --git a/Assets/Fungus/VisualScripting/AddOption.cs b/Assets/Fungus/VisualScripting/AddOption.cs index c3bbf5df..260a3498 100644 --- a/Assets/Fungus/VisualScripting/AddOption.cs +++ b/Assets/Fungus/VisualScripting/AddOption.cs @@ -23,7 +23,6 @@ namespace Fungus.Script public override void OnEnter() { Dialog dialog = Game.GetInstance().dialog; - bool showOption = (dialog != null && targetSequence != null); if (showCondition == ShowCondition.Always) diff --git a/Assets/Fungus/VisualScripting/Say.cs b/Assets/Fungus/VisualScripting/Say.cs index f4851d42..cab79c29 100644 --- a/Assets/Fungus/VisualScripting/Say.cs +++ b/Assets/Fungus/VisualScripting/Say.cs @@ -7,8 +7,20 @@ namespace Fungus.Script { public class Say : FungusCommand { + public enum ShowCondition + { + Always, + Once, + BooleanIsTrue, + BooleanIsFalse + } + public string character; public string text; + public ShowCondition showCondition; + public string booleanVariableKey; + + int executionCount; public override void OnEnter() { @@ -18,6 +30,49 @@ namespace Fungus.Script Continue(); return; } + + bool showSayText = true; + + if (showCondition == ShowCondition.Always) + { + // Always show option + } + else if (showCondition == ShowCondition.Once) + { + if (executionCount > 0) + { + showSayText = false; + } + } + else + { + Variable v = parentFungusScript.GetVariable(booleanVariableKey); + if (v == null) + { + showSayText = false; + } + else + { + if (showCondition == ShowCondition.BooleanIsTrue && + v.booleanValue != true) + { + showSayText = false; + } + else if (showCondition == ShowCondition.BooleanIsFalse && + v.booleanValue != false) + { + showSayText = false; + } + } + } + + if (!showSayText) + { + Continue(); + return; + } + + executionCount++; if (character.Length > 0) { @@ -28,7 +83,6 @@ namespace Fungus.Script Continue(); }); } - } } \ No newline at end of file diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 494ca919ae8d80e69d93cb90ff8a5dae0049b538..1260f6c14c393b2dfe46eff2c38b7386fb57093f 100644 GIT binary patch delta 2109 zcmZwIUrbw790%~<56Y<837W3p>}a7(z|DxtmiuPi*n|n80ug3r(qFcUR<*aIee=%OYh{s}4*h(0u1fv)>gzX$HYdlyL#-1F)0 z+~4p1&bj5&8iy>xjg~o z^}|>npTlNg&6r#C@deC{x{Nu#gbl(55re#uwZ!AV{D+CEf%o-dhSD95R@ewkCQ)Gt z*bJ;uAH%TAj}X0&`5k@j2+V6Es)D6;I|B>DM1i+;)6$U+M;zFO%2PUyB2d{v6h`2x zZf9W=Fyqr5&omWV9YiM)Cky-lHVSjYUe(75*k#>BXT=zV%?gWPa!4O1fhnK}unt{LS~R`{J-S5F-aMmb}^UNv-t>%(IA=vWX(%*GH@8 zYxAEp-|#f78)kgsk6|+~KW>P|tZm(L-NE{DC($HK7PA7IgBjPZ!jx_1El$-PjMPVg zJ}kbc-|#j9<1kV6if(CGWs&(H-GPn5qKK0R_%5u_wO-(|zV;q03=`Wa<1(-W>>Q#0 z5=)j9U(9Xpf(Mp>iN&(5rLbV}`WqqJ>IpadW?=!u$u5+_yd^{*!ercbSR6JEONs)K zpI+R3qA}_*x6lhyO3hFF5^M}+?93h*Z8vveuecw~k9*55RKw;Th}#c~_@5$*Ay9Uq z2AF_V!{n=23scI>`*{EsgBiE(_u_@u=U|^*G{)qzCXK+6BS4_NN?FV9q!_N{~4c58nJr<2TM|9kf_${FId2^Dt zVSboMBDX07n}vykc~eh(1m=6eY)4@;Fyn(1&rcr9uUbFoyX8KW0K0+BxS>TK9@q@b zk2!Lzz3=<;E)A6Lni{|Lnq`VpExD>M6IB!Um0_;Z@(b8@NnwRYCfKI+F%O7~=_D@f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