示例#1
0
        public override void OnEnter()
        {
            ChooseDialog dialog = SetChooseDialog.activeDialog;

            showBasicGUI = false;
            if (dialog == null)
            {
                showBasicGUI = true;
                return;
            }

            if (options.Count == 0)
            {
                Continue();
            }
            else
            {
                dialog.ShowDialog(true);
                dialog.SetCharacter(character);

                List <ChooseDialog.Option> dialogOptions = new List <ChooseDialog.Option>();
                foreach (Option option in options)
                {
                    ChooseDialog.Option dialogOption = new ChooseDialog.Option();
                    dialogOption.text = option.optionText;
                    Sequence onSelectSequence = option.targetSequence;

                    dialogOption.onSelect = delegate {
                        dialog.ShowDialog(false);

                        if (onSelectSequence == null)
                        {
                            Continue();
                        }
                        else
                        {
                            ExecuteSequence(onSelectSequence);
                        }
                    };

                    dialogOptions.Add(dialogOption);
                }

                options.Clear();

                if (voiceOverClip != null)
                {
                    MusicController.GetInstance().PlaySound(voiceOverClip, 1f);
                }

                dialog.Choose(chooseText, dialogOptions, timeoutDuration, delegate {
                    dialog.ShowDialog(false);
                    Continue();
                });
            }
        }
示例#2
0
        public override void OnEnter()
        {
            showBasicGUI = false;
            if (chooseDialog == null)
            {
                if (character != null)
                {
                    // Try to get game's default ChooseDialog
                    chooseDialog = GetFungusScript().defaultChoose;
                }

                if (chooseDialog == null)
                {
                    // Try to get any SayDialog in the scene
                    chooseDialog = GameObject.FindObjectOfType <ChooseDialog>();
                }

                if (chooseDialog == null)
                {
                    showBasicGUI = true;
                    return;
                }
            }

            if (options.Count == 0)
            {
                Continue();
            }
            else
            {
                FungusScript fungusScript = GetFungusScript();


                if (fadeIn)
                {
                    chooseDialog.FadeInDialog();
                }
                else
                {
                    chooseDialog.ShowDialog(true);
                }

                chooseDialog.SetCharacter(character, fungusScript);
                chooseDialog.SetCharacterImage(portrait);

                List <ChooseDialog.Option> dialogOptions = new List <ChooseDialog.Option>();
                foreach (Option option in options)
                {
                    ChooseDialog.Option dialogOption = new ChooseDialog.Option();

                    // Store these in local variables so they get closed over correctly by the delegate call
                    dialogOption.text = option.optionText;
                    dialogOption.text = fungusScript.SubstituteVariables(dialogOption.text);
                    Sequence onSelectSequence = option.targetSequence;
                    Action   optionAction     = option.action;

                    dialogOption.onSelect = delegate {
                        if (optionAction != null)
                        {
                            optionAction();
                        }

                        if (fadeOut)
                        {
                            chooseDialog.FadeOutDialog();
                        }
                        else
                        {
                            chooseDialog.ShowDialog(false);
                        }

                        if (onSelectSequence == null)
                        {
                            Continue();
                        }
                        else
                        {
                            ExecuteSequence(onSelectSequence);
                        }
                    };

                    dialogOptions.Add(dialogOption);
                }

                options.Clear();

                if (voiceOverClip != null)
                {
                    chooseDialog.PlayVoiceOver(voiceOverClip);
                }

                string subbedText = fungusScript.SubstituteVariables(chooseText);

                chooseDialog.Choose(subbedText, dialogOptions, timeoutDuration, delegate {
                    if (fadeOut)
                    {
                        chooseDialog.FadeOutDialog();
                    }
                    else
                    {
                        chooseDialog.ShowDialog(false);
                    }
                    Continue();
                });
            }
        }
