/// <summary> /// Link two dialog sets /// </summary> private void LinkDialogSet() { if (m_outSelectedCondition != null) { if (m_outConditionValue) { m_outSelectedCondition.LinkedTokenTrue = m_inSelectedNode.NodeToken; } else { m_outSelectedCondition.LinkedTokenFalse = m_inSelectedNode.NodeToken; } } else if (m_outSelectedLine != null) { m_outSelectedLine.LinkedToken = m_inSelectedNode.NodeToken; } else if (m_outSelectedStart != null) { m_outSelectedStart.LinkedToken = m_inSelectedNode.NodeToken; } m_inSelectedNode = null; m_outSelectedLine = null; m_outSelectedCondition = null; m_outSelectedStart = null; }
/// <summary> /// Remove the condition /// </summary> /// <param name="_condition"></param> private void RemoveCondition(DialogueCondition _condition) { if (m_dialogConditions.Contains(_condition)) { m_dialogConditions.Remove(_condition); } }
/// <summary> /// Get the Next set of the dialog according to the next token /// </summary> /// <param name="_nextToken">Token of the next Dialog Set</param> /// <returns></returns> public DialogueSet GetNextSet(int _nextToken) { if (m_dialogConditions.Any(c => c.NodeToken == _nextToken)) { DialogueCondition _condition = m_dialogConditions.Where(c => c.NodeToken == _nextToken).FirstOrDefault(); if (_condition == null) { return(null); } int _conditionToken = CheckCondition(_condition.Condition) ? _condition.LinkedTokenTrue : _condition.LinkedTokenFalse; return(GetNextSet(_conditionToken)); } return(m_dialogSets.Where(s => s.NodeToken == _nextToken).FirstOrDefault()); }
/// <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; } }
/// <summary> /// Process the events of the Dialog /// </summary> /// <param name="_e">Current Event</param> /// <returns></returns> public bool ProcessEvent(Event _e) { if (m_dialogSets.Any(p => p.IsSelected) && _e.keyCode == KeyCode.Delete) { DialogueSet _selectedPart = m_dialogSets.Where(p => p.IsSelected).FirstOrDefault(); m_dialogSets.Remove(_selectedPart); return(true); } if (m_dialogConditions.Any(c => c.IsSelected) && _e.keyCode == KeyCode.Delete) { DialogueCondition _selectedCondition = m_dialogConditions.Where(c => c.IsSelected).FirstOrDefault(); m_dialogConditions.Remove(_selectedCondition); return(true); } if (_e.type == EventType.KeyDown && _e.control && _e.keyCode == KeyCode.S) { SaveDialog(); } return(false); }