Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
0
 public void Execute()
 {
     _participant = _dialogue.AddParticipant("New participant");
     _partViewModel = new ParticipantViewModel(_cmdExec, _participant, _dialogue);
     _viewModel.participants.Add(_partViewModel);
 }