示例#3
0
        public override void OnEnter()
        {
            if (chooseDialog == null)
            {
                if (chooseDialog == null)
                {
                    // Try to get any ChooseDialog in the scene
                    chooseDialog = GameObject.FindObjectOfType <ChooseDialog>();
                }
            }

            // Build list of Option commands
            End           endCommand = null;
            List <Option> options    = new List <Option>();

            for (int i = commandIndex + 1; i < parentSequence.commandList.Count; ++i)
            {
                Command command = parentSequence.commandList[i];

                // Check for closing End command
                if (command.GetType() == typeof(End) &&
                    command.indentLevel == indentLevel)
                {
                    endCommand = command as End;

                    // Jump to End if no dialog is set
                    if (chooseDialog == null)
                    {
                        Continue(endCommand.commandIndex + 1);
                        return;
                    }

                    break;
                }

                Option option = command as Option;
                if (option != null &&
                    option.indentLevel == indentLevel &&
                    !option.IsHidden())
                {
                    options.Add(command as Option);
                }
            }

            if (options.Count == 0)
            {
                Continue();
            }
            else
            {
                FungusScript fungusScript = GetFungusScript();

                chooseDialog.ShowDialog(true);
                chooseDialog.SetCharacter(character, fungusScript);
                chooseDialog.SetCharacterImage(portrait);

                List <ChooseDialog.Option> dialogOptions = new List <ChooseDialog.Option>();
                foreach (Option option in options)
                {
                    ChooseDialog.Option dialogOption = new ChooseDialog.Option();
                    dialogOption.text = fungusScript.SubstituteVariables(option.optionText);

                    Option theOption = option;                     // Needed to close over the option object in the delegate

                    dialogOption.onSelect = delegate {
                        chooseDialog.ShowDialog(false);
                        theOption.wasSelected = true;
                        Continue(theOption.commandIndex + 1);
                    };

                    dialogOptions.Add(dialogOption);
                }

                options.Clear();

                if (voiceOverClip != null)
                {
                    chooseDialog.PlayVoiceOver(voiceOverClip);
                }

                string subbedText = fungusScript.SubstituteVariables(chooseText);

                chooseDialog.Choose(subbedText, dialogOptions, timeoutDuration, delegate {
                    // Timeout will execute the commands listed immediately after the Choose Option command
                    chooseDialog.ShowDialog(false);
                    Continue();
                });
            }
        }
示例#4
0
        public override void OnEnter()
        {
            showBasicGUI = false;
            if (chooseDialog == null)
            {
                if (chooseDialog == null)
                {
                    // Try to get any ChooseDialog in the scene
                    chooseDialog = GameObject.FindObjectOfType<ChooseDialog>();
                }

                if (chooseDialog == null)
                {
                    showBasicGUI = true;
                    return;
                }
            }

            if (options.Count == 0)
            {
                Continue();
            }
            else
            {
                Flowchart flowchart = GetFlowchart();

                chooseDialog.ShowDialog(true);
                chooseDialog.SetCharacter(character, flowchart);
                chooseDialog.SetCharacterImage(portrait);

                List<ChooseDialog.Option> dialogOptions = new List<ChooseDialog.Option>();
                foreach (Option option in options)
                {
                    ChooseDialog.Option dialogOption = new ChooseDialog.Option();

                    // Store these in local variables so they get closed over correctly by the delegate call
                    dialogOption.text = option.optionText;
                    dialogOption.text = flowchart.SubstituteVariables(dialogOption.text);
                    Block onSelectBlock = option.targetBlock;
                    Action optionAction = option.action;

                    dialogOption.onSelect = delegate {

                        if (optionAction != null)
                        {
                            optionAction();
                        }

                        chooseDialog.ShowDialog(false);

                        if (onSelectBlock == null)
                        {
                            Continue ();
                        }
                        else
                        {
                            Stop();
                            onSelectBlock.Execute();
                        }
                    };

                    dialogOptions.Add(dialogOption);
                }

                options.Clear();

                if (voiceOverClip != null)
                {
                    chooseDialog.PlayVoiceOver(voiceOverClip);
                }

                string subbedText = flowchart.SubstituteVariables(chooseText);

                chooseDialog.Choose(subbedText, dialogOptions, timeoutDuration, delegate {
                    chooseDialog.ShowDialog(false);
                    Continue();
                });
            }
        }
