示例#1
0
        public bool Close(GameObject dialog)
        {
            if (dialog == null)
            {
                return(false);
            }
            OpenDialogEventArgs arg = _dialogs.FirstOrDefault(a => a.DialogObject == dialog);

            if (arg == null || !_dialogs.Remove(arg))
            {
                return(false);
            }

            bool openDialogs = _dialogs.Count > 0;

            arg.ViewComponent?.OnClose();
            (arg.ViewComponent as IDisposable)?.Dispose();
            Destroy(dialog);
            gameObject.SetActive(openDialogs);
            dialog = null;
            if (openDialogs)
            {
                Blocker?.transform.SetSiblingIndex(_dialogs.Count - 1);
            }
            OnCloseDialog?.Invoke(this, new CloseDialogEventArgs(arg.DialogID));
            return(true);
        }
示例#2
0
        public override void Close()
        {
            if (OnCloseDialog != null)
            {
                OnCloseDialog.Invoke();
            }

            base.Close();
        }
示例#3
0
    private void CompleteDialog()
    {
        //OnGameOver?.Invoke(0.75f);

        if (twn.IsPlaying())
        {
            twn.Pause();

            OnCloseDialog?.Invoke(0.75f);
        }
    }
示例#4
0
    //
    // Public Methods
    //

    public void CloseDialog(DialogAction action)
    {
        DialogResult result = new DialogResult()
        {
            action = action
        };

        OnCloseDialog?.Invoke(result);

        if (result.shouldClose)
        {
            Close();
        }
    }
示例#5
0
 public void HandleUpdate()
 {
     if (Input.GetKeyDown(KeyCode.Space) && !isTyping)
     {
         ++currentLine;
         if (currentLine < dialog.Lines.Count)
         {
             StartCoroutine(TypeDialog(dialog.Lines[currentLine]));
         }
         else
         {
             currentLine = 0;
             dialogBox.SetActive(false);
             OnCloseDialog?.Invoke();
         }
     }
 }
示例#6
0
 public void HandleUpdate()
 {
     if (Input.GetKeyDown(KeyCode.Z) && !isTyping)
     {
         ++currentline;
         if (currentline < dialog.Lines.Count)
         {
             StartCoroutine(TypeDialog(dialog.Lines[currentline]));
         }
         else
         {
             currentline = 0;
             IsShowing   = false;
             dialogbox.SetActive(false);
             OnDialogFinished?.Invoke();
             OnCloseDialog?.Invoke();
         }
     }
 }
示例#7
0
 public void HandleUpdate()
 {
     if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return))
     {
         if (!isTyping)
         {
             ++currentLine;                                             //increase the number of thel line we show
             if (currentLine < dialog.Lines.Count)                      //If there still is some lines to show
             {
                 StartCoroutine(TypeDialog(dialog.Lines[currentLine])); //Write the current line
             }
             else //If there is no more lines to show, we close the dialog
             {
                 currentLine = 0;            //Set back to 0, so the next dialog will start from 0
                 IsShowing   = false;
                 dialogBox.SetActive(false); //Deactivate the dialog box
                 onDialogFinished?.Invoke();
                 OnCloseDialog?.Invoke();    //Call the close dialog action, to change back the gameState
             }
         }
     }
 }
示例#8
0
 public override void Close()
 {
     OnCloseDialog?.Invoke();
     base.Close();
 }