diff --git a/Assets/Fungus/Scripts/Commands/Break.cs b/Assets/Fungus/Scripts/Commands/Break.cs index 7e586f68..8dacca12 100644 --- a/Assets/Fungus/Scripts/Commands/Break.cs +++ b/Assets/Fungus/Scripts/Commands/Break.cs @@ -14,6 +14,8 @@ namespace Fungus.Commands [AddComponentMenu("")] public class Break : Command { + #region Public members + public override void OnEnter() { // Find index of previous while command @@ -66,6 +68,8 @@ namespace Fungus.Commands public override Color GetButtonColor() { return new Color32(253, 253, 150, 255); - } + } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Call.cs b/Assets/Fungus/Scripts/Commands/Call.cs index 4291c3e9..e4ecce44 100644 --- a/Assets/Fungus/Scripts/Commands/Call.cs +++ b/Assets/Fungus/Scripts/Commands/Call.cs @@ -44,6 +44,8 @@ namespace Fungus.Commands [Tooltip("Select if the calling block should stop or continue executing commands, or wait until the called block finishes.")] [SerializeField] protected CallMode callMode; + #region Public members + public override void OnEnter() { var flowchart = GetFlowchart(); @@ -138,5 +140,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/CallMethod.cs b/Assets/Fungus/Scripts/Commands/CallMethod.cs index 0088c79d..df7dc2a5 100644 --- a/Assets/Fungus/Scripts/Commands/CallMethod.cs +++ b/Assets/Fungus/Scripts/Commands/CallMethod.cs @@ -25,6 +25,13 @@ namespace Fungus.Commands [Tooltip("Delay (in seconds) before the method will be called")] [SerializeField] protected float delay; + protected virtual void CallTheMethod() + { + targetObject.SendMessage(methodName, SendMessageOptions.DontRequireReceiver); + } + + #region Public members + public override void OnEnter() { if (targetObject == null || @@ -46,11 +53,6 @@ namespace Fungus.Commands Continue(); } - protected virtual void CallTheMethod() - { - targetObject.SendMessage(methodName, SendMessageOptions.DontRequireReceiver); - } - public override string GetSummary() { if (targetObject == null) @@ -70,5 +72,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/ClearMenu.cs b/Assets/Fungus/Scripts/Commands/ClearMenu.cs index c2f9a8e3..85398aab 100644 --- a/Assets/Fungus/Scripts/Commands/ClearMenu.cs +++ b/Assets/Fungus/Scripts/Commands/ClearMenu.cs @@ -16,6 +16,8 @@ namespace Fungus.Commands [Tooltip("Menu Dialog to clear the options on")] [SerializeField] protected MenuDialog menuDialog; + #region Public members + public override void OnEnter() { menuDialog.Clear(); @@ -37,5 +39,7 @@ namespace Fungus.Commands { return new Color32(184, 210, 235, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Comment.cs b/Assets/Fungus/Scripts/Commands/Comment.cs index a217c074..5bc1ef60 100644 --- a/Assets/Fungus/Scripts/Commands/Comment.cs +++ b/Assets/Fungus/Scripts/Commands/Comment.cs @@ -21,6 +21,8 @@ namespace Fungus.Commands [TextArea(2,4)] [SerializeField] protected string commentText = ""; + #region Public members + public override void OnEnter() { Continue(); @@ -39,5 +41,7 @@ namespace Fungus.Commands { return new Color32(220, 220, 220, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Condition.cs b/Assets/Fungus/Scripts/Commands/Condition.cs index d1e10336..4ce14f6e 100644 --- a/Assets/Fungus/Scripts/Commands/Condition.cs +++ b/Assets/Fungus/Scripts/Commands/Condition.cs @@ -11,6 +11,8 @@ namespace Fungus.Commands [Tooltip("The type of comparison to be performed")] [SerializeField] protected CompareOperator compareOperator; + #region Public members + public static string GetOperatorDescription(CompareOperator compareOperator) { string summary = ""; @@ -38,5 +40,7 @@ namespace Fungus.Commands return summary; } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/ControlAudio.cs b/Assets/Fungus/Scripts/Commands/ControlAudio.cs index 013d25fe..308f65f8 100644 --- a/Assets/Fungus/Scripts/Commands/ControlAudio.cs +++ b/Assets/Fungus/Scripts/Commands/ControlAudio.cs @@ -54,49 +54,10 @@ namespace Fungus.Commands [Tooltip("Wait until this command has finished before executing the next command.")] [SerializeField] protected bool waitUntilFinished = false; - - public override void OnEnter() - { - if (_audioSource.Value == null) - { - Continue(); - return; - } - - if (control != ControlAudioType.ChangeVolume) - { - _audioSource.Value.volume = endVolume; - } - - switch(control) - { - case ControlAudioType.PlayOnce: - StopAudioWithSameTag(); - PlayOnce(); - break; - case ControlAudioType.PlayLoop: - StopAudioWithSameTag(); - PlayLoop(); - break; - case ControlAudioType.PauseLoop: - PauseLoop(); - break; - case ControlAudioType.StopLoop: - StopLoop(_audioSource.Value); - break; - case ControlAudioType.ChangeVolume: - ChangeVolume(); - break; - } - if (!waitUntilFinished) - { - Continue(); - } - } // If there's other music playing in the scene, assign it the same tag as the new music you want to play and // the old music will be automatically stopped. - protected void StopAudioWithSameTag() + protected virtual void StopAudioWithSameTag() { // Don't stop audio if there's no tag assigned if (_audioSource.Value == null || @@ -115,15 +76,15 @@ namespace Fungus.Commands } } - protected void PlayOnce() + protected virtual void PlayOnce() { if (fadeDuration > 0) { // Fade volume in LeanTween.value(_audioSource.Value.gameObject, - _audioSource.Value.volume, - endVolume, - fadeDuration + _audioSource.Value.volume, + endVolume, + fadeDuration ).setOnUpdate( (float updateVolume)=>{ _audioSource.Value.volume = updateVolume; @@ -150,7 +111,7 @@ namespace Fungus.Commands Continue(); } - protected void PlayLoop() + protected virtual void PlayLoop() { if (fadeDuration > 0) { @@ -179,7 +140,7 @@ namespace Fungus.Commands } } - protected void PauseLoop() + protected virtual void PauseLoop() { if (fadeDuration > 0) { @@ -190,7 +151,7 @@ namespace Fungus.Commands } ).setOnComplete( ()=>{ - + _audioSource.Value.GetComponent().Pause(); if (waitUntilFinished) { @@ -205,7 +166,7 @@ namespace Fungus.Commands } } - protected void StopLoop(AudioSource source) + protected virtual void StopLoop(AudioSource source) { if (fadeDuration > 0) { @@ -216,7 +177,7 @@ namespace Fungus.Commands } ).setOnComplete( ()=>{ - + source.GetComponent().Stop(); if (waitUntilFinished) { @@ -231,7 +192,7 @@ namespace Fungus.Commands } } - protected void ChangeVolume() + protected virtual void ChangeVolume() { LeanTween.value(_audioSource.Value.gameObject,_audioSource.Value.volume,endVolume,fadeDuration ).setOnUpdate( @@ -246,7 +207,7 @@ namespace Fungus.Commands }); } - void AudioFinished() + protected virtual void AudioFinished() { if (waitUntilFinished) { @@ -254,6 +215,47 @@ namespace Fungus.Commands } } + #region Public members + + public override void OnEnter() + { + if (_audioSource.Value == null) + { + Continue(); + return; + } + + if (control != ControlAudioType.ChangeVolume) + { + _audioSource.Value.volume = endVolume; + } + + switch(control) + { + case ControlAudioType.PlayOnce: + StopAudioWithSameTag(); + PlayOnce(); + break; + case ControlAudioType.PlayLoop: + StopAudioWithSameTag(); + PlayLoop(); + break; + case ControlAudioType.PauseLoop: + PauseLoop(); + break; + case ControlAudioType.StopLoop: + StopLoop(_audioSource.Value); + break; + case ControlAudioType.ChangeVolume: + ChangeVolume(); + break; + } + if (!waitUntilFinished) + { + Continue(); + } + } + public override string GetSummary() { if (_audioSource.Value == null) @@ -282,6 +284,8 @@ namespace Fungus.Commands return new Color32(242, 209, 176, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("audioSource")] public AudioSource audioSourceOLD; diff --git a/Assets/Fungus/Scripts/Commands/ControlStage.cs b/Assets/Fungus/Scripts/Commands/ControlStage.cs index c035a497..2fc2da60 100644 --- a/Assets/Fungus/Scripts/Commands/ControlStage.cs +++ b/Assets/Fungus/Scripts/Commands/ControlStage.cs @@ -51,7 +51,65 @@ namespace Fungus.Commands [Tooltip("Wait until the tween has finished before executing the next command")] [SerializeField] protected bool waitUntilFinished = false; - + + protected virtual void Show(Stage stage, bool visible) + { + float duration = (fadeDuration == 0) ? float.Epsilon : fadeDuration; + float targetAlpha = visible ? 1f : 0f; + + CanvasGroup canvasGroup = stage.GetComponentInChildren(); + if (canvasGroup == null) + { + Continue(); + return; + } + + LeanTween.value(canvasGroup.gameObject, canvasGroup.alpha, targetAlpha, duration).setOnUpdate( (float alpha) => { + canvasGroup.alpha = alpha; + }).setOnComplete( () => { + OnComplete(); + }); + } + + protected virtual void MoveToFront(Stage stage) + { + foreach (Stage s in Stage.ActiveStages) + { + if (s == stage) + { + s.PortraitCanvas.sortingOrder = 1; + } + else + { + s.PortraitCanvas.sortingOrder = 0; + } + } + } + + protected virtual void UndimAllPortraits(Stage stage) + { + stage.DimPortraits = false; + foreach (Character character in stage.CharactersOnStage) + { + stage.SetDimmed(character, false); + } + } + + protected virtual void DimNonSpeakingPortraits(Stage stage) + { + stage.DimPortraits = true; + } + + protected virtual void OnComplete() + { + if (waitUntilFinished) + { + Continue(); + } + } + + #region Public members + public override void OnEnter() { // If no display specified, do nothing @@ -123,62 +181,6 @@ namespace Fungus.Commands } } - protected void Show(Stage stage, bool visible) - { - float duration = (fadeDuration == 0) ? float.Epsilon : fadeDuration; - float targetAlpha = visible ? 1f : 0f; - - CanvasGroup canvasGroup = stage.GetComponentInChildren(); - if (canvasGroup == null) - { - Continue(); - return; - } - - LeanTween.value(canvasGroup.gameObject, canvasGroup.alpha, targetAlpha, duration).setOnUpdate( (float alpha) => { - canvasGroup.alpha = alpha; - }).setOnComplete( () => { - OnComplete(); - }); - } - - protected void MoveToFront(Stage stage) - { - foreach (Stage s in Stage.activeStages) - { - if (s == stage) - { - s.PortraitCanvas.sortingOrder = 1; - } - else - { - s.PortraitCanvas.sortingOrder = 0; - } - } - } - - protected void UndimAllPortraits(Stage stage) - { - stage.DimPortraits = false; - foreach (Character character in stage.CharactersOnStage) - { - stage.SetDimmed(character, false); - } - } - - protected void DimNonSpeakingPortraits(Stage stage) - { - stage.DimPortraits = true; - } - - protected void OnComplete() - { - if (waitUntilFinished) - { - Continue(); - } - } - public override string GetSummary() { string displaySummary = ""; @@ -208,5 +210,7 @@ namespace Fungus.Commands //Default to display type: show display = StageDisplayType.Show; } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/ControlWithDisplay.cs b/Assets/Fungus/Scripts/Commands/ControlWithDisplay.cs index 36a8f2d7..b440e018 100644 --- a/Assets/Fungus/Scripts/Commands/ControlWithDisplay.cs +++ b/Assets/Fungus/Scripts/Commands/ControlWithDisplay.cs @@ -11,12 +11,16 @@ namespace Fungus.Commands [Tooltip("Display type")] [SerializeField] protected TDisplayEnum display; - public virtual TDisplayEnum Display { get { return display; } } - - protected bool IsDisplayNone(TEnum enumValue) + protected virtual bool IsDisplayNone(TEnum enumValue) { string displayTypeStr = Enum.GetName(typeof (TEnum), enumValue); return displayTypeStr == "None"; } + + #region Public members + + public virtual TDisplayEnum Display { get { return display; } } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Conversation.cs b/Assets/Fungus/Scripts/Commands/Conversation.cs index e0ff9cd9..dd7cd9ec 100644 --- a/Assets/Fungus/Scripts/Commands/Conversation.cs +++ b/Assets/Fungus/Scripts/Commands/Conversation.cs @@ -27,11 +27,6 @@ namespace Fungus.Commands conversationManager.PopulateCharacterCache(); } - public override void OnEnter() - { - StartCoroutine(DoConversation()); - } - protected virtual IEnumerator DoConversation() { var flowchart = GetFlowchart(); @@ -42,6 +37,13 @@ namespace Fungus.Commands Continue(); } + #region Public members + + public override void OnEnter() + { + StartCoroutine(DoConversation()); + } + public override string GetSummary() { return conversationText.Value; @@ -51,5 +53,7 @@ namespace Fungus.Commands { return new Color32(184, 210, 235, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/DebugLog.cs b/Assets/Fungus/Scripts/Commands/DebugLog.cs index 8834cab6..7579ba6c 100644 --- a/Assets/Fungus/Scripts/Commands/DebugLog.cs +++ b/Assets/Fungus/Scripts/Commands/DebugLog.cs @@ -34,6 +34,8 @@ namespace Fungus.Commands [Tooltip("Text to write to the debug log. Supports variable substitution, e.g. {$Myvar}")] [SerializeField] protected StringDataMulti logMessage; + #region Public members + public override void OnEnter () { var flowchart = GetFlowchart(); @@ -64,5 +66,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs b/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs index aae4b8db..76920d1f 100644 --- a/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs +++ b/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs @@ -17,6 +17,8 @@ namespace Fungus.Commands [Tooltip("Name of the saved value. Supports variable substition e.g. \"player_{$PlayerNumber}")] [SerializeField] protected string key = ""; + #region Public members + public override void OnEnter() { if (key == "") @@ -49,5 +51,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Destroy.cs b/Assets/Fungus/Scripts/Commands/Destroy.cs index 2333ebfc..2e0c5c64 100644 --- a/Assets/Fungus/Scripts/Commands/Destroy.cs +++ b/Assets/Fungus/Scripts/Commands/Destroy.cs @@ -20,6 +20,8 @@ namespace Fungus.Commands [Tooltip("Reference to game object to destroy")] [SerializeField] protected GameObjectData _targetGameObject; + #region Public members + public override void OnEnter() { if (_targetGameObject.Value != null) @@ -45,6 +47,8 @@ namespace Fungus.Commands return new Color32(235, 191, 217, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("targetGameObject")] public GameObject targetGameObjectOLD; diff --git a/Assets/Fungus/Scripts/Commands/Else.cs b/Assets/Fungus/Scripts/Commands/Else.cs index 7af0fa6c..c77783ee 100644 --- a/Assets/Fungus/Scripts/Commands/Else.cs +++ b/Assets/Fungus/Scripts/Commands/Else.cs @@ -14,6 +14,8 @@ namespace Fungus.Commands [AddComponentMenu("")] public class Else : Command { + #region Public members + public override void OnEnter() { if (ParentBlock == null) @@ -64,5 +66,7 @@ namespace Fungus.Commands { return new Color32(253, 253, 150, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/ElseIf.cs b/Assets/Fungus/Scripts/Commands/ElseIf.cs index 5c187e6a..7e9424a9 100644 --- a/Assets/Fungus/Scripts/Commands/ElseIf.cs +++ b/Assets/Fungus/Scripts/Commands/ElseIf.cs @@ -14,6 +14,8 @@ namespace Fungus.Commands [AddComponentMenu("")] public class ElseIf : If { + #region Public members + public override void OnEnter() { System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType(); @@ -73,5 +75,7 @@ namespace Fungus.Commands { return new Color32(253, 253, 150, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/End.cs b/Assets/Fungus/Scripts/Commands/End.cs index 8af8d487..c4c363a7 100644 --- a/Assets/Fungus/Scripts/Commands/End.cs +++ b/Assets/Fungus/Scripts/Commands/End.cs @@ -14,6 +14,8 @@ namespace Fungus.Commands [AddComponentMenu("")] public class End : Command { + #region Public members + public virtual bool Loop { get; set; } public override void OnEnter() @@ -43,5 +45,7 @@ namespace Fungus.Commands { return new Color32(253, 253, 150, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/ExecuteLua.cs b/Assets/Fungus/Scripts/Commands/ExecuteLua.cs index 3f346ec1..4c53af59 100644 --- a/Assets/Fungus/Scripts/Commands/ExecuteLua.cs +++ b/Assets/Fungus/Scripts/Commands/ExecuteLua.cs @@ -108,29 +108,6 @@ namespace Fungus.Commands return luaFile.text + "\n" + luaScript; } - public override void OnEnter() - { - InitExecuteLua(); - - if (luaFunction == null) - { - Continue(); - } - - LuaEnv.RunLuaFunction(luaFunction, runAsCoroutine, (returnValue) => { - StoreReturnVariable(returnValue); - if (waitUntilFinished) - { - Continue(); - } - }); - - if (!waitUntilFinished) - { - Continue(); - } - } - protected virtual void StoreReturnVariable(DynValue returnValue) { if (returnVariable == null || returnValue == null) @@ -194,6 +171,31 @@ namespace Fungus.Commands } } + #region Public members + + public override void OnEnter() + { + InitExecuteLua(); + + if (luaFunction == null) + { + Continue(); + } + + LuaEnv.RunLuaFunction(luaFunction, runAsCoroutine, (returnValue) => { + StoreReturnVariable(returnValue); + if (waitUntilFinished) + { + Continue(); + } + }); + + if (!waitUntilFinished) + { + Continue(); + } + } + public override string GetSummary() { return luaScript; @@ -203,5 +205,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } diff --git a/Assets/Fungus/Scripts/Commands/FadeScreen.cs b/Assets/Fungus/Scripts/Commands/FadeScreen.cs index ff86f94a..e00a3b11 100644 --- a/Assets/Fungus/Scripts/Commands/FadeScreen.cs +++ b/Assets/Fungus/Scripts/Commands/FadeScreen.cs @@ -30,7 +30,9 @@ namespace Fungus.Commands [Tooltip("Optional texture to use when rendering the fullscreen fade effect.")] [SerializeField] protected Texture2D fadeTexture; - + + #region Public members + public override void OnEnter() { var cameraController = CameraController.GetInstance(); @@ -66,5 +68,7 @@ namespace Fungus.Commands { return new Color32(216, 228, 170, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/FadeSprite.cs b/Assets/Fungus/Scripts/Commands/FadeSprite.cs index f3f8a1d3..6cd9f113 100644 --- a/Assets/Fungus/Scripts/Commands/FadeSprite.cs +++ b/Assets/Fungus/Scripts/Commands/FadeSprite.cs @@ -18,16 +18,18 @@ namespace Fungus.Commands public class FadeSprite : Command { [Tooltip("Sprite object to be faded")] - public SpriteRenderer spriteRenderer; + [SerializeField] protected SpriteRenderer spriteRenderer; [Tooltip("Length of time to perform the fade")] - public FloatData _duration = new FloatData(1f); + [SerializeField] protected FloatData _duration = new FloatData(1f); [Tooltip("Target color to fade to. To only fade transparency level, set the color to white and set the alpha to required transparency.")] - public ColorData _targetColor = new ColorData(Color.white); + [SerializeField] protected ColorData _targetColor = new ColorData(Color.white); [Tooltip("Wait until the fade has finished before executing the next command")] - public bool waitUntilFinished = true; + [SerializeField] protected bool waitUntilFinished = true; + + #region Public members public override void OnEnter() { @@ -65,6 +67,8 @@ namespace Fungus.Commands return new Color32(221, 184, 169, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("duration")] public float durationOLD; diff --git a/Assets/Fungus/Scripts/Commands/FadeToView.cs b/Assets/Fungus/Scripts/Commands/FadeToView.cs index b3be3249..d49d9e2a 100644 --- a/Assets/Fungus/Scripts/Commands/FadeToView.cs +++ b/Assets/Fungus/Scripts/Commands/FadeToView.cs @@ -22,7 +22,6 @@ namespace Fungus.Commands [Tooltip("View to transition to when Fade is complete")] [SerializeField] protected View targetView; - public virtual View TargetView { get { return targetView; } } [Tooltip("Wait until the fade has finished before executing next command")] [SerializeField] protected bool waitUntilFinished = true; @@ -36,6 +35,11 @@ namespace Fungus.Commands [Tooltip("Camera to use for the fade. Will use main camera if set to none.")] [SerializeField] protected Camera targetCamera; + protected virtual void Start() + { + AcquireCamera(); + } + protected virtual void AcquireCamera() { if (targetCamera != null) @@ -50,10 +54,12 @@ namespace Fungus.Commands } } - public virtual void Start() - { - AcquireCamera(); - } + #region Public members + + /// + /// View to transition to when Fade is complete + /// + public virtual View TargetView { get { return targetView; } } public override void OnEnter() { @@ -110,5 +116,7 @@ namespace Fungus.Commands { return new Color32(216, 228, 170, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/FadeUI.cs b/Assets/Fungus/Scripts/Commands/FadeUI.cs index a2caa96f..e4978357 100644 --- a/Assets/Fungus/Scripts/Commands/FadeUI.cs +++ b/Assets/Fungus/Scripts/Commands/FadeUI.cs @@ -140,6 +140,8 @@ namespace Fungus.Commands return ""; } + #region Public members + public override bool IsPropertyVisible(string propertyName) { if (fadeMode == FadeMode.Alpha && @@ -156,5 +158,7 @@ namespace Fungus.Commands return true; } + + #endregion } } diff --git a/Assets/Fungus/Scripts/Commands/Fullscreen.cs b/Assets/Fungus/Scripts/Commands/Fullscreen.cs index b6578ccd..c6a852af 100644 --- a/Assets/Fungus/Scripts/Commands/Fullscreen.cs +++ b/Assets/Fungus/Scripts/Commands/Fullscreen.cs @@ -29,6 +29,8 @@ namespace Fungus.Commands { [SerializeField] protected FullscreenMode fullscreenMode; + #region Public members + public override void OnEnter() { switch (fullscreenMode) @@ -56,5 +58,7 @@ namespace Fungus.Commands { return new Color32(216, 228, 170, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/GetText.cs b/Assets/Fungus/Scripts/Commands/GetText.cs index b9d535dc..d0f074c4 100644 --- a/Assets/Fungus/Scripts/Commands/GetText.cs +++ b/Assets/Fungus/Scripts/Commands/GetText.cs @@ -23,7 +23,9 @@ namespace Fungus.Commands [Tooltip("String variable to store the text value in")] [VariableProperty(typeof(StringVariable))] [SerializeField] protected StringVariable stringVariable; - + + #region Public members + public override void OnEnter() { if (stringVariable == null) @@ -81,6 +83,10 @@ namespace Fungus.Commands return new Color32(235, 191, 217, 255); } + #endregion + + #region Backwards compatibility + // Backwards compatibility with Fungus v2.1.2 [HideInInspector] [FormerlySerializedAs("textObject")] @@ -92,5 +98,7 @@ namespace Fungus.Commands targetTextObject = _textObjectObsolete.gameObject; } } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/If.cs b/Assets/Fungus/Scripts/Commands/If.cs index 0456934d..fcad60dd 100644 --- a/Assets/Fungus/Scripts/Commands/If.cs +++ b/Assets/Fungus/Scripts/Commands/If.cs @@ -33,53 +33,8 @@ namespace Fungus.Commands [Tooltip("String value to compare against")] [SerializeField] protected StringDataMulti stringData; - - public override void OnEnter() - { - if (ParentBlock == null) - { - return; - } - - if (variable == null) - { - Continue(); - return; - } - EvaluateAndContinue(); - } - - public bool EvaluateCondition() - { - BooleanVariable booleanVariable = variable as BooleanVariable; - IntegerVariable integerVariable = variable as IntegerVariable; - FloatVariable floatVariable = variable as FloatVariable; - StringVariable stringVariable = variable as StringVariable; - - bool condition = false; - - if (booleanVariable != null) - { - condition = booleanVariable.Evaluate(compareOperator, booleanData.Value); - } - else if (integerVariable != null) - { - condition = integerVariable.Evaluate(compareOperator, integerData.Value); - } - else if (floatVariable != null) - { - condition = floatVariable.Evaluate(compareOperator, floatData.Value); - } - else if (stringVariable != null) - { - condition = stringVariable.Evaluate(compareOperator, stringData.Value); - } - - return condition; - } - - protected void EvaluateAndContinue() + protected virtual void EvaluateAndContinue() { if (EvaluateCondition()) { @@ -124,7 +79,7 @@ namespace Fungus.Commands { continue; } - + System.Type type = nextCommand.GetType(); if (type == typeof(Else) || type == typeof(End)) @@ -154,6 +109,53 @@ namespace Fungus.Commands StopParentBlock(); } + protected virtual bool EvaluateCondition() + { + BooleanVariable booleanVariable = variable as BooleanVariable; + IntegerVariable integerVariable = variable as IntegerVariable; + FloatVariable floatVariable = variable as FloatVariable; + StringVariable stringVariable = variable as StringVariable; + + bool condition = false; + + if (booleanVariable != null) + { + condition = booleanVariable.Evaluate(compareOperator, booleanData.Value); + } + else if (integerVariable != null) + { + condition = integerVariable.Evaluate(compareOperator, integerData.Value); + } + else if (floatVariable != null) + { + condition = floatVariable.Evaluate(compareOperator, floatData.Value); + } + else if (stringVariable != null) + { + condition = stringVariable.Evaluate(compareOperator, stringData.Value); + } + + return condition; + } + + #region Public members + + public override void OnEnter() + { + if (ParentBlock == null) + { + return; + } + + if (variable == null) + { + Continue(); + return; + } + + EvaluateAndContinue(); + } + public override string GetSummary() { if (variable == null) @@ -198,5 +200,7 @@ namespace Fungus.Commands { return new Color32(253, 253, 150, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/InvokeEvent.cs b/Assets/Fungus/Scripts/Commands/InvokeEvent.cs index e49d37cf..ef541996 100644 --- a/Assets/Fungus/Scripts/Commands/InvokeEvent.cs +++ b/Assets/Fungus/Scripts/Commands/InvokeEvent.cs @@ -37,14 +37,10 @@ namespace Fungus.Commands [AddComponentMenu("")] public class InvokeEvent : Command { - [Serializable] public class BooleanEvent : UnityEvent {} - [Serializable] public class IntegerEvent : UnityEvent {} - [Serializable] public class FloatEvent : UnityEvent {} - [Serializable] public class StringEvent : UnityEvent {} - [Tooltip("Delay (in seconds) before the methods will be called")] [SerializeField] protected float delay; + [Tooltip("Selects type of method parameter to pass")] [SerializeField] protected InvokeType invokeType; [Tooltip("List of methods to call. Supports methods with no parameters or exactly one string, int, float or object parameter.")] @@ -74,9 +70,39 @@ namespace Fungus.Commands [Tooltip("List of methods to call. Supports methods with one string parameter.")] [SerializeField] protected StringEvent stringEvent = new StringEvent(); + protected virtual void DoInvoke() + { + switch (invokeType) + { + default: + case InvokeType.Static: + staticEvent.Invoke(); + break; + case InvokeType.DynamicBoolean: + booleanEvent.Invoke(booleanParameter.Value); + break; + case InvokeType.DynamicInteger: + integerEvent.Invoke(integerParameter.Value); + break; + case InvokeType.DynamicFloat: + floatEvent.Invoke(floatParameter.Value); + break; + case InvokeType.DynamicString: + stringEvent.Invoke(stringParameter.Value); + break; + } + } + + #region Public members + + [Serializable] public class BooleanEvent : UnityEvent {} + [Serializable] public class IntegerEvent : UnityEvent {} + [Serializable] public class FloatEvent : UnityEvent {} + [Serializable] public class StringEvent : UnityEvent {} + public override void OnEnter() { - if (delay == 0f) + if (Mathf.Approximately(delay, 0f)) { DoInvoke(); } @@ -88,29 +114,6 @@ namespace Fungus.Commands Continue(); } - protected virtual void DoInvoke() - { - switch (invokeType) - { - default: - case InvokeType.Static: - staticEvent.Invoke(); - break; - case InvokeType.DynamicBoolean: - booleanEvent.Invoke(booleanParameter.Value); - break; - case InvokeType.DynamicInteger: - integerEvent.Invoke(integerParameter.Value); - break; - case InvokeType.DynamicFloat: - floatEvent.Invoke(floatParameter.Value); - break; - case InvokeType.DynamicString: - stringEvent.Invoke(stringParameter.Value); - break; - } - } - public override string GetSummary() { string summary = invokeType.ToString() + " "; @@ -142,5 +145,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/InvokeMethod.cs b/Assets/Fungus/Scripts/Commands/InvokeMethod.cs index 8bc46786..a5356734 100644 --- a/Assets/Fungus/Scripts/Commands/InvokeMethod.cs +++ b/Assets/Fungus/Scripts/Commands/InvokeMethod.cs @@ -22,7 +22,6 @@ namespace Fungus.Commands { [Tooltip("GameObject containing the component method to be invoked")] [SerializeField] protected GameObject targetObject; - public virtual GameObject TargetObject { get { return targetObject; } } [HideInInspector] [Tooltip("Name of assembly containing the target component")] @@ -96,47 +95,6 @@ namespace Fungus.Commands } } - public override void OnEnter() - { - try - { - if (targetObject == null || string.IsNullOrEmpty(targetComponentAssemblyName) || string.IsNullOrEmpty(targetMethod)) - { - Continue(); - return; - } - - if (returnValueType != "System.Collections.IEnumerator") - { - var objReturnValue = objMethod.Invoke(objComponent, GetParameterValues()); - - if (saveReturnValue) - { - SetVariable(returnValueVariableKey, objReturnValue, returnValueType); - } - - Continue(); - } - else - { - StartCoroutine(ExecuteCoroutine()); - - if (callMode == CallMode.Continue) - { - Continue(); - } - else if(callMode == CallMode.Stop) - { - StopParentBlock(); - } - } - } - catch (System.Exception ex) - { - Debug.LogError("Error: " + ex.Message); - } - } - protected virtual IEnumerator ExecuteCoroutine() { yield return StartCoroutine((IEnumerator)objMethod.Invoke(objComponent, GetParameterValues())); @@ -147,22 +105,7 @@ namespace Fungus.Commands } } - public override Color GetButtonColor() - { - return new Color32(235, 191, 217, 255); - } - - public override string GetSummary() - { - if (targetObject == null) - { - return "Error: targetObject is not assigned"; - } - - return targetObject.name + "." + targetComponentText + "." + targetMethodText; - } - - protected System.Type[] GetParameterTypes() + protected virtual System.Type[] GetParameterTypes() { System.Type[] types = new System.Type[methodParameters.Length]; @@ -177,7 +120,7 @@ namespace Fungus.Commands return types; } - protected object[] GetParameterValues() + protected virtual object[] GetParameterValues() { object[] values = new object[methodParameters.Length]; var flowChart = GetFlowchart(); @@ -265,7 +208,7 @@ namespace Fungus.Commands return values; } - protected void SetVariable(string key, object value, string returnType) + protected virtual void SetVariable(string key, object value, string returnType) { var flowChart = GetFlowchart(); @@ -309,6 +252,71 @@ namespace Fungus.Commands break; } } + + #region Public members + + /// + /// GameObject containing the component method to be invoked. + /// + public virtual GameObject TargetObject { get { return targetObject; } } + + public override void OnEnter() + { + try + { + if (targetObject == null || string.IsNullOrEmpty(targetComponentAssemblyName) || string.IsNullOrEmpty(targetMethod)) + { + Continue(); + return; + } + + if (returnValueType != "System.Collections.IEnumerator") + { + var objReturnValue = objMethod.Invoke(objComponent, GetParameterValues()); + + if (saveReturnValue) + { + SetVariable(returnValueVariableKey, objReturnValue, returnValueType); + } + + Continue(); + } + else + { + StartCoroutine(ExecuteCoroutine()); + + if (callMode == CallMode.Continue) + { + Continue(); + } + else if(callMode == CallMode.Stop) + { + StopParentBlock(); + } + } + } + catch (System.Exception ex) + { + Debug.LogError("Error: " + ex.Message); + } + } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } + + public override string GetSummary() + { + if (targetObject == null) + { + return "Error: targetObject is not assigned"; + } + + return targetObject.name + "." + targetComponentText + "." + targetMethodText; + } + + #endregion } [System.Serializable] @@ -317,7 +325,6 @@ namespace Fungus.Commands [SerializeField] public ObjectValue objValue; - [SerializeField] public string variableKey; } diff --git a/Assets/Fungus/Scripts/Commands/Jump.cs b/Assets/Fungus/Scripts/Commands/Jump.cs index 4c63477c..c4bd782a 100644 --- a/Assets/Fungus/Scripts/Commands/Jump.cs +++ b/Assets/Fungus/Scripts/Commands/Jump.cs @@ -20,6 +20,8 @@ namespace Fungus.Commands [Tooltip("Name of a label in this block to jump to")] [SerializeField] protected StringData _targetLabel = new StringData(""); + #region Public members + public override void OnEnter() { if (_targetLabel.Value == "") @@ -59,6 +61,8 @@ namespace Fungus.Commands return new Color32(253, 253, 150, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("targetLabel")] public Label targetLabelOLD; diff --git a/Assets/Fungus/Scripts/Commands/Label.cs b/Assets/Fungus/Scripts/Commands/Label.cs index da76c909..c1222cd8 100644 --- a/Assets/Fungus/Scripts/Commands/Label.cs +++ b/Assets/Fungus/Scripts/Commands/Label.cs @@ -16,6 +16,12 @@ namespace Fungus.Commands { [Tooltip("Display name for the label")] [SerializeField] protected string key = ""; + + #region Public members + + /// + /// Display name for the label + /// public virtual string Key { get { return key; } } public override void OnEnter() @@ -32,5 +38,7 @@ namespace Fungus.Commands { return new Color32(200, 200, 253, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/LoadScene.cs b/Assets/Fungus/Scripts/Commands/LoadScene.cs index 5d41d36d..495b5d8d 100644 --- a/Assets/Fungus/Scripts/Commands/LoadScene.cs +++ b/Assets/Fungus/Scripts/Commands/LoadScene.cs @@ -29,6 +29,8 @@ namespace Fungus.Commands [Tooltip("Image to display while loading the scene")] [SerializeField] protected Texture2D loadingImage; + #region Public members + public override void OnEnter() { SceneLoader.LoadScene(_sceneName.Value, loadingImage); @@ -49,6 +51,8 @@ namespace Fungus.Commands return new Color32(235, 191, 217, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("sceneName")] public string sceneNameOLD = ""; diff --git a/Assets/Fungus/Scripts/Commands/LoadVariable.cs b/Assets/Fungus/Scripts/Commands/LoadVariable.cs index 16718cd2..ac3480be 100644 --- a/Assets/Fungus/Scripts/Commands/LoadVariable.cs +++ b/Assets/Fungus/Scripts/Commands/LoadVariable.cs @@ -23,7 +23,9 @@ namespace Fungus.Commands typeof(IntegerVariable), typeof(FloatVariable), typeof(StringVariable))] - public Variable variable; + [SerializeField] protected Variable variable; + + #region Public members public override void OnEnter() { @@ -97,5 +99,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/LookFrom.cs b/Assets/Fungus/Scripts/Commands/LookFrom.cs index 52d8f1e3..ab242383 100644 --- a/Assets/Fungus/Scripts/Commands/LookFrom.cs +++ b/Assets/Fungus/Scripts/Commands/LookFrom.cs @@ -27,6 +27,8 @@ namespace Fungus.Commands [Tooltip("Restricts rotation to the supplied axis only")] [SerializeField] protected iTweenAxis axis; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -58,7 +60,9 @@ namespace Fungus.Commands tweenParams.Add("oncompletetarget", gameObject); tweenParams.Add("oncompleteparams", this); iTween.LookFrom(_targetObject.Value, tweenParams); - } + } + + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/LookTo.cs b/Assets/Fungus/Scripts/Commands/LookTo.cs index 3f0b0058..d71373f6 100644 --- a/Assets/Fungus/Scripts/Commands/LookTo.cs +++ b/Assets/Fungus/Scripts/Commands/LookTo.cs @@ -27,6 +27,8 @@ namespace Fungus.Commands [Tooltip("Restricts rotation to the supplied axis only")] [SerializeField] protected iTweenAxis axis; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -60,6 +62,8 @@ namespace Fungus.Commands iTween.LookTo(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("toTransform")] public Transform toTransformOLD; diff --git a/Assets/Fungus/Scripts/Commands/Menu.cs b/Assets/Fungus/Scripts/Commands/Menu.cs index 2dd72482..67bec41a 100644 --- a/Assets/Fungus/Scripts/Commands/Menu.cs +++ b/Assets/Fungus/Scripts/Commands/Menu.cs @@ -36,6 +36,8 @@ namespace Fungus.Commands [Tooltip("A custom Menu Dialog to use to display this menu. All subsequent Menu commands will use this dialog.")] [SerializeField] protected MenuDialog setMenuDialog; + #region Public member + public override void OnEnter() { if (setMenuDialog != null) @@ -91,6 +93,8 @@ namespace Fungus.Commands return new Color32(184, 210, 235, 255); } + #endregion + #region ILocalizable implementation public virtual string GetStandardText() diff --git a/Assets/Fungus/Scripts/Commands/MenuTimer.cs b/Assets/Fungus/Scripts/Commands/MenuTimer.cs index 32d83a83..51a4424b 100644 --- a/Assets/Fungus/Scripts/Commands/MenuTimer.cs +++ b/Assets/Fungus/Scripts/Commands/MenuTimer.cs @@ -25,6 +25,8 @@ namespace Fungus.Commands [Tooltip("Block to execute when the timer expires")] [SerializeField] protected Block targetBlock; + #region Public members + public override void OnEnter() { var menuDialog = MenuDialog.GetMenuDialog(); @@ -61,6 +63,8 @@ namespace Fungus.Commands return new Color32(184, 210, 235, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("duration")] public float durationOLD; diff --git a/Assets/Fungus/Scripts/Commands/MoveAdd.cs b/Assets/Fungus/Scripts/Commands/MoveAdd.cs index afbb729e..4909ce30 100644 --- a/Assets/Fungus/Scripts/Commands/MoveAdd.cs +++ b/Assets/Fungus/Scripts/Commands/MoveAdd.cs @@ -24,6 +24,8 @@ namespace Fungus.Commands [Tooltip("Apply the transformation in either the world coordinate or local cordinate system")] [SerializeField] protected Space space = Space.Self; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -39,6 +41,8 @@ namespace Fungus.Commands iTween.MoveAdd(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("offset")] public Vector3 offsetOLD; diff --git a/Assets/Fungus/Scripts/Commands/MoveFrom.cs b/Assets/Fungus/Scripts/Commands/MoveFrom.cs index 2bb75a90..8716b9e2 100644 --- a/Assets/Fungus/Scripts/Commands/MoveFrom.cs +++ b/Assets/Fungus/Scripts/Commands/MoveFrom.cs @@ -27,6 +27,8 @@ namespace Fungus.Commands [Tooltip("Whether to animate in world space or relative to the parent. False by default.")] [SerializeField] protected bool isLocal; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -49,6 +51,8 @@ namespace Fungus.Commands iTween.MoveFrom(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("fromTransform")] public Transform fromTransformOLD; diff --git a/Assets/Fungus/Scripts/Commands/MoveTo.cs b/Assets/Fungus/Scripts/Commands/MoveTo.cs index 94214f4d..cccb748f 100644 --- a/Assets/Fungus/Scripts/Commands/MoveTo.cs +++ b/Assets/Fungus/Scripts/Commands/MoveTo.cs @@ -27,6 +27,8 @@ namespace Fungus.Commands [Tooltip("Whether to animate in world space or relative to the parent. False by default.")] [SerializeField] protected bool isLocal; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -49,6 +51,8 @@ namespace Fungus.Commands iTween.MoveTo(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("toTransform")] public Transform toTransformOLD; diff --git a/Assets/Fungus/Scripts/Commands/MoveToView.cs b/Assets/Fungus/Scripts/Commands/MoveToView.cs index 9055f551..ba14ce11 100644 --- a/Assets/Fungus/Scripts/Commands/MoveToView.cs +++ b/Assets/Fungus/Scripts/Commands/MoveToView.cs @@ -46,6 +46,8 @@ namespace Fungus.Commands AcquireCamera(); } + #region Public members + public override void OnEnter() { AcquireCamera(); @@ -96,5 +98,7 @@ namespace Fungus.Commands { return new Color32(216, 228, 170, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/OpenURL.cs b/Assets/Fungus/Scripts/Commands/OpenURL.cs index 5f982170..fc0cf62c 100644 --- a/Assets/Fungus/Scripts/Commands/OpenURL.cs +++ b/Assets/Fungus/Scripts/Commands/OpenURL.cs @@ -18,6 +18,8 @@ namespace Fungus.Commands [Tooltip("URL to open in the browser")] [SerializeField] protected StringData url = new StringData(); + #region Public members + public override void OnEnter() { Application.OpenURL(url.Value); @@ -34,5 +36,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/PlayAnimState.cs b/Assets/Fungus/Scripts/Commands/PlayAnimState.cs index c4e79a26..485d7eb3 100644 --- a/Assets/Fungus/Scripts/Commands/PlayAnimState.cs +++ b/Assets/Fungus/Scripts/Commands/PlayAnimState.cs @@ -27,6 +27,8 @@ namespace Fungus.Commands [Tooltip("Start time of animation")] [SerializeField] protected FloatData time = new FloatData(0f); + #region Public members + public override void OnEnter() { if (animator.Value != null) @@ -51,6 +53,8 @@ namespace Fungus.Commands { return new Color32(170, 204, 169, 255); } + + #endregion } } diff --git a/Assets/Fungus/Scripts/Commands/PlayMusic.cs b/Assets/Fungus/Scripts/Commands/PlayMusic.cs index 005f2be2..3add80cd 100644 --- a/Assets/Fungus/Scripts/Commands/PlayMusic.cs +++ b/Assets/Fungus/Scripts/Commands/PlayMusic.cs @@ -26,6 +26,8 @@ namespace Fungus.Commands [Tooltip("Length of time to fade out previous playing music.")] [SerializeField] protected float fadeDuration = 1f; + #region Public members + public override void OnEnter() { var musicController = MusicController.GetInstance(); @@ -52,5 +54,7 @@ namespace Fungus.Commands { return new Color32(242, 209, 176, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/PlaySound.cs b/Assets/Fungus/Scripts/Commands/PlaySound.cs index 14613641..8478fa25 100644 --- a/Assets/Fungus/Scripts/Commands/PlaySound.cs +++ b/Assets/Fungus/Scripts/Commands/PlaySound.cs @@ -24,6 +24,13 @@ namespace Fungus.Commands [Tooltip("Wait until the sound has finished playing before continuing execution.")] [SerializeField] protected bool waitUntilFinished; + protected virtual void DoWait() + { + Continue(); + } + + #region Public members + public override void OnEnter() { if (soundClip == null) @@ -48,11 +55,6 @@ namespace Fungus.Commands } } - protected virtual void DoWait() - { - Continue(); - } - public override string GetSummary() { if (soundClip == null) @@ -67,5 +69,7 @@ namespace Fungus.Commands { return new Color32(242, 209, 176, 255); } + + #endregion } } diff --git a/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs b/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs index 87ab88ca..53734c64 100644 --- a/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs +++ b/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs @@ -30,7 +30,7 @@ using Fungus.Variables; protected SfxrSynth _synth = new SfxrSynth(); //Call this if the settings have changed - protected void UpdateCache() + protected virtual void UpdateCache() { if (_SettingsString.Value != null) { @@ -39,12 +39,19 @@ using Fungus.Variables; } } - public void Awake() + protected virtual void Awake() { //Always build the cache on awake UpdateCache(); } + protected void DoWait() + { + Continue(); + } + + #region Public members + public override void OnEnter() { _synth.SetParentTransform(ParentTransform); @@ -59,11 +66,6 @@ using Fungus.Variables; } } - protected void DoWait() - { - Continue(); - } - public override string GetSummary() { if (String.IsNullOrEmpty(_SettingsString.Value)) @@ -82,6 +84,8 @@ using Fungus.Variables; return new Color32(128, 200, 200, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("SettingsString")] public String SettingsStringOLD = ""; diff --git a/Assets/Fungus/Scripts/Commands/Portrait.cs b/Assets/Fungus/Scripts/Commands/Portrait.cs index 4e6bcf4e..310c8bbd 100644 --- a/Assets/Fungus/Scripts/Commands/Portrait.cs +++ b/Assets/Fungus/Scripts/Commands/Portrait.cs @@ -16,59 +16,101 @@ namespace Fungus.Commands { [Tooltip("Stage to display portrait on")] [SerializeField] protected Stage stage; - public virtual Stage _Stage { get { return stage; } set { stage = value; } } [Tooltip("Character to display")] [SerializeField] protected Character character; - public virtual Character _Character { get { return character; } set { character = value; } } [Tooltip("Character to swap with")] [SerializeField] protected Character replacedCharacter; - + [Tooltip("Portrait to display")] [SerializeField] protected Sprite portrait; - public virtual Sprite _Portrait { get { return portrait; } set { portrait = value; } } [Tooltip("Move the portrait from/to this offset position")] [SerializeField] protected PositionOffset offset; - public virtual PositionOffset Offset { get { return offset; } set { offset = value; } } [Tooltip("Move the portrait from this position")] [SerializeField] protected RectTransform fromPosition; - public virtual RectTransform FromPosition { get { return fromPosition; } set { fromPosition = value;} } - [Tooltip("Move the portrait to this positoin")] + [Tooltip("Move the portrait to this position")] [SerializeField] protected RectTransform toPosition; - public virtual RectTransform ToPosition { get { return toPosition; } set { toPosition = value;} } [Tooltip("Direction character is facing")] [SerializeField] protected FacingDirection facing; - public virtual FacingDirection Facing { get { return facing; } set { facing = value; } } [Tooltip("Use Default Settings")] [SerializeField] protected bool useDefaultSettings = true; - public virtual bool UseDefaultSettings { get { return useDefaultSettings; } set { useDefaultSettings = value; } } [Tooltip("Fade Duration")] [SerializeField] protected float fadeDuration = 0.5f; - + [Tooltip("Movement Duration")] [SerializeField] protected float moveDuration = 1f; - + [Tooltip("Shift Offset")] [SerializeField] protected Vector2 shiftOffset; - - [Tooltip("Move")] + + [Tooltip("Move portrait into new position")] [SerializeField] protected bool move; - public virtual bool Move { get { return move; } set { move = value; } } - [Tooltip("Start from offset")] + [Tooltip("Start from offset position")] [SerializeField] protected bool shiftIntoPlace; - public virtual bool ShiftIntoPlace { get { return shiftIntoPlace; } set { shiftIntoPlace = value; } } [Tooltip("Wait until the tween has finished before executing the next command")] [SerializeField] protected bool waitUntilFinished = false; + #region Public members + + /// + /// Stage to display portrait on. + /// + public virtual Stage _Stage { get { return stage; } set { stage = value; } } + + /// + /// Character to display. + /// + public virtual Character _Character { get { return character; } set { character = value; } } + + /// + /// Portrait to display. + /// + public virtual Sprite _Portrait { get { return portrait; } set { portrait = value; } } + + /// + /// Move the portrait from/to this offset position. + /// + public virtual PositionOffset Offset { get { return offset; } set { offset = value; } } + + /// + /// Move the portrait from this position. + /// + public virtual RectTransform FromPosition { get { return fromPosition; } set { fromPosition = value;} } + + /// + /// Move the portrait to this position. + /// + public virtual RectTransform ToPosition { get { return toPosition; } set { toPosition = value;} } + + /// + /// Direction character is facing. + /// + public virtual FacingDirection Facing { get { return facing; } set { facing = value; } } + + /// + /// Use Default Settings. + /// + public virtual bool UseDefaultSettings { get { return useDefaultSettings; } set { useDefaultSettings = value; } } + + /// + /// Move portrait into new position. + /// + public virtual bool Move { get { return move; } set { move = value; } } + + /// + /// Start from offset position. + /// + public virtual bool ShiftIntoPlace { get { return shiftIntoPlace; } set { shiftIntoPlace = value; } } + public override void OnEnter() { // Selected "use default Portrait Stage" @@ -213,5 +255,7 @@ namespace Fungus.Commands //Default to display type: show display = DisplayType.Show; } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/PunchPosition.cs b/Assets/Fungus/Scripts/Commands/PunchPosition.cs index 54641709..9b57c96b 100644 --- a/Assets/Fungus/Scripts/Commands/PunchPosition.cs +++ b/Assets/Fungus/Scripts/Commands/PunchPosition.cs @@ -24,6 +24,8 @@ namespace Fungus.Commands [Tooltip("Apply the transformation in either the world coordinate or local cordinate system")] [SerializeField] protected Space space = Space.Self; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -39,6 +41,8 @@ namespace Fungus.Commands iTween.PunchPosition(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; diff --git a/Assets/Fungus/Scripts/Commands/PunchRotation.cs b/Assets/Fungus/Scripts/Commands/PunchRotation.cs index 2b2ea475..afb104cb 100644 --- a/Assets/Fungus/Scripts/Commands/PunchRotation.cs +++ b/Assets/Fungus/Scripts/Commands/PunchRotation.cs @@ -24,6 +24,8 @@ namespace Fungus.Commands [Tooltip("Apply the transformation in either the world coordinate or local cordinate system")] [SerializeField] protected Space space = Space.Self; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -39,6 +41,8 @@ namespace Fungus.Commands iTween.PunchRotation(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; diff --git a/Assets/Fungus/Scripts/Commands/PunchScale.cs b/Assets/Fungus/Scripts/Commands/PunchScale.cs index 1507f54e..181effac 100644 --- a/Assets/Fungus/Scripts/Commands/PunchScale.cs +++ b/Assets/Fungus/Scripts/Commands/PunchScale.cs @@ -21,6 +21,8 @@ namespace Fungus.Commands [Tooltip("A scale offset in space the GameObject will animate to")] [SerializeField] protected Vector3Data _amount; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -35,6 +37,8 @@ namespace Fungus.Commands iTween.PunchScale(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; diff --git a/Assets/Fungus/Scripts/Commands/Quit.cs b/Assets/Fungus/Scripts/Commands/Quit.cs index 041843ed..98314427 100644 --- a/Assets/Fungus/Scripts/Commands/Quit.cs +++ b/Assets/Fungus/Scripts/Commands/Quit.cs @@ -14,6 +14,8 @@ namespace Fungus.Commands [AddComponentMenu("")] public class Quit : Command { + #region Public members + public override void OnEnter() { Application.Quit(); @@ -26,5 +28,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/RandomFloat.cs b/Assets/Fungus/Scripts/Commands/RandomFloat.cs index 0aead1be..00953272 100644 --- a/Assets/Fungus/Scripts/Commands/RandomFloat.cs +++ b/Assets/Fungus/Scripts/Commands/RandomFloat.cs @@ -25,6 +25,8 @@ namespace Fungus.Commands [Tooltip("Maximum value for random range")] [SerializeField] protected FloatData maxValue; + #region Public members + public override void OnEnter() { if (variable != null) @@ -54,5 +56,7 @@ namespace Fungus.Commands { return new Color32(253, 253, 150, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/RandomInteger.cs b/Assets/Fungus/Scripts/Commands/RandomInteger.cs index 1515541c..f4fb0fdc 100644 --- a/Assets/Fungus/Scripts/Commands/RandomInteger.cs +++ b/Assets/Fungus/Scripts/Commands/RandomInteger.cs @@ -25,6 +25,8 @@ namespace Fungus.Commands [Tooltip("Maximum value for random range")] [SerializeField] protected IntegerData maxValue; + #region Public members + public override void OnEnter() { if (variable != null) @@ -54,5 +56,7 @@ namespace Fungus.Commands { return new Color32(253, 253, 150, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/ReadTextFile.cs b/Assets/Fungus/Scripts/Commands/ReadTextFile.cs index 10397bcd..65626128 100644 --- a/Assets/Fungus/Scripts/Commands/ReadTextFile.cs +++ b/Assets/Fungus/Scripts/Commands/ReadTextFile.cs @@ -22,6 +22,8 @@ namespace Fungus.Commands [VariableProperty(typeof(StringVariable))] [SerializeField] protected StringVariable stringVariable; + #region Public members + public override void OnEnter() { if (textFile == null || @@ -60,5 +62,7 @@ namespace Fungus.Commands { return new Color32(253, 253, 150, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Reset.cs b/Assets/Fungus/Scripts/Commands/Reset.cs index e6e6d728..b2cdcfc3 100644 --- a/Assets/Fungus/Scripts/Commands/Reset.cs +++ b/Assets/Fungus/Scripts/Commands/Reset.cs @@ -20,6 +20,8 @@ namespace Fungus.Commands [Tooltip("Reset variables back to their default values")] [SerializeField] protected bool resetVariables = true; + #region Public members + public override void OnEnter() { GetFlowchart().Reset(resetCommands, resetVariables); @@ -30,5 +32,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs b/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs index 3ecab22b..5c6cdafb 100644 --- a/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs +++ b/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs @@ -23,6 +23,8 @@ namespace Fungus.Commands [Tooltip("Name of the trigger Animator parameter that will be reset")] [SerializeField] protected StringData _parameterName; + #region Public members + public override void OnEnter() { if (_animator.Value != null) @@ -48,6 +50,8 @@ namespace Fungus.Commands return new Color32(170, 204, 169, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("animator")] public Animator animatorOLD; diff --git a/Assets/Fungus/Scripts/Commands/RotateAdd.cs b/Assets/Fungus/Scripts/Commands/RotateAdd.cs index a0a3ec43..b2a019fe 100644 --- a/Assets/Fungus/Scripts/Commands/RotateAdd.cs +++ b/Assets/Fungus/Scripts/Commands/RotateAdd.cs @@ -24,6 +24,8 @@ namespace Fungus.Commands [Tooltip("Apply the transformation in either the world coordinate or local cordinate system")] [SerializeField] protected Space space = Space.Self; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -39,6 +41,8 @@ namespace Fungus.Commands iTween.RotateAdd(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("offset")] public Vector3 offsetOLD; diff --git a/Assets/Fungus/Scripts/Commands/RotateFrom.cs b/Assets/Fungus/Scripts/Commands/RotateFrom.cs index 8ec7db27..a8ba3e4f 100644 --- a/Assets/Fungus/Scripts/Commands/RotateFrom.cs +++ b/Assets/Fungus/Scripts/Commands/RotateFrom.cs @@ -27,6 +27,8 @@ namespace Fungus.Commands [Tooltip("Whether to animate in world space or relative to the parent. False by default.")] [SerializeField] protected bool isLocal; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -49,6 +51,8 @@ namespace Fungus.Commands iTween.RotateFrom(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("fromTransform")] public Transform fromTransformOLD; diff --git a/Assets/Fungus/Scripts/Commands/RotateTo.cs b/Assets/Fungus/Scripts/Commands/RotateTo.cs index e5dfadcc..f0f67d0a 100644 --- a/Assets/Fungus/Scripts/Commands/RotateTo.cs +++ b/Assets/Fungus/Scripts/Commands/RotateTo.cs @@ -27,6 +27,8 @@ namespace Fungus.Commands [Tooltip("Whether to animate in world space or relative to the parent. False by default.")] [SerializeField] protected bool isLocal; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -49,6 +51,8 @@ namespace Fungus.Commands iTween.RotateTo(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("toTransform")] public Transform toTransformOLD; diff --git a/Assets/Fungus/Scripts/Commands/SaveVariable.cs b/Assets/Fungus/Scripts/Commands/SaveVariable.cs index bdca4c3a..df640bf3 100644 --- a/Assets/Fungus/Scripts/Commands/SaveVariable.cs +++ b/Assets/Fungus/Scripts/Commands/SaveVariable.cs @@ -27,7 +27,9 @@ namespace Fungus.Commands typeof(IntegerVariable), typeof(FloatVariable), typeof(StringVariable))] - public Variable variable; + [SerializeField] protected Variable variable; + + #region Public members public override void OnEnter() { @@ -101,5 +103,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Say.cs b/Assets/Fungus/Scripts/Commands/Say.cs index fe1af4eb..d6db89f5 100644 --- a/Assets/Fungus/Scripts/Commands/Say.cs +++ b/Assets/Fungus/Scripts/Commands/Say.cs @@ -23,11 +23,9 @@ namespace Fungus.Commands [Tooltip("Character that is speaking")] [SerializeField] protected Character character; - public virtual Character _Character { get { return character; } } [Tooltip("Portrait that represents speaking character")] [SerializeField] protected Sprite portrait; - public virtual Sprite Portrait { get { return portrait; } set { portrait = value; } } [Tooltip("Voiceover audio to play when writing the text")] [SerializeField] protected AudioClip voiceOverClip; @@ -40,7 +38,6 @@ namespace Fungus.Commands [Tooltip("Type this text in the previous dialog box.")] [SerializeField] protected bool extendPrevious = false; - public virtual bool ExtendPrevious { get { return extendPrevious; } } [Tooltip("Fade out the dialog box when writing has finished and not waiting for input.")] [SerializeField] protected bool fadeWhenDone = true; @@ -56,6 +53,23 @@ namespace Fungus.Commands protected int executionCount; + #region Public members + + /// + /// Character that is speaking. + /// + public virtual Character _Character { get { return character; } } + + /// + /// Portrait that represents speaking character. + /// + public virtual Sprite Portrait { get { return portrait; } set { portrait = value; } } + + /// + /// Type this text in the previous dialog box. + /// + public virtual bool ExtendPrevious { get { return extendPrevious; } } + public override void OnEnter() { if (!showAlways && executionCount >= showCount) @@ -144,6 +158,8 @@ namespace Fungus.Commands sayDialog.Stop(); } + #endregion + #region ILocalizable implementation public virtual string GetStandardText() diff --git a/Assets/Fungus/Scripts/Commands/ScaleAdd.cs b/Assets/Fungus/Scripts/Commands/ScaleAdd.cs index 1083d457..d1c4ddb4 100644 --- a/Assets/Fungus/Scripts/Commands/ScaleAdd.cs +++ b/Assets/Fungus/Scripts/Commands/ScaleAdd.cs @@ -21,6 +21,8 @@ namespace Fungus.Commands [Tooltip("A scale offset in space the GameObject will animate to")] [SerializeField] protected Vector3Data _offset; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -35,6 +37,8 @@ namespace Fungus.Commands iTween.ScaleAdd(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("offset")] public Vector3 offsetOLD; diff --git a/Assets/Fungus/Scripts/Commands/ScaleFrom.cs b/Assets/Fungus/Scripts/Commands/ScaleFrom.cs index 483ed2d0..51cdfa9e 100644 --- a/Assets/Fungus/Scripts/Commands/ScaleFrom.cs +++ b/Assets/Fungus/Scripts/Commands/ScaleFrom.cs @@ -24,6 +24,8 @@ namespace Fungus.Commands [Tooltip("Target scale that the GameObject will scale from, if no From Transform is set")] [SerializeField] protected Vector3Data _fromScale; + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -45,6 +47,8 @@ namespace Fungus.Commands iTween.ScaleFrom(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("fromTransform")] public Transform fromTransformOLD; diff --git a/Assets/Fungus/Scripts/Commands/ScaleTo.cs b/Assets/Fungus/Scripts/Commands/ScaleTo.cs index 6a34268e..c53a38af 100644 --- a/Assets/Fungus/Scripts/Commands/ScaleTo.cs +++ b/Assets/Fungus/Scripts/Commands/ScaleTo.cs @@ -24,6 +24,8 @@ namespace Fungus.Commands [Tooltip("Target scale that the GameObject will scale to, if no To Transform is set")] [SerializeField] protected Vector3Data _toScale = new Vector3Data(Vector3.one); + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -45,6 +47,8 @@ namespace Fungus.Commands iTween.ScaleTo(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("toTransform")] public Transform toTransformOLD; diff --git a/Assets/Fungus/Scripts/Commands/SendMessage.cs b/Assets/Fungus/Scripts/Commands/SendMessage.cs index ae44517a..2c2692ed 100644 --- a/Assets/Fungus/Scripts/Commands/SendMessage.cs +++ b/Assets/Fungus/Scripts/Commands/SendMessage.cs @@ -39,6 +39,8 @@ namespace Fungus.Commands [Tooltip("Name of the message to send")] [SerializeField] protected StringData _message = new StringData(""); + #region Public members + public override void OnEnter() { if (_message.Value.Length == 0) @@ -83,6 +85,8 @@ namespace Fungus.Commands return new Color32(235, 191, 217, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("message")] public string messageOLD = ""; diff --git a/Assets/Fungus/Scripts/Commands/SetActive.cs b/Assets/Fungus/Scripts/Commands/SetActive.cs index 27feb641..4bb9c9b2 100644 --- a/Assets/Fungus/Scripts/Commands/SetActive.cs +++ b/Assets/Fungus/Scripts/Commands/SetActive.cs @@ -23,6 +23,8 @@ namespace Fungus.Commands [Tooltip("Set to true to enable the game object")] [SerializeField] protected BooleanData activeState; + #region Public members + public override void OnEnter() { if (_targetGameObject.Value != null) @@ -48,6 +50,8 @@ namespace Fungus.Commands return new Color32(235, 191, 217, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("targetGameObject")] public GameObject targetGameObjectOLD; diff --git a/Assets/Fungus/Scripts/Commands/SetAnimBool.cs b/Assets/Fungus/Scripts/Commands/SetAnimBool.cs index 8e4fb946..feff71e1 100644 --- a/Assets/Fungus/Scripts/Commands/SetAnimBool.cs +++ b/Assets/Fungus/Scripts/Commands/SetAnimBool.cs @@ -26,6 +26,8 @@ namespace Fungus.Commands [Tooltip("The boolean value to set the parameter to")] [SerializeField] protected BooleanData value; + #region Public members + public override void OnEnter() { if (_animator.Value != null) @@ -51,6 +53,8 @@ namespace Fungus.Commands return new Color32(170, 204, 169, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("animator")] public Animator animatorOLD; diff --git a/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs b/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs index 13c1add6..43985c44 100644 --- a/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs +++ b/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs @@ -26,6 +26,8 @@ namespace Fungus.Commands [Tooltip("The float value to set the parameter to")] [SerializeField] protected FloatData value; + #region Public members + public override void OnEnter() { if (_animator.Value != null) @@ -51,6 +53,8 @@ namespace Fungus.Commands return new Color32(170, 204, 169, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("animator")] public Animator animatorOLD; diff --git a/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs b/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs index 21e4cde9..db638a72 100644 --- a/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs +++ b/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs @@ -26,6 +26,8 @@ namespace Fungus.Commands [Tooltip("The integer value to set the parameter to")] [SerializeField] protected IntegerData value; + #region Public members + public override void OnEnter() { if (_animator.Value != null) @@ -51,6 +53,8 @@ namespace Fungus.Commands return new Color32(170, 204, 169, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("animator")] public Animator animatorOLD; diff --git a/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs b/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs index 262ab3d7..03c19eb1 100644 --- a/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs +++ b/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs @@ -23,6 +23,8 @@ namespace Fungus.Commands [Tooltip("Name of the trigger Animator parameter that will have its value changed")] [SerializeField] protected StringData _parameterName; + #region Public members + public override void OnEnter() { if (_animator.Value != null) @@ -48,6 +50,8 @@ namespace Fungus.Commands return new Color32(170, 204, 169, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("animator")] public Animator animatorOLD; diff --git a/Assets/Fungus/Scripts/Commands/SetAudioPitch.cs b/Assets/Fungus/Scripts/Commands/SetAudioPitch.cs index c7664e07..59002c0f 100644 --- a/Assets/Fungus/Scripts/Commands/SetAudioPitch.cs +++ b/Assets/Fungus/Scripts/Commands/SetAudioPitch.cs @@ -25,6 +25,8 @@ namespace Fungus.Commands [Tooltip("Wait until the pitch change has finished before executing next command")] [SerializeField] protected bool waitUntilFinished = true; + #region Public members + public override void OnEnter() { System.Action onComplete = () => { @@ -55,5 +57,7 @@ namespace Fungus.Commands { return new Color32(242, 209, 176, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetAudioVolume.cs b/Assets/Fungus/Scripts/Commands/SetAudioVolume.cs index e0b44fe0..f492481c 100644 --- a/Assets/Fungus/Scripts/Commands/SetAudioVolume.cs +++ b/Assets/Fungus/Scripts/Commands/SetAudioVolume.cs @@ -25,6 +25,8 @@ namespace Fungus.Commands [Tooltip("Wait until the volume fade has completed before continuing.")] [SerializeField] protected bool waitUntilFinished = true; + #region Public members + public override void OnEnter() { var musicController = MusicController.GetInstance(); @@ -53,5 +55,7 @@ namespace Fungus.Commands { return new Color32(242, 209, 176, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetClickable2D.cs b/Assets/Fungus/Scripts/Commands/SetClickable2D.cs index 9866ce52..488fcf82 100644 --- a/Assets/Fungus/Scripts/Commands/SetClickable2D.cs +++ b/Assets/Fungus/Scripts/Commands/SetClickable2D.cs @@ -21,6 +21,8 @@ namespace Fungus.Commands [Tooltip("Set to true to enable the component")] [SerializeField] protected BooleanData activeState; + #region Public members + public override void OnEnter() { if (targetClickable2D != null) @@ -45,6 +47,8 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetCollider.cs b/Assets/Fungus/Scripts/Commands/SetCollider.cs index 5d5eaaf3..dfb04709 100644 --- a/Assets/Fungus/Scripts/Commands/SetCollider.cs +++ b/Assets/Fungus/Scripts/Commands/SetCollider.cs @@ -25,6 +25,26 @@ namespace Fungus.Commands [Tooltip("Set to true to enable the collider components")] [SerializeField] protected BooleanData activeState; + protected virtual void SetColliderActive(GameObject go) + { + if (go != null) + { + // 3D objects + foreach (Collider c in go.GetComponentsInChildren()) + { + c.enabled = activeState.Value; + } + + // 2D objects + foreach (Collider2D c in go.GetComponentsInChildren()) + { + c.enabled = activeState.Value; + } + } + } + + #region Public members + public override void OnEnter() { foreach (GameObject go in targetObjects) @@ -53,24 +73,6 @@ namespace Fungus.Commands Continue(); } - protected virtual void SetColliderActive(GameObject go) - { - if (go != null) - { - // 3D objects - foreach (Collider c in go.GetComponentsInChildren()) - { - c.enabled = activeState.Value; - } - - // 2D objects - foreach (Collider2D c in go.GetComponentsInChildren()) - { - c.enabled = activeState.Value; - } - } - } - public override string GetSummary() { int count = targetObjects.Count; @@ -89,6 +91,8 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs b/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs index 544e51f4..eba99d71 100644 --- a/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs +++ b/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs @@ -21,6 +21,8 @@ namespace Fungus.Commands [Tooltip("Set to true to enable the component")] [SerializeField] protected BooleanData activeState; + #region Public members + public override void OnEnter() { if (targetDraggable2D != null) @@ -45,5 +47,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetInteractable.cs b/Assets/Fungus/Scripts/Commands/SetInteractable.cs index 1767a27e..29fd3d29 100644 --- a/Assets/Fungus/Scripts/Commands/SetInteractable.cs +++ b/Assets/Fungus/Scripts/Commands/SetInteractable.cs @@ -22,6 +22,8 @@ namespace Fungus.Commands [Tooltip("Controls if the selectable UI object be interactable or not")] [SerializeField] protected BooleanData interactableState = new BooleanData(true); + #region Public members + public override void OnEnter() { if (targetObjects.Count == 0) @@ -96,5 +98,7 @@ namespace Fungus.Commands return false; } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetLanguage.cs b/Assets/Fungus/Scripts/Commands/SetLanguage.cs index 49195695..1aae5a83 100644 --- a/Assets/Fungus/Scripts/Commands/SetLanguage.cs +++ b/Assets/Fungus/Scripts/Commands/SetLanguage.cs @@ -20,6 +20,8 @@ namespace Fungus.Commands [Tooltip("Code of the language to set. e.g. ES, DE, JA")] [SerializeField] protected StringData _languageCode = new StringData(); + #region Public members + public static string mostRecentLanguage = ""; public override void OnEnter() @@ -47,6 +49,8 @@ namespace Fungus.Commands return new Color32(184, 210, 235, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("languageCode")] public string languageCodeOLD = ""; diff --git a/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs b/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs index 65023378..d57fff4e 100644 --- a/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs +++ b/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs @@ -19,7 +19,24 @@ namespace Fungus.Commands [Tooltip("The New Layer Name to apply")] [SerializeField] protected string sortingLayer; - + + protected void ApplySortingLayer(Transform target, string layerName) + { + Renderer renderer = target.gameObject.GetComponent(); + if (renderer) + { + renderer.sortingLayerName = layerName; + Debug.Log(target.name); + } + + foreach (Transform child in target.transform) + { + ApplySortingLayer(child, layerName); + } + } + + #region Public members + public override void OnEnter() { if (targetObject != null) @@ -44,20 +61,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } - - protected void ApplySortingLayer(Transform target, string layerName) - { - Renderer renderer = target.gameObject.GetComponent(); - if (renderer) - { - renderer.sortingLayerName = layerName; - Debug.Log(target.name); - } - foreach (Transform child in target.transform) - { - ApplySortingLayer(child, layerName); - } - } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs b/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs index 0661f512..93925c17 100644 --- a/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs +++ b/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs @@ -17,6 +17,8 @@ namespace Fungus.Commands [Tooltip("The Menu Dialog to use for displaying menu buttons")] [SerializeField] protected MenuDialog menuDialog; + #region Public members + public override void OnEnter() { if (menuDialog != null) @@ -41,5 +43,7 @@ namespace Fungus.Commands { return new Color32(184, 210, 235, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetMouseCursor.cs b/Assets/Fungus/Scripts/Commands/SetMouseCursor.cs index e847fa06..a54d8c4a 100644 --- a/Assets/Fungus/Scripts/Commands/SetMouseCursor.cs +++ b/Assets/Fungus/Scripts/Commands/SetMouseCursor.cs @@ -24,6 +24,8 @@ namespace Fungus.Commands protected static Texture2D activeCursorTexture; protected static Vector2 activeHotspot; + #region Public members + public static void ResetMouseCursor() { // Change mouse cursor back to most recent settings @@ -54,5 +56,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs b/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs index bcf56096..38932c14 100644 --- a/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs +++ b/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs @@ -16,14 +16,16 @@ namespace Fungus.Commands [AddComponentMenu("")] public class SetSaveProfile : Command { + [Tooltip("Name of save profile to make active.")] + [SerializeField] protected string saveProfileName = ""; + + #region Public members + /// /// Shared save profile name used by SaveVariable and LoadVariable. /// public static string saveProfile = ""; - [Tooltip("Name of save profile to make active.")] - [SerializeField] protected string saveProfileName = ""; - public override void OnEnter() { saveProfile = saveProfileName; @@ -40,5 +42,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetSayDialog.cs b/Assets/Fungus/Scripts/Commands/SetSayDialog.cs index b7662546..09501a99 100644 --- a/Assets/Fungus/Scripts/Commands/SetSayDialog.cs +++ b/Assets/Fungus/Scripts/Commands/SetSayDialog.cs @@ -17,6 +17,8 @@ namespace Fungus.Commands [Tooltip("The Say Dialog to use for displaying Say story text")] [SerializeField] protected SayDialog sayDialog; + #region Public members + public override void OnEnter() { if (sayDialog != null) @@ -41,5 +43,7 @@ namespace Fungus.Commands { return new Color32(184, 210, 235, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetSliderValue.cs b/Assets/Fungus/Scripts/Commands/SetSliderValue.cs index 56577404..e67d7883 100644 --- a/Assets/Fungus/Scripts/Commands/SetSliderValue.cs +++ b/Assets/Fungus/Scripts/Commands/SetSliderValue.cs @@ -21,6 +21,8 @@ namespace Fungus.Commands [Tooltip("Float value to set the slider value to.")] [SerializeField] protected FloatData value; + #region Public members + public override void OnEnter() { slider.value = value; @@ -42,5 +44,7 @@ namespace Fungus.Commands return slider.name + " = " + value.GetDescription(); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs index 20a928dc..77588824 100644 --- a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs +++ b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs @@ -22,6 +22,8 @@ namespace Fungus.Commands [Tooltip("The order in layer value to set on the target sprites")] [SerializeField] protected IntegerData orderInLayer; + #region Public members + public override void OnEnter() { foreach (SpriteRenderer spriteRenderer in targetSprites) @@ -78,5 +80,7 @@ namespace Fungus.Commands // Add a default empty entry targetSprites.Add(null); } + + #endregion } } diff --git a/Assets/Fungus/Scripts/Commands/SetText.cs b/Assets/Fungus/Scripts/Commands/SetText.cs index 0dbc3140..b0d1b0f8 100644 --- a/Assets/Fungus/Scripts/Commands/SetText.cs +++ b/Assets/Fungus/Scripts/Commands/SetText.cs @@ -26,7 +26,9 @@ namespace Fungus.Commands [Tooltip("Notes about this story text for other authors, localization, etc.")] [SerializeField] protected string description; - + + #region Public members + public override void OnEnter() { var flowchart = GetFlowchart(); @@ -79,17 +81,7 @@ namespace Fungus.Commands return new Color32(235, 191, 217, 255); } - // Backwards compatibility with Fungus v2.1.2 - [HideInInspector] - [FormerlySerializedAs("textObject")] - public Text _textObjectObsolete; - protected virtual void OnEnable() - { - if (_textObjectObsolete != null) - { - targetTextObject = _textObjectObsolete.gameObject; - } - } + #endregion #region ILocalizable implementation @@ -115,5 +107,21 @@ namespace Fungus.Commands } #endregion + + #region Backwards compatibility + + // Backwards compatibility with Fungus v2.1.2 + [HideInInspector] + [FormerlySerializedAs("textObject")] + public Text _textObjectObsolete; + protected virtual void OnEnable() + { + if (_textObjectObsolete != null) + { + targetTextObject = _textObjectObsolete.gameObject; + } + } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetVariable.cs b/Assets/Fungus/Scripts/Commands/SetVariable.cs index 582b8354..2f57972b 100644 --- a/Assets/Fungus/Scripts/Commands/SetVariable.cs +++ b/Assets/Fungus/Scripts/Commands/SetVariable.cs @@ -43,7 +43,6 @@ namespace Fungus.Commands [Tooltip("The type of math operation to be performed")] [SerializeField] protected SetOperator setOperator; - public virtual SetOperator _SetOperator { get { return setOperator; } } [Tooltip("Boolean value to set with")] [SerializeField] protected BooleanData booleanData; @@ -56,7 +55,102 @@ namespace Fungus.Commands [Tooltip("String value to set with")] [SerializeField] protected StringDataMulti stringData; - + + protected virtual void DoSetOperation() + { + if (variable == null) + { + return; + } + + if (variable.GetType() == typeof(BooleanVariable)) + { + BooleanVariable lhs = (variable as BooleanVariable); + bool rhs = booleanData.Value; + + switch (setOperator) + { + default: + case SetOperator.Assign: + lhs.Value = rhs; + break; + case SetOperator.Negate: + lhs.Value = !rhs; + break; + } + } + else if (variable.GetType() == typeof(IntegerVariable)) + { + IntegerVariable lhs = (variable as IntegerVariable); + int rhs = integerData.Value; + + switch (setOperator) + { + default: + case SetOperator.Assign: + lhs.Value = rhs; + break; + case SetOperator.Add: + lhs.Value += rhs; + break; + case SetOperator.Subtract: + lhs.Value -= rhs; + break; + case SetOperator.Multiply: + lhs.Value *= rhs; + break; + case SetOperator.Divide: + lhs.Value /= rhs; + break; + } + } + else if (variable.GetType() == typeof(FloatVariable)) + { + FloatVariable lhs = (variable as FloatVariable); + float rhs = floatData.Value; + + switch (setOperator) + { + default: + case SetOperator.Assign: + lhs.Value = rhs; + break; + case SetOperator.Add: + lhs.Value += rhs; + break; + case SetOperator.Subtract: + lhs.Value -= rhs; + break; + case SetOperator.Multiply: + lhs.Value *= rhs; + break; + case SetOperator.Divide: + lhs.Value /= rhs; + break; + } + } + else if (variable.GetType() == typeof(StringVariable)) + { + StringVariable lhs = (variable as StringVariable); + string rhs = stringData.Value; + + switch (setOperator) + { + default: + case SetOperator.Assign: + lhs.Value = rhs; + break; + } + } + } + + #region Public members + + /// + /// The type of math operation to be performed. + /// + public virtual SetOperator _SetOperator { get { return setOperator; } } + public override void OnEnter() { DoSetOperation(); @@ -126,92 +220,6 @@ namespace Fungus.Commands return new Color32(253, 253, 150, 255); } - protected virtual void DoSetOperation() - { - if (variable == null) - { - return; - } - - if (variable.GetType() == typeof(BooleanVariable)) - { - BooleanVariable lhs = (variable as BooleanVariable); - bool rhs = booleanData.Value; - - switch (setOperator) - { - default: - case SetOperator.Assign: - lhs.Value = rhs; - break; - case SetOperator.Negate: - lhs.Value = !rhs; - break; - } - } - else if (variable.GetType() == typeof(IntegerVariable)) - { - IntegerVariable lhs = (variable as IntegerVariable); - int rhs = integerData.Value; - - switch (setOperator) - { - default: - case SetOperator.Assign: - lhs.Value = rhs; - break; - case SetOperator.Add: - lhs.Value += rhs; - break; - case SetOperator.Subtract: - lhs.Value -= rhs; - break; - case SetOperator.Multiply: - lhs.Value *= rhs; - break; - case SetOperator.Divide: - lhs.Value /= rhs; - break; - } - } - else if (variable.GetType() == typeof(FloatVariable)) - { - FloatVariable lhs = (variable as FloatVariable); - float rhs = floatData.Value; - - switch (setOperator) - { - default: - case SetOperator.Assign: - lhs.Value = rhs; - break; - case SetOperator.Add: - lhs.Value += rhs; - break; - case SetOperator.Subtract: - lhs.Value -= rhs; - break; - case SetOperator.Multiply: - lhs.Value *= rhs; - break; - case SetOperator.Divide: - lhs.Value /= rhs; - break; - } - } - else if (variable.GetType() == typeof(StringVariable)) - { - StringVariable lhs = (variable as StringVariable); - string rhs = stringData.Value; - - switch (setOperator) - { - default: - case SetOperator.Assign: - lhs.Value = rhs; - break; - } - } - } + #endregion } } diff --git a/Assets/Fungus/Scripts/Commands/ShakeCamera.cs b/Assets/Fungus/Scripts/Commands/ShakeCamera.cs index f5163178..1290d2ba 100644 --- a/Assets/Fungus/Scripts/Commands/ShakeCamera.cs +++ b/Assets/Fungus/Scripts/Commands/ShakeCamera.cs @@ -23,7 +23,21 @@ namespace Fungus.Commands [Tooltip("Wait until the shake effect has finished before executing next command")] [SerializeField] protected bool waitUntilFinished; - + + protected virtual void OniTweenComplete(object param) + { + Command command = param as Command; + if (command != null && command.Equals(this)) + { + if (waitUntilFinished) + { + Continue(); + } + } + } + + #region Public members + public override void OnEnter() { Vector3 v = new Vector3(); @@ -42,19 +56,7 @@ namespace Fungus.Commands Continue(); } } - - protected virtual void OniTweenComplete(object param) - { - Command command = param as Command; - if (command != null && command.Equals(this)) - { - if (waitUntilFinished) - { - Continue(); - } - } - } - + public override string GetSummary() { return "For " + duration + " seconds."; @@ -64,5 +66,7 @@ namespace Fungus.Commands { return new Color32(216, 228, 170, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/ShakePosition.cs b/Assets/Fungus/Scripts/Commands/ShakePosition.cs index 6c359430..c79c268c 100644 --- a/Assets/Fungus/Scripts/Commands/ShakePosition.cs +++ b/Assets/Fungus/Scripts/Commands/ShakePosition.cs @@ -26,7 +26,9 @@ namespace Fungus.Commands [Tooltip("Restricts rotation to the supplied axis only")] [SerializeField] protected iTweenAxis axis; - + + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -54,6 +56,8 @@ namespace Fungus.Commands iTween.ShakePosition(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; diff --git a/Assets/Fungus/Scripts/Commands/ShakeRotation.cs b/Assets/Fungus/Scripts/Commands/ShakeRotation.cs index 152ee22f..366e1fdf 100644 --- a/Assets/Fungus/Scripts/Commands/ShakeRotation.cs +++ b/Assets/Fungus/Scripts/Commands/ShakeRotation.cs @@ -23,7 +23,9 @@ namespace Fungus.Commands [Tooltip("Apply the transformation in either the world coordinate or local cordinate system")] [SerializeField] protected Space space = Space.Self; - + + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -39,6 +41,8 @@ namespace Fungus.Commands iTween.ShakeRotation(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; diff --git a/Assets/Fungus/Scripts/Commands/ShakeScale.cs b/Assets/Fungus/Scripts/Commands/ShakeScale.cs index a92ea72a..290121f2 100644 --- a/Assets/Fungus/Scripts/Commands/ShakeScale.cs +++ b/Assets/Fungus/Scripts/Commands/ShakeScale.cs @@ -20,7 +20,9 @@ namespace Fungus.Commands { [Tooltip("A scale offset in space the GameObject will animate to")] [SerializeField] protected Vector3Data _amount; - + + #region Public members + public override void DoTween() { Hashtable tweenParams = new Hashtable(); @@ -35,6 +37,8 @@ namespace Fungus.Commands iTween.ShakeScale(_targetObject.Value, tweenParams); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("amount")] public Vector3 amountOLD; diff --git a/Assets/Fungus/Scripts/Commands/ShowSprite.cs b/Assets/Fungus/Scripts/Commands/ShowSprite.cs index cf854b6c..621c0333 100644 --- a/Assets/Fungus/Scripts/Commands/ShowSprite.cs +++ b/Assets/Fungus/Scripts/Commands/ShowSprite.cs @@ -26,6 +26,15 @@ namespace Fungus.Commands [Tooltip("Affect the visibility of child sprites")] [SerializeField] protected bool affectChildren = true; + protected virtual void SetSpriteAlpha(SpriteRenderer renderer, bool visible) + { + Color spriteColor = renderer.color; + spriteColor.a = visible ? 1f : 0f; + renderer.color = spriteColor; + } + + #region Public members + public override void OnEnter() { if (spriteRenderer != null) @@ -47,13 +56,6 @@ namespace Fungus.Commands Continue(); } - protected virtual void SetSpriteAlpha(SpriteRenderer renderer, bool visible) - { - Color spriteColor = renderer.color; - spriteColor.a = visible ? 1f : 0f; - renderer.color = spriteColor; - } - public override string GetSummary() { if (spriteRenderer == null) @@ -69,6 +71,8 @@ namespace Fungus.Commands return new Color32(221, 184, 169, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("visible")] public bool visibleOLD; diff --git a/Assets/Fungus/Scripts/Commands/SpawnObject.cs b/Assets/Fungus/Scripts/Commands/SpawnObject.cs index 18211b7f..e4c35dab 100644 --- a/Assets/Fungus/Scripts/Commands/SpawnObject.cs +++ b/Assets/Fungus/Scripts/Commands/SpawnObject.cs @@ -29,6 +29,8 @@ namespace Fungus.Commands [Tooltip("Local rotation of newly spawned object.")] [SerializeField] protected Vector3Data _spawnRotation; + #region Public members + public override void OnEnter() { if (_sourceObject.Value == null) @@ -64,6 +66,8 @@ namespace Fungus.Commands return new Color32(235, 191, 217, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("sourceObject")] public GameObject sourceObjectOLD; diff --git a/Assets/Fungus/Scripts/Commands/StartSwipe.cs b/Assets/Fungus/Scripts/Commands/StartSwipe.cs index 3bd6d6b5..cd69e6a1 100644 --- a/Assets/Fungus/Scripts/Commands/StartSwipe.cs +++ b/Assets/Fungus/Scripts/Commands/StartSwipe.cs @@ -28,7 +28,9 @@ namespace Fungus.Commands [Tooltip("Camera to use for the pan. Will use main camera if set to none.")] [SerializeField] protected Camera targetCamera; - + + #region Public members + public virtual void Start() { if (targetCamera == null) @@ -75,5 +77,7 @@ namespace Fungus.Commands { return new Color32(216, 228, 170, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Stop.cs b/Assets/Fungus/Scripts/Commands/Stop.cs index 0be1acdc..f1b7909a 100644 --- a/Assets/Fungus/Scripts/Commands/Stop.cs +++ b/Assets/Fungus/Scripts/Commands/Stop.cs @@ -13,7 +13,9 @@ namespace Fungus.Commands "Stop executing the Block that contains this command.")] [AddComponentMenu("")] public class Stop : Command - { + { + #region Public members + public override void OnEnter() { StopParentBlock(); @@ -23,5 +25,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/StopBlock.cs b/Assets/Fungus/Scripts/Commands/StopBlock.cs index 2f6a5e91..a7aeef2f 100644 --- a/Assets/Fungus/Scripts/Commands/StopBlock.cs +++ b/Assets/Fungus/Scripts/Commands/StopBlock.cs @@ -20,6 +20,8 @@ namespace Fungus.Commands [Tooltip("Name of the Block to stop")] [SerializeField] protected StringData blockName = new StringData(""); + #region Public members + public override void OnEnter() { if (blockName.Value == "") @@ -52,6 +54,8 @@ namespace Fungus.Commands public override Color GetButtonColor() { return new Color32(253, 253, 150, 255); - } + } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/StopFlowchart.cs b/Assets/Fungus/Scripts/Commands/StopFlowchart.cs index 9486adad..7dad5ab5 100644 --- a/Assets/Fungus/Scripts/Commands/StopFlowchart.cs +++ b/Assets/Fungus/Scripts/Commands/StopFlowchart.cs @@ -21,6 +21,8 @@ namespace Fungus.Commands [Tooltip("Stop all executing Blocks in a list of target Flowcharts")] [SerializeField] protected List targetFlowcharts = new List(); + #region Public members + public override void OnEnter() { var flowchart = GetFlowchart(); @@ -56,5 +58,7 @@ namespace Fungus.Commands { return new Color32(235, 191, 217, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/StopMusic.cs b/Assets/Fungus/Scripts/Commands/StopMusic.cs index 167a7444..5e4abe27 100644 --- a/Assets/Fungus/Scripts/Commands/StopMusic.cs +++ b/Assets/Fungus/Scripts/Commands/StopMusic.cs @@ -14,6 +14,8 @@ namespace Fungus.Commands [AddComponentMenu("")] public class StopMusic : Command { + #region Public members + public override void OnEnter() { var musicController = MusicController.GetInstance(); @@ -29,5 +31,7 @@ namespace Fungus.Commands { return new Color32(242, 209, 176, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/StopSwipe.cs b/Assets/Fungus/Scripts/Commands/StopSwipe.cs index 69706372..53863e5c 100644 --- a/Assets/Fungus/Scripts/Commands/StopSwipe.cs +++ b/Assets/Fungus/Scripts/Commands/StopSwipe.cs @@ -14,6 +14,8 @@ namespace Fungus.Commands [AddComponentMenu("")] public class StopSwipe : Command { + #region Public members + public override void OnEnter() { var cameraController = CameraController.GetInstance(); @@ -27,5 +29,7 @@ namespace Fungus.Commands { return new Color32(216, 228, 170, 255); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/StopTween.cs b/Assets/Fungus/Scripts/Commands/StopTween.cs index 4e289038..a6d3edaf 100644 --- a/Assets/Fungus/Scripts/Commands/StopTween.cs +++ b/Assets/Fungus/Scripts/Commands/StopTween.cs @@ -20,12 +20,16 @@ namespace Fungus.Commands [Tooltip("Stop and destroy any Tweens in current scene with the supplied name")] [SerializeField] protected StringData _tweenName; + #region Public members + public override void OnEnter() { iTween.StopByName(_tweenName.Value); Continue(); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("tweenName")] public string tweenNameOLD = ""; diff --git a/Assets/Fungus/Scripts/Commands/StopTweens.cs b/Assets/Fungus/Scripts/Commands/StopTweens.cs index bd6f0cd8..bdac4d10 100644 --- a/Assets/Fungus/Scripts/Commands/StopTweens.cs +++ b/Assets/Fungus/Scripts/Commands/StopTweens.cs @@ -14,10 +14,14 @@ namespace Fungus.Commands [AddComponentMenu("")] public class StopTweens : Command { + #region Public members + public override void OnEnter() { iTween.Stop(); Continue(); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/TweenUI.cs b/Assets/Fungus/Scripts/Commands/TweenUI.cs index 24c5395e..9d8cfd4f 100644 --- a/Assets/Fungus/Scripts/Commands/TweenUI.cs +++ b/Assets/Fungus/Scripts/Commands/TweenUI.cs @@ -24,23 +24,7 @@ namespace Fungus.Commands [Tooltip("Time for the tween to complete")] [SerializeField] protected FloatData duration = new FloatData(1f); - - public override void OnEnter() - { - if (targetObjects.Count == 0) - { - Continue(); - return; - } - - ApplyTween(); - if (!waitUntilFinished) - { - Continue(); - } - } - protected virtual void ApplyTween() { foreach (GameObject targetObject in targetObjects) @@ -49,16 +33,16 @@ namespace Fungus.Commands { continue; } - + ApplyTween(targetObject); } - + if (waitUntilFinished) { LeanTween.value(gameObject, 0f, 1f, duration).setOnComplete(OnComplete); } } - + protected abstract void ApplyTween(GameObject go); protected virtual void OnComplete() @@ -66,6 +50,29 @@ namespace Fungus.Commands Continue(); } + protected virtual string GetSummaryValue() + { + return ""; + } + + #region Public members + + public override void OnEnter() + { + if (targetObjects.Count == 0) + { + Continue(); + return; + } + + ApplyTween(); + + if (!waitUntilFinished) + { + Continue(); + } + } + public override void OnCommandAdded(Block parentBlock) { // Add an empty slot by default. Saves an unnecessary user click. @@ -75,11 +82,6 @@ namespace Fungus.Commands } } - protected virtual string GetSummaryValue() - { - return ""; - } - public override string GetSummary() { if (targetObjects.Count == 0) @@ -130,5 +132,7 @@ namespace Fungus.Commands return false; } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Wait.cs b/Assets/Fungus/Scripts/Commands/Wait.cs index f8b45d18..b02989ce 100644 --- a/Assets/Fungus/Scripts/Commands/Wait.cs +++ b/Assets/Fungus/Scripts/Commands/Wait.cs @@ -20,14 +20,16 @@ namespace Fungus.Commands [Tooltip("Duration to wait for")] [SerializeField] protected FloatData _duration = new FloatData(1); - public override void OnEnter() + protected virtual void OnWaitComplete() { - Invoke ("OnWaitComplete", _duration.Value); + Continue(); } - void OnWaitComplete() + #region Public members + + public override void OnEnter() { - Continue(); + Invoke ("OnWaitComplete", _duration.Value); } public override string GetSummary() @@ -40,6 +42,8 @@ namespace Fungus.Commands return new Color32(235, 191, 217, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("duration")] public float durationOLD; diff --git a/Assets/Fungus/Scripts/Commands/While.cs b/Assets/Fungus/Scripts/Commands/While.cs index a7aeed42..4687ab2b 100644 --- a/Assets/Fungus/Scripts/Commands/While.cs +++ b/Assets/Fungus/Scripts/Commands/While.cs @@ -14,6 +14,8 @@ namespace Fungus.Commands [AddComponentMenu("")] public class While : If { + #region Public members + public override void OnEnter() { bool execute = true; @@ -57,6 +59,8 @@ namespace Fungus.Commands public override Color GetButtonColor() { return new Color32(253, 253, 150, 255); - } + } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Write.cs b/Assets/Fungus/Scripts/Commands/Write.cs index cd801621..912f7e87 100644 --- a/Assets/Fungus/Scripts/Commands/Write.cs +++ b/Assets/Fungus/Scripts/Commands/Write.cs @@ -45,10 +45,13 @@ namespace Fungus.Commands [Tooltip("Wait until this command finishes before executing the next command")] [SerializeField] protected bool waitUntilFinished = true; + [Tooltip("Color mode to apply to the text.")] [SerializeField] protected TextColor textColor = TextColor.Default; + [Tooltip("Alpha to apply to the text.")] [SerializeField] protected FloatData setAlpha = new FloatData(1f); + [Tooltip("Color to apply to the text.")] [SerializeField] protected ColorData setColor = new ColorData(Color.white); protected Writer GetWriter() @@ -62,6 +65,8 @@ namespace Fungus.Commands return writer; } + #region Public members + public override void OnEnter() { if (textObject == null) @@ -126,6 +131,8 @@ namespace Fungus.Commands GetWriter().Stop(); } + #endregion + #region ILocalizable implementation public virtual string GetStandardText() diff --git a/Assets/Fungus/Scripts/Commands/iTweenCommand.cs b/Assets/Fungus/Scripts/Commands/iTweenCommand.cs index a3a77dbe..a8124430 100644 --- a/Assets/Fungus/Scripts/Commands/iTweenCommand.cs +++ b/Assets/Fungus/Scripts/Commands/iTweenCommand.cs @@ -49,6 +49,20 @@ namespace Fungus.Commands [Tooltip("Wait until the tween has finished before executing the next command")] [SerializeField] protected bool waitUntilFinished = true; + protected virtual void OniTweenComplete(object param) + { + Command command = param as Command; + if (command != null && command.Equals(this)) + { + if (waitUntilFinished) + { + Continue(); + } + } + } + + #region Public members + public override void OnEnter() { if (_targetObject.Value == null) @@ -78,18 +92,6 @@ namespace Fungus.Commands public virtual void DoTween() {} - protected virtual void OniTweenComplete(object param) - { - Command command = param as Command; - if (command != null && command.Equals(this)) - { - if (waitUntilFinished) - { - Continue(); - } - } - } - public override string GetSummary() { if (_targetObject.Value == null) @@ -105,6 +107,8 @@ namespace Fungus.Commands return new Color32(233, 163, 180, 255); } + #endregion + #region Backwards compatibility [HideInInspector] [FormerlySerializedAs("target")] [FormerlySerializedAs("targetObject")] public GameObject targetObjectOLD; diff --git a/Assets/Fungus/Scripts/Components/CameraController.cs b/Assets/Fungus/Scripts/Components/CameraController.cs index c1cea06d..b6824157 100644 --- a/Assets/Fungus/Scripts/Components/CameraController.cs +++ b/Assets/Fungus/Scripts/Components/CameraController.cs @@ -52,22 +52,7 @@ namespace Fungus protected Dictionary storedViews = new Dictionary(); protected static CameraController instance; - - /// - /// Returns the CameraController singleton instance. - /// Will create a CameraController game object if none currently exists. - /// - static public CameraController GetInstance() - { - if (instance == null) - { - GameObject go = new GameObject("CameraController"); - instance = go.AddComponent(); - } - - return instance; - } - + protected virtual void OnGUI() { if (swipePanActive) @@ -186,41 +171,6 @@ namespace Fungus } } - /// - /// Moves camera smoothly through a sequence of Views over a period of time. - /// - public virtual void PanToPath(Camera camera, View[] viewList, float duration, Action arriveAction) - { - if (camera == null) - { - Debug.LogWarning("Camera is null"); - return; - } - - swipePanActive = false; - - List pathList = new List(); - - // Add current camera position as first point in path - // Note: We use the z coord to tween the camera orthographic size - Vector3 startPos = new Vector3(camera.transform.position.x, - camera.transform.position.y, - camera.orthographicSize); - pathList.Add(startPos); - - for (int i = 0; i < viewList.Length; ++i) - { - View view = viewList[i]; - - Vector3 viewPos = new Vector3(view.transform.position.x, - view.transform.position.y, - view.ViewSize); - pathList.Add(viewPos); - } - - StartCoroutine(PanToPathInternal(camera, duration, arriveAction, pathList.ToArray())); - } - protected virtual IEnumerator PanToPathInternal(Camera camera, float duration, Action arriveAction, Vector3[] path) { if (camera == null) @@ -352,6 +302,56 @@ namespace Fungus #region Public members + /// + /// Returns the CameraController singleton instance. + /// Will create a CameraController game object if none currently exists. + /// + public static CameraController GetInstance() + { + if (instance == null) + { + GameObject go = new GameObject("CameraController"); + instance = go.AddComponent(); + } + + return instance; + } + + /// + /// Moves camera smoothly through a sequence of Views over a period of time. + /// + public virtual void PanToPath(Camera camera, View[] viewList, float duration, Action arriveAction) + { + if (camera == null) + { + Debug.LogWarning("Camera is null"); + return; + } + + swipePanActive = false; + + List pathList = new List(); + + // Add current camera position as first point in path + // Note: We use the z coord to tween the camera orthographic size + Vector3 startPos = new Vector3(camera.transform.position.x, + camera.transform.position.y, + camera.orthographicSize); + pathList.Add(startPos); + + for (int i = 0; i < viewList.Length; ++i) + { + View view = viewList[i]; + + Vector3 viewPos = new Vector3(view.transform.position.x, + view.transform.position.y, + view.ViewSize); + pathList.Add(viewPos); + } + + StartCoroutine(PanToPathInternal(camera, duration, arriveAction, pathList.ToArray())); + } + /// /// Creates a flat colored texture. /// diff --git a/Assets/Fungus/Scripts/Components/Character.cs b/Assets/Fungus/Scripts/Components/Character.cs index 42618931..250175fe 100644 --- a/Assets/Fungus/Scripts/Components/Character.cs +++ b/Assets/Fungus/Scripts/Components/Character.cs @@ -39,7 +39,7 @@ namespace Fungus protected PortraitState portaitState = new PortraitState(); - static public List activeCharacters = new List(); + protected static List activeCharacters = new List(); protected virtual void OnEnable() { @@ -56,6 +56,11 @@ namespace Fungus #region Public members + /// + /// Gets the list of active characters. + /// + public static List ActiveCharacters { get { return activeCharacters; } } + /// /// Character name as displayed in Say Dialog. /// diff --git a/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs b/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs index b49c4fe1..7019a874 100644 --- a/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs +++ b/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs @@ -12,12 +12,22 @@ namespace Fungus public class CommandCopyBuffer : Block { protected static CommandCopyBuffer instance; - + + protected virtual void Start() + { + if (Application.isPlaying) + { + Destroy(this.gameObject); + } + } + + #region Public members + /// /// Returns the CommandCopyBuffer singleton instance. /// Will create a CommandCopyBuffer game object if none currently exists. /// - static public CommandCopyBuffer GetInstance() + public static CommandCopyBuffer GetInstance() { if (instance == null) { @@ -36,16 +46,8 @@ namespace Fungus instance = go.AddComponent(); } } - - return instance; - } - protected virtual void Start() - { - if (Application.isPlaying) - { - Destroy(this.gameObject); - } + return instance; } public virtual bool HasCommands() @@ -65,5 +67,7 @@ namespace Fungus DestroyImmediate(command); } } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Components/CustomTag.cs b/Assets/Fungus/Scripts/Components/CustomTag.cs index 954fcfc1..537f27f4 100644 --- a/Assets/Fungus/Scripts/Components/CustomTag.cs +++ b/Assets/Fungus/Scripts/Components/CustomTag.cs @@ -24,8 +24,6 @@ namespace Fungus [Tooltip("String to replace the end tag with.")] [SerializeField] protected string replaceTagEndWith; - static public List activeCustomTags = new List(); - protected virtual void OnEnable() { if (!activeCustomTags.Contains(this)) @@ -41,6 +39,8 @@ namespace Fungus #region Public members + public static List activeCustomTags = new List(); + /// /// String that defines the start of the tag. /// diff --git a/Assets/Fungus/Scripts/Components/MenuDialog.cs b/Assets/Fungus/Scripts/Components/MenuDialog.cs index 943ea7bd..c11b19b7 100644 --- a/Assets/Fungus/Scripts/Components/MenuDialog.cs +++ b/Assets/Fungus/Scripts/Components/MenuDialog.cs @@ -240,7 +240,7 @@ namespace Fungus /// Will cause the Menu dialog to become visible if it is not already visible. /// /// true, if the option was added successfully. - public bool AddOption(string text, bool interactable, ILuaEnvironment luaEnv, Closure callBack) + public virtual bool AddOption(string text, bool interactable, ILuaEnvironment luaEnv, Closure callBack) { if (!gameObject.activeSelf) { @@ -301,7 +301,7 @@ namespace Fungus /// /// Show a timer during which the player can select an option. Calls a Lua function when the timer expires. /// - public IEnumerator ShowTimer(float duration, ILuaEnvironment luaEnv, Closure callBack) + public virtual IEnumerator ShowTimer(float duration, ILuaEnvironment luaEnv, Closure callBack) { if (CachedSlider == null || duration <= 0f) diff --git a/Assets/Fungus/Scripts/Components/MusicController.cs b/Assets/Fungus/Scripts/Components/MusicController.cs index d05f31fb..8f0c655b 100644 --- a/Assets/Fungus/Scripts/Components/MusicController.cs +++ b/Assets/Fungus/Scripts/Components/MusicController.cs @@ -12,13 +12,21 @@ namespace Fungus [RequireComponent(typeof(AudioSource))] public class MusicController : MonoBehaviour { - static MusicController instance; + protected static MusicController instance; + + protected virtual void Start() + { + GetComponent().playOnAwake = false; + GetComponent().loop = true; + } + + #region Public members /// /// Returns the MusicController singleton instance. /// Will create a MusicController game object if none currently exists. /// - static public MusicController GetInstance() + public static MusicController GetInstance() { if (instance == null) { @@ -30,14 +38,6 @@ namespace Fungus return instance; } - protected virtual void Start() - { - GetComponent().playOnAwake = false; - GetComponent().loop = true; - } - - #region Public members - /// /// Plays game music using an audio clip. /// One music clip may be played at a time. diff --git a/Assets/Fungus/Scripts/Components/SayDialog.cs b/Assets/Fungus/Scripts/Components/SayDialog.cs index def91fc3..8acf3704 100644 --- a/Assets/Fungus/Scripts/Components/SayDialog.cs +++ b/Assets/Fungus/Scripts/Components/SayDialog.cs @@ -226,7 +226,7 @@ namespace Fungus public static void StopPortraitTweens() { // Stop all tweening portraits - foreach( Character c in Character.activeCharacters ) + foreach( Character c in Character.ActiveCharacters ) { if (c.State.portraitImage != null) { @@ -281,7 +281,7 @@ namespace Fungus speakingCharacter = character; // Dim portraits of non-speaking characters - foreach (Stage stage in Stage.activeStages) + foreach (Stage stage in Stage.ActiveStages) { if (stage.DimPortraits) diff --git a/Assets/Fungus/Scripts/Components/SceneLoader.cs b/Assets/Fungus/Scripts/Components/SceneLoader.cs index a85ee1c8..933acb2d 100644 --- a/Assets/Fungus/Scripts/Components/SceneLoader.cs +++ b/Assets/Fungus/Scripts/Components/SceneLoader.cs @@ -22,22 +22,6 @@ namespace Fungus protected string sceneToLoad; protected bool displayedImage; - /// - /// Asynchronously load a new scene. - /// - /// The name of the scene to load. Scenes must be added in project build settings. - /// Loading image to display while loading the new scene. - static public void LoadScene(string _sceneToLoad, Texture2D _loadingTexture) - { - // Unity does not provide a way to check if the named scene actually exists in the project. - GameObject go = new GameObject("SceneLoader"); - DontDestroyOnLoad(go); - - SceneLoader sceneLoader = go.AddComponent(); - sceneLoader.sceneToLoad = _sceneToLoad; - sceneLoader.loadingTexture = _loadingTexture; - } - protected virtual void Start() { StartCoroutine(DoLoadBlock()); @@ -105,5 +89,25 @@ namespace Fungus displayedImage = true; } } + + #region Public members + + /// + /// Asynchronously load a new scene. + /// + /// The name of the scene to load. Scenes must be added in project build settings. + /// Loading image to display while loading the new scene. + public static void LoadScene(string _sceneToLoad, Texture2D _loadingTexture) + { + // Unity does not provide a way to check if the named scene actually exists in the project. + GameObject go = new GameObject("SceneLoader"); + DontDestroyOnLoad(go); + + SceneLoader sceneLoader = go.AddComponent(); + sceneLoader.sceneToLoad = _sceneToLoad; + sceneLoader.loadingTexture = _loadingTexture; + } + + #endregion } } diff --git a/Assets/Fungus/Scripts/Components/SpriteFader.cs b/Assets/Fungus/Scripts/Components/SpriteFader.cs index 492c3557..7d7eb119 100644 --- a/Assets/Fungus/Scripts/Components/SpriteFader.cs +++ b/Assets/Fungus/Scripts/Components/SpriteFader.cs @@ -24,6 +24,47 @@ namespace Fungus protected Action onFadeComplete; + protected virtual void Start() + { + spriteRenderer = GetComponent() as SpriteRenderer; + } + + protected virtual void Update() + { + fadeTimer += Time.deltaTime; + if (fadeTimer > fadeDuration) + { + // Snap to final values + spriteRenderer.color = endColor; + if (slideOffset.magnitude > 0) + { + transform.position = endPosition; + } + + // Remove this component when transition is complete + Destroy(this); + + if (onFadeComplete != null) + { + onFadeComplete(); + } + } + else + { + float t = Mathf.SmoothStep(0, 1, fadeTimer / fadeDuration); + spriteRenderer.color = Color.Lerp(startColor, endColor, t); + if (slideOffset.magnitude > 0) + { + Vector3 startPosition = endPosition; + startPosition.x += slideOffset.x; + startPosition.y += slideOffset.y; + transform.position = Vector3.Lerp(startPosition, endPosition, t); + } + } + } + + #region Public members + /// /// Attaches a SpriteFader component to a sprite object to transition its color over time. /// @@ -43,7 +84,7 @@ namespace Fungus { continue; } - + FadeSprite(child, targetColor, duration, slideOffset); } @@ -75,43 +116,6 @@ namespace Fungus spriteFader.onFadeComplete = onComplete; } - protected virtual void Start() - { - spriteRenderer = GetComponent() as SpriteRenderer; - } - - protected virtual void Update() - { - fadeTimer += Time.deltaTime; - if (fadeTimer > fadeDuration) - { - // Snap to final values - spriteRenderer.color = endColor; - if (slideOffset.magnitude > 0) - { - transform.position = endPosition; - } - - // Remove this component when transition is complete - Destroy(this); - - if (onFadeComplete != null) - { - onFadeComplete(); - } - } - else - { - float t = Mathf.SmoothStep(0, 1, fadeTimer / fadeDuration); - spriteRenderer.color = Color.Lerp(startColor, endColor, t); - if (slideOffset.magnitude > 0) - { - Vector3 startPosition = endPosition; - startPosition.x += slideOffset.x; - startPosition.y += slideOffset.y; - transform.position = Vector3.Lerp(startPosition, endPosition, t); - } - } - } + #endregion } } diff --git a/Assets/Fungus/Scripts/Components/Stage.cs b/Assets/Fungus/Scripts/Components/Stage.cs index 69168cba..c34887e8 100644 --- a/Assets/Fungus/Scripts/Components/Stage.cs +++ b/Assets/Fungus/Scripts/Components/Stage.cs @@ -40,7 +40,7 @@ namespace Fungus protected List charactersOnStage = new List(); - static public List activeStages = new List(); + protected static List activeStages = new List(); protected virtual void OnEnable() { @@ -67,6 +67,11 @@ namespace Fungus #region Public members + /// + /// Gets the list of active stages. + /// + public static List ActiveStages { get { return activeStages; } } + /// /// Returns the currently active stage. /// diff --git a/Assets/Fungus/Scripts/Editor/BlockEditor.cs b/Assets/Fungus/Scripts/Editor/BlockEditor.cs index f834742c..5da11b69 100644 --- a/Assets/Fungus/Scripts/Editor/BlockEditor.cs +++ b/Assets/Fungus/Scripts/Editor/BlockEditor.cs @@ -407,7 +407,7 @@ namespace Fungus.EditorUtils PrefabUtility.RecordPrefabInstancePropertyModifications(block); } - static public void BlockField(SerializedProperty property, GUIContent label, GUIContent nullLabel, Flowchart flowchart) + public static void BlockField(SerializedProperty property, GUIContent label, GUIContent nullLabel, Flowchart flowchart) { if (flowchart == null) { @@ -445,7 +445,7 @@ namespace Fungus.EditorUtils property.objectReferenceValue = block; } - static public Block BlockField(Rect position, GUIContent nullLabel, Flowchart flowchart, Block block) + public static Block BlockField(Rect position, GUIContent nullLabel, Flowchart flowchart, Block block) { if (flowchart == null) { diff --git a/Assets/Fungus/Scripts/Editor/CommandEditor.cs b/Assets/Fungus/Scripts/Editor/CommandEditor.cs index 044eb225..4f9f43f1 100644 --- a/Assets/Fungus/Scripts/Editor/CommandEditor.cs +++ b/Assets/Fungus/Scripts/Editor/CommandEditor.cs @@ -156,7 +156,7 @@ namespace Fungus.EditorUtils } - static public void ObjectField(SerializedProperty property, GUIContent label, GUIContent nullLabel, List objectList) where T : Object + public static void ObjectField(SerializedProperty property, GUIContent label, GUIContent nullLabel, List objectList) where T : Object { if (property == null) { diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index 1f9bed6e..799c7295 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -84,7 +84,7 @@ namespace Fungus.EditorUtils Repaint(); } - static public Flowchart GetFlowchart() + public static Flowchart GetFlowchart() { // Using a temp hidden object to track the active Flowchart across // serialization / deserialization when playing the game in the editor. diff --git a/Assets/Fungus/Scripts/Editor/LabelEditor.cs b/Assets/Fungus/Scripts/Editor/LabelEditor.cs index cdfb0cb3..9ce82f87 100644 --- a/Assets/Fungus/Scripts/Editor/LabelEditor.cs +++ b/Assets/Fungus/Scripts/Editor/LabelEditor.cs @@ -13,7 +13,7 @@ namespace Fungus.EditorUtils { protected SerializedProperty keyProp; - static public void LabelField(SerializedProperty property, + public static void LabelField(SerializedProperty property, GUIContent labelText, Block block) { diff --git a/Assets/Fungus/Scripts/Editor/PortraitEditor.cs b/Assets/Fungus/Scripts/Editor/PortraitEditor.cs index de3d356f..7639c5ee 100644 --- a/Assets/Fungus/Scripts/Editor/PortraitEditor.cs +++ b/Assets/Fungus/Scripts/Editor/PortraitEditor.cs @@ -57,12 +57,12 @@ namespace Fungus.EditorUtils Portrait t = target as Portrait; - if (Stage.activeStages.Count > 1) + if (Stage.ActiveStages.Count > 1) { CommandEditor.ObjectField(stageProp, new GUIContent("Portrait Stage", "Stage to display the character portraits on"), new GUIContent(""), - Stage.activeStages); + Stage.ActiveStages); } else { @@ -78,14 +78,14 @@ namespace Fungus.EditorUtils CommandEditor.ObjectField(replacedCharacterProp, new GUIContent("Replace", "Character to replace"), new GUIContent(""), - Character.activeCharacters); + Character.ActiveCharacters); characterLabel = "With"; } CommandEditor.ObjectField(characterProp, new GUIContent(characterLabel, "Character to display"), new GUIContent(""), - Character.activeCharacters); + Character.ActiveCharacters); bool showOptionalFields = true; Stage s = t._Stage; diff --git a/Assets/Fungus/Scripts/Editor/SayEditor.cs b/Assets/Fungus/Scripts/Editor/SayEditor.cs index a6be0951..bd731df0 100644 --- a/Assets/Fungus/Scripts/Editor/SayEditor.cs +++ b/Assets/Fungus/Scripts/Editor/SayEditor.cs @@ -12,10 +12,10 @@ namespace Fungus.EditorUtils [CustomEditor (typeof(Say))] public class SayEditor : CommandEditor { - static public bool showTagHelp; + public static bool showTagHelp; public Texture2D blackTex; - static public void DrawTagHelpLabel() + public static void DrawTagHelpLabel() { string tagsText = TextTagParser.GetTagHelp(); @@ -121,7 +121,7 @@ namespace Fungus.EditorUtils CommandEditor.ObjectField(characterProp, new GUIContent("Character", "Character that is speaking"), new GUIContent(""), - Character.activeCharacters); + Character.ActiveCharacters); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(" "); diff --git a/Assets/Fungus/Scripts/Editor/StageEditor.cs b/Assets/Fungus/Scripts/Editor/StageEditor.cs index 3b5c52a5..18f158ff 100644 --- a/Assets/Fungus/Scripts/Editor/StageEditor.cs +++ b/Assets/Fungus/Scripts/Editor/StageEditor.cs @@ -47,16 +47,16 @@ namespace Fungus.EditorUtils CommandEditor.ObjectField(replacedStageProp, new GUIContent("Replace", "Character to swap with"), new GUIContent(""), - Stage.activeStages); + Stage.ActiveStages); replaceLabel = "With"; } - if (Stage.activeStages.Count > 0) + if (Stage.ActiveStages.Count > 0) { CommandEditor.ObjectField(stageProp, new GUIContent(replaceLabel, "Stage to display the character portraits on"), new GUIContent(""), - Stage.activeStages); + Stage.ActiveStages); } bool showOptionalFields = true; diff --git a/Assets/Fungus/Scripts/Editor/VariableEditor.cs b/Assets/Fungus/Scripts/Editor/VariableEditor.cs index af877d40..b7bbcd02 100644 --- a/Assets/Fungus/Scripts/Editor/VariableEditor.cs +++ b/Assets/Fungus/Scripts/Editor/VariableEditor.cs @@ -34,7 +34,7 @@ namespace Fungus.EditorUtils return null; } - static public void VariableField(SerializedProperty property, + public static void VariableField(SerializedProperty property, GUIContent label, Flowchart flowchart, string defaultText, diff --git a/Assets/Fungus/Scripts/Editor/WriteEditor.cs b/Assets/Fungus/Scripts/Editor/WriteEditor.cs index 00467edb..f00dd5cd 100644 --- a/Assets/Fungus/Scripts/Editor/WriteEditor.cs +++ b/Assets/Fungus/Scripts/Editor/WriteEditor.cs @@ -11,7 +11,7 @@ namespace Fungus.EditorUtils [CustomEditor (typeof(Write))] public class WriteEditor : CommandEditor { - static public bool showTagHelp; + public static bool showTagHelp; protected SerializedProperty textObjectProp; protected SerializedProperty textProp; @@ -22,7 +22,7 @@ namespace Fungus.EditorUtils protected SerializedProperty setColorProp; protected SerializedProperty waitUntilFinishedProp; - static public void DrawTagHelpLabel() + public static void DrawTagHelpLabel() { string tagsText = ""; tagsText += "\n"; diff --git a/Assets/Fungus/Scripts/EventHandlers/ButtonClicked.cs b/Assets/Fungus/Scripts/EventHandlers/ButtonClicked.cs index 10e99310..96d0f81c 100644 --- a/Assets/Fungus/Scripts/EventHandlers/ButtonClicked.cs +++ b/Assets/Fungus/Scripts/EventHandlers/ButtonClicked.cs @@ -17,7 +17,9 @@ namespace Fungus.EventHandlers { [Tooltip("The UI Button that the user can click on")] [SerializeField] protected Button targetButton; - + + #region Public members + public virtual void Start() { if (targetButton != null) @@ -40,5 +42,7 @@ namespace Fungus.EventHandlers return "None"; } + + #endregion } } diff --git a/Assets/Fungus/Scripts/EventHandlers/DragCancelled.cs b/Assets/Fungus/Scripts/EventHandlers/DragCancelled.cs index f10be139..4aec3cc8 100644 --- a/Assets/Fungus/Scripts/EventHandlers/DragCancelled.cs +++ b/Assets/Fungus/Scripts/EventHandlers/DragCancelled.cs @@ -16,7 +16,9 @@ namespace Fungus.EventHandlers { [Tooltip("Draggable object to listen for drag events on")] [SerializeField] protected Draggable2D draggableObject; - + + #region Public members + public virtual void OnDragCancelled(Draggable2D draggableObject) { if (draggableObject == this.draggableObject) @@ -34,5 +36,7 @@ namespace Fungus.EventHandlers return "None"; } + + #endregion } } diff --git a/Assets/Fungus/Scripts/EventHandlers/DragCompleted.cs b/Assets/Fungus/Scripts/EventHandlers/DragCompleted.cs index 9da02347..899f7f44 100644 --- a/Assets/Fungus/Scripts/EventHandlers/DragCompleted.cs +++ b/Assets/Fungus/Scripts/EventHandlers/DragCompleted.cs @@ -16,20 +16,32 @@ namespace Fungus.EventHandlers { [Tooltip("Draggable object to listen for drag events on")] [SerializeField] protected Draggable2D draggableObject; - public virtual Draggable2D DraggableObject { get { return draggableObject; } } [Tooltip("Drag target object to listen for drag events on")] [SerializeField] protected Collider2D targetObject; // There's no way to poll if an object is touching another object, so // we have to listen to the callbacks and track the touching state ourselves. - bool overTarget = false; - + protected bool overTarget = false; + + #region Public members + + /// + /// Gets the draggable object. + /// + public virtual Draggable2D DraggableObject { get { return draggableObject; } } + + /// + /// Returns true if the draggable object is over the drag target object. + /// public virtual bool IsOverTarget() { return overTarget; } - + + /// + /// Called by the Draggable2D object when the it enters the drag target. + /// public virtual void OnDragEntered(Draggable2D draggableObject, Collider2D targetObject) { if (this.targetObject != null && @@ -40,6 +52,9 @@ namespace Fungus.EventHandlers } } + /// + /// Called by the Draggable2D object when the it exits the drag target. + /// public virtual void OnDragExited(Draggable2D draggableObject, Collider2D targetObject) { if (this.targetObject != null && @@ -50,6 +65,9 @@ namespace Fungus.EventHandlers } } + /// + /// Called by the Draggable2D object when the the drag ends over the drag target. + /// public virtual void OnDragCompleted(Draggable2D draggableObject) { if (draggableObject == this.draggableObject && @@ -83,5 +101,7 @@ namespace Fungus.EventHandlers return summary; } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/EventHandlers/DragEntered.cs b/Assets/Fungus/Scripts/EventHandlers/DragEntered.cs index 9f293e06..31653053 100644 --- a/Assets/Fungus/Scripts/EventHandlers/DragEntered.cs +++ b/Assets/Fungus/Scripts/EventHandlers/DragEntered.cs @@ -23,6 +23,11 @@ namespace Fungus.EventHandlers [Tooltip("Drag target object to listen for drag events on")] [SerializeField] protected Collider2D targetObject; + #region Public members + + /// + /// Called by the Draggable2D object when the the drag enters the drag target. + /// public virtual void OnDragEntered(Draggable2D draggableObject, Collider2D targetObject) { if (draggableObject == this.draggableObject && @@ -51,5 +56,7 @@ namespace Fungus.EventHandlers return summary; } + + #endregion } } diff --git a/Assets/Fungus/Scripts/EventHandlers/DragExited.cs b/Assets/Fungus/Scripts/EventHandlers/DragExited.cs index e5f9cee7..d6a15b9d 100644 --- a/Assets/Fungus/Scripts/EventHandlers/DragExited.cs +++ b/Assets/Fungus/Scripts/EventHandlers/DragExited.cs @@ -23,6 +23,11 @@ namespace Fungus.EventHandlers [Tooltip("Drag target object to listen for drag events on")] [SerializeField] protected Collider2D targetObject; + #region Public members + + /// + /// Called by the Draggable2D object when the drag exits from the targetObject. + /// public virtual void OnDragExited(Draggable2D draggableObject, Collider2D targetObject) { if (draggableObject == this.draggableObject && @@ -51,5 +56,7 @@ namespace Fungus.EventHandlers return summary; } + + #endregion } } diff --git a/Assets/Fungus/Scripts/EventHandlers/DragStarted.cs b/Assets/Fungus/Scripts/EventHandlers/DragStarted.cs index 0fc7b53b..e35aecc3 100644 --- a/Assets/Fungus/Scripts/EventHandlers/DragStarted.cs +++ b/Assets/Fungus/Scripts/EventHandlers/DragStarted.cs @@ -16,6 +16,11 @@ namespace Fungus.EventHandlers { [SerializeField] protected Draggable2D draggableObject; + #region Public members + + /// + /// Called by the Draggable2D object when the drag starts. + /// public virtual void OnDragStarted(Draggable2D draggableObject) { if (draggableObject == this.draggableObject) @@ -33,5 +38,7 @@ namespace Fungus.EventHandlers return "None"; } + + #endregion } } diff --git a/Assets/Fungus/Scripts/EventHandlers/EndEdit.cs b/Assets/Fungus/Scripts/EventHandlers/EndEdit.cs index bb9fefee..8cfa076b 100644 --- a/Assets/Fungus/Scripts/EventHandlers/EndEdit.cs +++ b/Assets/Fungus/Scripts/EventHandlers/EndEdit.cs @@ -18,7 +18,7 @@ namespace Fungus.EventHandlers [Tooltip("The UI Input Field that the user can enter text into")] [SerializeField] protected InputField targetInputField; - public virtual void Start() + protected virtual void Start() { targetInputField.onEndEdit.AddListener(OnEndEdit); } @@ -28,6 +28,8 @@ namespace Fungus.EventHandlers ExecuteBlock(); } + #region Public methods + public override string GetSummary() { if (targetInputField != null) @@ -37,5 +39,7 @@ namespace Fungus.EventHandlers return "None"; } + + #endregion } } diff --git a/Assets/Fungus/Scripts/EventHandlers/KeyPressed.cs b/Assets/Fungus/Scripts/EventHandlers/KeyPressed.cs index 8d7269f5..cec8b7e5 100644 --- a/Assets/Fungus/Scripts/EventHandlers/KeyPressed.cs +++ b/Assets/Fungus/Scripts/EventHandlers/KeyPressed.cs @@ -58,9 +58,13 @@ namespace Fungus.EventHandlers } } + #region Public members + public override string GetSummary() { return keyCode.ToString(); } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/EventHandlers/MessageReceived.cs b/Assets/Fungus/Scripts/EventHandlers/MessageReceived.cs index 64eaafab..c6faad78 100644 --- a/Assets/Fungus/Scripts/EventHandlers/MessageReceived.cs +++ b/Assets/Fungus/Scripts/EventHandlers/MessageReceived.cs @@ -17,6 +17,12 @@ namespace Fungus.EventHandlers [Tooltip("Fungus message to listen for")] [SerializeField] protected string message = ""; + #region Public members + + /// + /// Called from Flowchart when a message is sent. + /// + /// Message. public void OnSendFungusMessage(string message) { if (this.message == message) @@ -29,5 +35,7 @@ namespace Fungus.EventHandlers { return message; } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs b/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs index 12481311..92eee8f6 100644 --- a/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs +++ b/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs @@ -16,7 +16,12 @@ namespace Fungus.EventHandlers { [Tooltip("Object that the user can click or tap on")] [SerializeField] protected Clickable2D clickableObject; - + + #region Public members + + /// + /// Called by the Clickable2D object when it is clicked. + /// public virtual void OnObjectClicked(Clickable2D clickableObject) { if (clickableObject == this.clickableObject) @@ -34,5 +39,7 @@ namespace Fungus.EventHandlers return "None"; } + + #endregion } } diff --git a/Assets/Fungus/Scripts/Utils/ConversationManager.cs b/Assets/Fungus/Scripts/Utils/ConversationManager.cs index 45eaef5c..619e2360 100644 --- a/Assets/Fungus/Scripts/Utils/ConversationManager.cs +++ b/Assets/Fungus/Scripts/Utils/ConversationManager.cs @@ -76,7 +76,7 @@ namespace Fungus.Utils return results.ToArray(); } - protected SayDialog GetSayDialog(Character character) + protected virtual SayDialog GetSayDialog(Character character) { SayDialog sayDialog = null; if (character != null) @@ -269,7 +269,7 @@ namespace Fungus.Utils /// /// Caches the character objects in the scene for fast lookup during conversations. /// - public void PopulateCharacterCache() + public virtual void PopulateCharacterCache() { // cache characters for faster lookup characters = UnityEngine.Object.FindObjectsOfType(); @@ -278,7 +278,7 @@ namespace Fungus.Utils /// /// Parse and execute a conversation string. /// - public IEnumerator DoConversation(string conv) + public virtual IEnumerator DoConversation(string conv) { if (string.IsNullOrEmpty(conv)) { diff --git a/Assets/Fungus/Scripts/Utils/FungusConstants.cs b/Assets/Fungus/Scripts/Utils/FungusConstants.cs index 0a98f3e5..75480ce3 100644 --- a/Assets/Fungus/Scripts/Utils/FungusConstants.cs +++ b/Assets/Fungus/Scripts/Utils/FungusConstants.cs @@ -8,6 +8,8 @@ namespace Fungus.Utils /// public static class FungusConstants { + #region Public members + /// /// Duration of fade for executing icon displayed beside blocks & commands. /// @@ -22,5 +24,7 @@ namespace Fungus.Utils /// The name of the initial block in a new flowchart. /// public const string DefaultBlockName = "New Block"; + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Utils/PortraitUtils.cs b/Assets/Fungus/Scripts/Utils/PortraitUtils.cs index 8c7b3995..a40d4d84 100644 --- a/Assets/Fungus/Scripts/Utils/PortraitUtils.cs +++ b/Assets/Fungus/Scripts/Utils/PortraitUtils.cs @@ -71,6 +71,8 @@ namespace Fungus.Utils /// public static class PortraitUtil { + #region Public members + /// /// Convert a Moonsharp table to portrait options /// If the table returns a null for any of the parameters, it should keep the defaults @@ -155,5 +157,7 @@ namespace Fungus.Utils return options; } + + #endregion } } diff --git a/Assets/Fungus/Scripts/Utils/StringFormatter.cs b/Assets/Fungus/Scripts/Utils/StringFormatter.cs index 94d34e3d..e7e1a202 100644 --- a/Assets/Fungus/Scripts/Utils/StringFormatter.cs +++ b/Assets/Fungus/Scripts/Utils/StringFormatter.cs @@ -11,6 +11,8 @@ namespace Fungus.Utils /// public static class StringFormatter { + #region Public members + public static string[] FormatEnumNames(Enum e, string firstLabel) { string[] enumLabels = Enum.GetNames(e.GetType()); @@ -56,5 +58,7 @@ namespace Fungus.Utils } return true; } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Utils/TextTagToken.cs b/Assets/Fungus/Scripts/Utils/TextTagToken.cs index 12c8e202..02370d05 100644 --- a/Assets/Fungus/Scripts/Utils/TextTagToken.cs +++ b/Assets/Fungus/Scripts/Utils/TextTagToken.cs @@ -73,6 +73,8 @@ namespace Fungus.Utils /// public class TextTagToken { + #region Public members + /// /// The type of the token. /// @@ -82,5 +84,7 @@ namespace Fungus.Utils /// List of comma separated parameters. /// public List paramList; + + #endregion } } \ No newline at end of file