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; }
protected override void Awake() { base.Awake(); UiElevator = GetComponent <UiElevator>(); DialogSystem = GetComponentInChildren <IDialogSystem>(); ButtonETrigger = GetComponentInChildren <UiButtonTriggerZone>(); }
/// <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); }
public void DisengageFromDialog() { if (partner != null) { partner.BeDisengagedFromDialog(); } partner = null; }
public override void OnStart() { if (partner != null) { partnerDialogSystem = partner.GetComponent <IDialogSystem>(); } base.OnStart(); }
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; }
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); }
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. }
/// <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); }
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; } }
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); } }
/// <summary> /// Creates a new <see cref="NpcDialogHandler"/> instance. /// </summary> /// <param name="dialogSystem">Dialog system.</param> public NpcDialogHandler(IDialogSystem dialogSystem) { _dialogSystem = dialogSystem; }
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); }
public DialogSequence(IDialogSystem system) : base(system) { }
public DialogAnimation(IDialogSystem system) : base(system) { ShowHash = Animator.StringToHash("Show"); HideHash = Animator.StringToHash("Hide"); Animator = DialogSystem.Monobehavior.GetComponentInChildren <Animator>(); }
/// <summary> /// Sets the parent dialog; /// </summary> /// <param name="dialog"></param> public void SetDialog(IDialogSystem dialog) { Dialog = dialog; }
protected DialogSubComponent(IDialogSystem system) => DialogSystem = system;