Exemple #1
0
        public NodeViewModel CreateNode(string name, Point nodeLocation)
        {
            var node = new NodeViewModel(_cmdExec, _currentDlg.AddEntry(_currentDlg.Participant(0), name), _currentDlg, Network)
            {
                X = nodeLocation.X,
                Y = nodeLocation.Y
            };

            Network.Nodes.Add(node);

            return(node);
        }
Exemple #2
0
        public NetworkViewModel(CommandExecutor cmdExe, Dialogue dialogue)
        {
            _dialogue = dialogue;
            _cmdExec = cmdExe;

            if (_dialogue == null)
            {
                Debug.Assert(false);
                return;
            }

            var entryToModel = new Dictionary<DialogueEntry, NodeViewModel>();

            for (int i = 0; i < _dialogue.NumEntries; ++i)
            {
                DialogueEntry entry = _dialogue.Entry(i);
                if (entry != null)
                {
                    var model = new NodeViewModel(cmdExe, entry, _dialogue, this);
                    Nodes.Add(model);

                    entryToModel.Add(entry, model);
                }
            }

            for (int i = 0; i < _dialogue.NumChoices; ++i)
            {
                DialogueChoice choice = _dialogue.Choice(i);
                if (choice != null)
                {
                    var connection = new ConnectionViewModel(cmdExe, choice);
                    Connections.Add(connection);

                    if (choice.SourceEntry != null && choice.DestinationEntry != null)
                    {
                        NodeViewModel srcNode = entryToModel[choice.SourceEntry];
                        foreach (ConnectorViewModel connector in srcNode.OutgoingConnectors)
                        {
                            if (connector.DialogueChoice.Equals(choice))
                            {
                                connection.SourceConnector = connector;
                                break;
                            }
                        }

                        NodeViewModel dstNode = entryToModel[choice.DestinationEntry];
                        connection.DestConnector = dstNode.IncomingConnector;
                    }
                }
            }

            for (int i = 0; i < _dialogue.NumParticipants; ++i)
            {
                Participant participant = _dialogue.Participant(i);
                if (participant != null)
                {
                    var model = new ParticipantViewModel(cmdExe, participant, _dialogue);
                    Participants.Add(model);
                }
            }
        }