示例#5
0
        public override void OnEnter()
        {
            showBasicGUI = false;
            if (chooseDialog == null)
            {
                if (chooseDialog == null)
                {
                    // Try to get any ChooseDialog in the scene
                    chooseDialog = GameObject.FindObjectOfType <ChooseDialog>();
                }

                if (chooseDialog == null)
                {
                    showBasicGUI = true;
                    return;
                }
            }

            if (options.Count == 0)
            {
                Continue();
            }
            else
            {
                Flowchart flowchart = GetFlowchart();

                chooseDialog.ShowDialog(true);
                chooseDialog.SetCharacter(character, flowchart);
                chooseDialog.SetCharacterImage(portrait);

                List <ChooseDialog.Option> dialogOptions = new List <ChooseDialog.Option>();
                foreach (Option option in options)
                {
                    ChooseDialog.Option dialogOption = new ChooseDialog.Option();

                    // Store these in local variables so they get closed over correctly by the delegate call
                    dialogOption.text = option.optionText;
                    dialogOption.text = flowchart.SubstituteVariables(dialogOption.text);
                    Block  onSelectBlock = option.targetBlock;
                    Action optionAction  = option.action;

                    dialogOption.onSelect = delegate {
                        if (optionAction != null)
                        {
                            optionAction();
                        }

                        chooseDialog.ShowDialog(false);

                        if (onSelectBlock == null)
                        {
                            Continue();
                        }
                        else
                        {
                            Stop();
                            onSelectBlock.Execute();
                        }
                    };

                    dialogOptions.Add(dialogOption);
                }

                options.Clear();

                if (voiceOverClip != null)
                {
                    chooseDialog.PlayVoiceOver(voiceOverClip);
                }

                string subbedText = flowchart.SubstituteVariables(chooseText);

                chooseDialog.Choose(subbedText, dialogOptions, timeoutDuration, delegate {
                    chooseDialog.ShowDialog(false);
                    Continue();
                });
            }
        }
示例#6
0
 public override void OnEnter()
 {
     activeDialog = chooseDialog;
     Continue();
 }
示例#7
0
		public override void OnEnter()
		{
			activeDialog = chooseDialog;
			Continue();
		}
示例#8
0
        public override void OnEnter()
        {
            if (chooseDialog == null)
            {
                if (chooseDialog == null)
                {
                    // Try to get any ChooseDialog in the scene
                    chooseDialog = GameObject.FindObjectOfType<ChooseDialog>();
                }
            }

            // Build list of Option commands
            End endCommand = null;
            List<Option> options = new List<Option>();
            for (int i = commandIndex + 1; i < parentSequence.commandList.Count; ++i)
            {
                Command command = parentSequence.commandList[i];

                // Check for closing End command
                if (command.GetType() == typeof(End) &&
                    command.indentLevel == indentLevel)
                {
                    endCommand = command as End;

                    // Jump to End if no dialog is set
                    if (chooseDialog == null)
                    {
                        Continue (endCommand.commandIndex + 1);
                        return;
                    }

                    break;
                }

                Option option = command as Option;
                if (option != null &&
                    option.indentLevel == indentLevel &&
                    !option.IsHidden())
                {
                    options.Add(command as Option);
                }
            }

            if (options.Count == 0)
            {
                Continue();
            }
            else
            {
                FungusScript fungusScript = GetFungusScript();

                chooseDialog.ShowDialog(true);
                chooseDialog.SetCharacter(character, fungusScript);
                chooseDialog.SetCharacterImage(portrait);

                List<ChooseDialog.Option> dialogOptions = new List<ChooseDialog.Option>();
                foreach (Option option in options)
                {
                    ChooseDialog.Option dialogOption = new ChooseDialog.Option();
                    dialogOption.text = fungusScript.SubstituteVariables(option.optionText);

                    Option theOption = option; // Needed to close over the option object in the delegate

                    dialogOption.onSelect = delegate {
                        chooseDialog.ShowDialog(false);
                        theOption.wasSelected = true;
                        Continue(theOption.commandIndex + 1);
                    };

                    dialogOptions.Add(dialogOption);
                }

                options.Clear();

                if (voiceOverClip != null)
                {
                    chooseDialog.PlayVoiceOver(voiceOverClip);
                }

                string subbedText = fungusScript.SubstituteVariables(chooseText);

                chooseDialog.Choose(subbedText, dialogOptions, timeoutDuration, delegate {
                    // Timeout will execute the commands listed immediately after the Choose Option command
                    chooseDialog.ShowDialog(false);
                    Continue();
                });
            }
        }
