public void BeDisengagedFromDialog()
 {
     // a disengaged customer becomes an EX_CUSTOMER
     // else "race conditions" may re-engage it and thwart expected behaviour
     gameObject.tag = "EX_CUSTOMER";
     this.partner   = null;
 }
예제 #2
0
 protected override void Awake()
 {
     base.Awake();
     UiElevator     = GetComponent <UiElevator>();
     DialogSystem   = GetComponentInChildren <IDialogSystem>();
     ButtonETrigger = GetComponentInChildren <UiButtonTriggerZone>();
 }
예제 #3
0
        /// <summary>
        /// Interrupt a dialog stack with a new dialog, following rules for sending interrupt and resume events.
        /// </summary>
        public static async Task InterruptAsync <T>(this IDialogSystem system, IDialogStack stack, IDialog <T> dialog, CancellationToken token)
        {
            if (!system.DialogTasks.Contains(stack))
            {
                throw new ArgumentOutOfRangeException(nameof(stack));
            }

            // send the interruption event
            system.Post(MakeEvent(new InterruptDialogEvent()));
            await system.PollAsync(token);

            var interrupter =
                // when the dialog is done
                dialog
                // task boundary: catch all exceptions
                .DefaultIfException()
                // task boundary: catch all events
                .WithEventIgnore();

            // Chain.PostToChain is two frames - yuck?
            if (stack.Frames.Count > 2)
            {
                // post the resume dialog event to the queue
                interrupter = interrupter.PostEvent(new ResumeDialogEvent());
            }

            // ignore/void the result, and then resume the interrupted wait
            var voided = interrupter.Void(stack);

            // start the interrupting dialog
            stack.Call(voided, null);
            // run the task until the next wait
            await system.PollAsync(token);
        }
 public bool BeEngagedInDialog(IDialogSystem partner)
 {
     // someone wants to talk to you. You may refuse or accept
     // this agent always accepts
     this.partner = partner;
     return(true);
 }
예제 #5
0
 public void DisengageFromDialog()
 {
     if (partner != null)
     {
         partner.BeDisengagedFromDialog();
     }
     partner = null;
 }
예제 #6
0
 public override void OnStart()
 {
     if (partner != null)
     {
         partnerDialogSystem = partner.GetComponent <IDialogSystem>();
     }
     base.OnStart();
 }
예제 #7
0
 public DialogWriting(IDialogSystem system,
                      TextMeshProUGUI sentence,
                      TextMeshProUGUI author) : base(system)
 {
     Builder      = new StringBuilder();
     AuthorText   = author;
     SentenceText = sentence;
 }
 public override void OnStart()
 {
     base.OnStart();
     dialogSystem = gameObject.GetComponent <IDialogSystem>();
     // first utter
     dialogSystem.SetUtterance(index);
     // then give partner time to answer
     elapsedTime = 0;
 }
예제 #9
0
 protected override void Awake()
 {
     base.Awake();
     DialogSystem   = GetComponentInChildren <IDialogSystem>();
     ButtonETrigger = GetComponentInChildren <UiButtonTriggerZone>();
     ButtonToggleOn.OnClick.Add(DialogSystem, ToggleElevator);
     ButtonToggleOff.OnClick.Add(DialogSystem, ToggleElevator);
     ButtonForgetIt.OnClick.Add(DialogSystem, DialogSystem.Hide);
 }
예제 #10
0
 protected override void Awake()
 {
     base.Awake();
     UiDoor         = GetComponent <UiDoor>();
     DialogSystem   = GetComponentInChildren <IDialogSystem>();
     ButtonETrigger = GetComponentInChildren <UiButtonTriggerZone>();
     ButtonOpenDoor.OnClick.Add(DialogSystem, UiDoor.OpenDoor);
     ButtonNevermind.OnClick.Add(DialogSystem, DialogSystem.Hide);
 }
 public bool EngageInDialog(IDialogSystem partner)
 {
     // you want to engage with someone. Use this method
     if (partner.BeEngagedInDialog(this))
     {
         this.partner = partner;
         return(true);
     }
     return(false); // returning false means partner has refused.
 }
예제 #12
0
        /// <summary>
        ///     Creates the button, assigns the necessary callbacks and texts.
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public DialogButton CreateButton(Transform parent, IDialogSystem dialog)
        {
            KeyText = " [" + BondedKey + "]";
            GameObject   goButton = Instantiate(PrefabButton, parent);
            DialogButton btn      = goButton.GetComponent <DialogButton>();

            btn.SetText(Text + KeyText);
            btn.SetKeyCode(BondedKey);
            btn.AddListener(OnClick[dialog].Invoke);
            return(btn);
        }
예제 #13
0
    public override void OnStart()
    {
        base.OnStart();

        dialogSystem = gameObject.GetComponent <IDialogSystem>();

        if (dialogSystem == null)
        {
            Debug.Log("No dialog system in Utter. Succeeding, anyway");
            elapsedTime = duration;
        }
        else
        {
            dialogSystem.SetUtterance(index);
            elapsedTime = 0;
        }
    }
예제 #14
0
 public override TaskStatus OnUpdate()
 {
     elapsedTime += Time.deltaTime;
     if (elapsedTime >= duration)
     {
         dialogSystem = gameObject.GetComponent <IDialogSystem>();
         if (dialogSystem.Tell(index, false))
         {
             return(TaskStatus.COMPLETED);
         }
         else
         {
             return(TaskStatus.FAILED);
         }
     }
     else
     {
         return(TaskStatus.RUNNING);
     }
 }
 public override TaskStatus OnUpdate()
 {
     elapsedTime += Time.deltaTime;
     if (elapsedTime >= duration)
     {
         dialogSystem = gameObject.GetComponent <IDialogSystem>();
         answer       = dialogSystem.Ask(index, false); // no need to utter now.
         if (answer != null)
         {
             return(TaskStatus.COMPLETED);
         }
         else
         {
             return(TaskStatus.FAILED);
         }
     }
     else
     {
         return(TaskStatus.RUNNING);
     }
 }
예제 #16
0
 /// <summary>
 /// Creates a new <see cref="NpcDialogHandler"/> instance.
 /// </summary>
 /// <param name="dialogSystem">Dialog system.</param>
 public NpcDialogHandler(IDialogSystem dialogSystem)
 {
     _dialogSystem = dialogSystem;
 }
예제 #17
0
 public bool BeEngagedInDialog(IDialogSystem partner)
 {
     // Anita is not supposed to be asked to engage. She'll take initiative.
     throw new System.NotImplementedException();
 }
 public override TaskStatus OnUpdate()
 {
     dialogSystem = gameObject.GetComponent <IDialogSystem>();
     dialogSystem.ClearUtterance();
     return(TaskStatus.COMPLETED);
 }
예제 #19
0
 public DialogSequence(IDialogSystem system) : base(system)
 {
 }
예제 #20
0
 public DialogAnimation(IDialogSystem system) : base(system)
 {
     ShowHash = Animator.StringToHash("Show");
     HideHash = Animator.StringToHash("Hide");
     Animator = DialogSystem.Monobehavior.GetComponentInChildren <Animator>();
 }
예제 #21
0
 /// <summary>
 ///     Sets the parent dialog;
 /// </summary>
 /// <param name="dialog"></param>
 public void SetDialog(IDialogSystem dialog)
 {
     Dialog = dialog;
 }
예제 #22
0
 protected DialogSubComponent(IDialogSystem system) => DialogSystem = system;