/// <summary>
 /// Select the out point of a dialog set
 /// </summary>
 /// <param name="_line">Content linked to the out point selected</param>
 private void SelectOutLine(DialogueLine _line)
 {
     if (m_outSelectedCondition != null)
     {
         m_outSelectedCondition = null;
     }
     if (m_outSelectedStart != null)
     {
         m_outSelectedStart = null;
     }
     m_outSelectedLine = _line;
     if (m_inSelectedNode != null && m_outSelectedLine != null)
     {
         LinkDialogSet();
     }
 }
 /// <summary>
 /// Select the out point of a condition
 /// </summary>
 /// <param name="_condition">Content linked to the out point selected</param>
 private void SelectOutCondition(DialogueCondition _condition, bool _valueCondition)
 {
     if (m_outSelectedLine != null)
     {
         m_outSelectedLine = null;
     }
     if (m_outSelectedStart != null)
     {
         m_outSelectedStart = null;
     }
     m_outSelectedCondition = _condition;
     m_outConditionValue    = _valueCondition;
     if (m_inSelectedNode != null && m_outSelectedCondition != null)
     {
         LinkDialogSet();
     }
 }
        private void SelectOutStarter(StarterPair _startingPair)
        {
            if (m_outSelectedCondition != null)
            {
                m_outSelectedCondition = null;
            }
            if (m_outSelectedLine != null)
            {
                m_outSelectedLine = null;
            }

            m_outSelectedStart = _startingPair;

            if (m_inSelectedNode != null && m_outSelectedStart != null)
            {
                LinkDialogSet();
            }
        }
        /// <summary>
        /// Process the EditorEvents according to the mouse button pressed
        /// </summary>
        /// <param name="_e">Current Event</param>
        private void ProcessEditorEvents(Event _e)
        {
            m_drag = Vector2.zero;
            switch (_e.type)
            {
            case EventType.MouseDown:
                if (_e.button == 1)
                {
                    if (m_inSelectedNode == null && (m_outSelectedLine != null || m_outSelectedCondition != null))
                    {
                        m_outSelectedLine      = null;
                        m_outSelectedCondition = null;
                        break;
                    }
                    ShowContextMenu(_e.mousePosition);
                }
                break;

            case EventType.MouseDrag:
                if (_e.button == 0 && (CurrentDialog != null && !CurrentDialog.AnyPartIsSelected))
                {
                    OnDrag(_e.delta);
                }
                break;

            case EventType.ScrollWheel:
                if (m_zoomScale == .25f && _e.delta.y > 0)
                {
                    break;
                }

                Vector2 screenCoordsMousePos = Event.current.mousePosition;
                Vector2 zoomCoordsMousePos   = ConvertScreenCoordsToZoomCoords(screenCoordsMousePos);
                float   _oldZoomScale        = m_zoomScale;
                m_zoomScale         = Mathf.Clamp(m_zoomScale - (_e.delta.y * .05f), .25f, 1.0f);
                m_zoomCoordOrigine += (zoomCoordsMousePos - m_zoomCoordOrigine) - (_oldZoomScale / m_zoomScale) * (zoomCoordsMousePos - m_zoomCoordOrigine);
                Repaint();
                break;

            default:
                break;
            }
        }
示例#5
0
        /// <summary>
        /// Display the dialog line of the dialog set at the selected index
        /// </summary>
        /// <param name="_set">Displayed Dialog Set</param>
        /// <returns></returns>
        private IEnumerator DisplayDialogueLineAtIndex(DialogueSet _set, int _index = 0)
        {
            m_onMouseClicked = null;
            // Get the dialog line at the _index in the _set
            DialogueLine _line = _set.DialogLines[_index];

            // Call the event
            OnDialogLineRead?.Invoke(_line.Key);
            // Change the color of the font if needed
            if (!DialoguesSettingsManager.DialogsSettings.OverrideCharacterColor)
            {
                if (DialoguesSettingsManager.DialogsSettings.CharactersColor.Any(c => c.CharacterIdentifier == _line.CharacterIdentifier))
                {
                    m_textDisplayer.color = DialoguesSettingsManager.DialogsSettings.CharactersColor.Where(c => c.CharacterIdentifier == _line.CharacterIdentifier).Select(c => c.CharacterColor).FirstOrDefault();
                }
                else
                {
                    m_textDisplayer.color = m_fontColor;
                }
            }
            else
            {
                m_textDisplayer.color = m_fontColor;
            }
            // Change the text of the text displayer
            m_textDisplayer.text = GetDialogueLineContent(_line.Key, DialoguesSettingsManager.DialogsSettings.CurrentLocalisationKey);
            // If there is an audiosource and the AudioClip Exists in the DialogsAssetsManager, play the audioclip in OneShot
            if (m_audioSource != null && DialogueAssetsManager.DialogLinesAudioClips.ContainsKey(_line.Key + "_" + DialoguesSettingsManager.DialogsSettings.CurrentAudioLocalisationKey))
            {
                AudioClip _c = DialogueAssetsManager.DialogLinesAudioClips[_line.Key + "_" + DialoguesSettingsManager.DialogsSettings.CurrentAudioLocalisationKey];

                m_audioSource.PlayOneShot(_c);
                yield return(new WaitForSeconds(_c.length + .05f));
            }
            else
            {
                yield return(new WaitForSeconds(_line.InitialWaitingTime));
            }

            // Increase Index
            _index++;
            //Check if we reach the end of the set and go to the next set
            if (_set.DialogLines.Count == _index && !_set.PlayRandomly)
            {
                _set   = m_dialog.GetNextSet(_line.LinkedToken);
                _index = 0;
            }
            else if (_set.PlayOnlyOneLine || (_set.PlayRandomly && _set.RemainingIndexesCount == 0))
            {
                _set   = m_dialog.GetNextSet(_set.DialogLines.Last().LinkedToken);
                _index = 0;
            }

            switch (_line.WaitingType)
            {
            case WaitingType.None:
                DisplayDialogueSet(_set, _index);
                break;

            case WaitingType.WaitForClick:
                m_onMouseClicked += () => DisplayDialogueSet(_set, _index);
                break;

            case WaitingType.WaitForTime:
                StartCoroutine(WaitBeforeDisplayDialogueSet(_set, _index, _line.ExtraWaitingTime));
                break;

            default:
                break;
            }
        }