示例#9
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            Choose       t  = target as Choose;
            ChooseDialog cd = t.chooseDialog;

            if (t.chooseDialog == null)                       // If default box selected
            {
                cd = t.GetFungusScript().defaultChoose;       // Try to get character's default choose dialog box
                if (cd == null)                               // If no default specified, Try to get any ChooseDialog in the scene
                {
                    cd = GameObject.FindObjectOfType <ChooseDialog>();
                }
            }
            CommandEditor.ObjectField <ChooseDialog>(chooseDialogProp,
                                                     new GUIContent("Choose Dialog", "Choose Dialog object to use to display the multiple player choices"),
                                                     new GUIContent("<Default>"),
                                                     ChooseDialog.activeDialogs);
            if (cd != null && cd.nameText != null)
            {
                CommandEditor.ObjectField <Character>(characterProp,
                                                      new GUIContent("Character", "Character to display in dialog"),
                                                      new GUIContent("<None>"),
                                                      Character.activeCharacters);
            }
            else
            {
                t.character = null;
            }

            bool showPortraits = false;

            // Only show portrait selection if...
            if (t.character != null &&                            // Character is selected
                t.character.portraits != null &&                  // Character has a portraits field
                t.character.portraits.Count > 0)                  // Selected Character has at least 1 portrait
            {
                if (cd != null && cd.characterImage != null)      // Check that selected choose dialog has a character image
                {
                    showPortraits = true;
                }
            }
            if (showPortraits)
            {
                CommandEditor.ObjectField <Sprite>(portraitProp,
                                                   new GUIContent("Portrait", "Portrait representing speaking character"),
                                                   new GUIContent("<None>"),
                                                   t.character.portraits);
            }
            else
            {
                t.portrait = null;
            }

            EditorGUILayout.PropertyField(chooseTextProp);

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
            {
                showTagHelp = !showTagHelp;
            }
            EditorGUILayout.EndHorizontal();

            if (showTagHelp)
            {
                SayEditor.DrawTagHelpLabel();
            }

            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(voiceOverClipProp, new GUIContent("Voice Over Clip", "Voice over audio to play when the choose text is displayed"));

            EditorGUILayout.PropertyField(timeoutDurationProp, new GUIContent("Timeout Duration", "Time limit for player to make a choice. Set to 0 for no limit."));

            EditorGUILayout.PropertyField(fadeInProp);

            EditorGUILayout.PropertyField(fadeOutProp);

            if (showPortraits && t.portrait != null)
            {
                Texture2D characterTexture = t.portrait.texture;

                float aspect = (float)characterTexture.width / (float)characterTexture.height;

                Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));

                CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor;
                characterEditor.DrawPreview(previewRect, characterTexture);
                DestroyImmediate(characterEditor);
            }

            serializedObject.ApplyModifiedProperties();
        }