Example #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();
				});
			}
		}
Example #2
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();
                });
            }
        }
Example #3
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();
                });
            }
        }
Example #4
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();
                });
            }
        }
Example #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();
                });
            }
        }
        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();
                });
            }
        }
Example #7
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();
                });
            }
        }