protected override void RegisterControllerEvent(EventDialogueController controller) { var image = GetComponent <Image>(); controller.RegisterSpecialClipEnterAction(MaskTool.ChangeBackground, clip => { gameObject.SetActive(true); image.sprite = (Sprite)clip.GetDialogueObjectByMaskBit(MaskTool.ChangeBackground); }); gameObject.SetActive(false); }
protected override void RegisterControllerEvent(EventDialogueController controller) { var btn = GetComponent <Button>(); var isEnd = false; controller.RegisterSpecialClipEnterAction(MaskTool.BranchClip, (clip) => { btn.interactable = false; }); controller.RegisterSpecialClipEndAction(MaskTool.BranchClip, (clip) => { btn.interactable = true; }); controller.RegisterSpecialClipEnterAction(MaskTool.DialogueEndClip, (clip) => { isEnd = true; }); controller.RegisterSpecialClipEndAction(MaskTool.DialogueEndClip, (clip) => { isEnd = false; }); btn.onClick.AddListener(() => { if (isEnd) { controller.ClipSwitchTo(-1); } else { controller.ShowNextClip(); } }); }
protected override void RegisterControllerEvent(EventDialogueController controller) { var audioSource = GetComponent <AudioSource>(); controller.RegisterSpecialClipEnterAction(MaskTool.ChangeBGM, clip => { audioSource.clip = (AudioClip)clip.GetDialogueObjectByMaskBit(MaskTool.ChangeBGM); audioSource.Play(); }); controller.OnDialogueEndEvent += (dialogue) => { audioSource.Stop(); }; }
protected override void RegisterControllerEvent(EventDialogueController controller) { /// 用于显示对白片段的内容 var txt = GetComponent <Text>(); controller.OnDialogueClipEnterEvent += (clip) => { txt.text = clip.clipContext; }; controller.RegisterSpecialClipEnterAction(MaskTool.BranchClip, (clip) => { txt.text = clip.clipContext.Split('*')[0]; }); }
protected override void RegisterControllerEvent(EventDialogueController controller) { var but1 = transform.GetChild(0).GetComponent <Button>(); var txt1 = transform.GetChild(0).GetComponentInChildren <Text>(); var but2 = transform.GetChild(1).GetComponent <Button>(); var txt2 = transform.GetChild(1).GetComponentInChildren <Text>(); /// 通过闭包来改变nextClip的值 /// 从而达到通过监听SpecialClipEnter事件改变切换的下一个片段号的作用 int nextClip1 = 0; int nextClip2 = 0; but1.onClick.AddListener(() => { controller.ClipSwitchTo(nextClip1); }); but2.onClick.AddListener(() => { controller.ClipSwitchTo(nextClip2); }); controller.RegisterSpecialClipEnterAction(MaskTool.BranchClip, (clip) => { gameObject.SetActive(true); try { var parts = clip.clipContext.Split('*').Where(str => !string.IsNullOrEmpty(str)).Skip(1).ToArray(); var branchInfo1 = parts[0].Split(' '); var branchInfo2 = parts[1].Split(' '); nextClip1 = int.Parse(branchInfo1[0]); nextClip2 = int.Parse(branchInfo2[0]); txt1.text = branchInfo1[1]; txt2.text = branchInfo2[1]; } catch { throw new System.Exception("clip.clipContext{" + clip.clipContext + "}内容与格式不同"); } }); controller.RegisterSpecialClipEndAction(MaskTool.BranchClip, clip => { gameObject.SetActive(false); }); gameObject.SetActive(false); }