Exemple #1
0
 public void Connect(Room source, AutomapDirection directionFromSource, Room target)
 {
     try { m_control.Invoke((MethodInvoker) delegate { m_canvas.Connect(source, directionFromSource, target); }); }
     catch (Exception)
     {
     }
 }
Exemple #2
0
 public void Connect(Room source, MappableDirection directionFromSource, Room target, bool assumeTwoWayConnections)
 {
     try { mControl.Invoke((MethodInvoker) delegate { mCanvas.Connect(source, directionFromSource, target, assumeTwoWayConnections); }); }
     catch (Exception) {
         // ignored
     }
 }
Exemple #3
0
        private async Task ProcessTranscriptText(List <string> lines)
        {
            string previousLine = null;

            for (var index = 0; index < lines.Count; ++index)
            {
                var    line = lines[index];
                string roomName;
                if (ExtractRoomName(line, previousLine, out roomName))
                {
                    string roomDescription;
                    ExtractParagraph(lines, index + 1, out roomDescription);

                    // work out which room the transcript is referring to here, asking them if necessary
                    var room = FindRoom(roomName, roomDescription);
                    if (room == null)
                    {
                        // new room
                        if (m_lastKnownRoom != null && m_lastMoveDirection != null)
                        {
                            // player moved to new room
                            // if not added already, add room to map; and join it up to the previous one
                            room = m_canvas.CreateRoom(m_lastKnownRoom, m_lastMoveDirection.Value, roomName);
                            m_canvas.Connect(m_lastKnownRoom, m_lastMoveDirection.Value, room);
                            Trace("{0}: {1} is now {2} from {3}.", FormatTranscriptLineForDisplay(line), roomName, m_lastMoveDirection.Value.ToString().ToLower(), m_lastKnownRoom.Name);
                        }
                        else
                        {
                            // player teleported to new room;
                            // don't connect it up, as we don't know how they got there
                            room = m_canvas.CreateRoom(m_lastKnownRoom, roomName);
                            Trace("{0}: teleported to new room, {1}.", FormatTranscriptLineForDisplay(line), roomName);
                        }

                        DeduceExitsFromDescription(room, roomDescription);
                        NowInRoom(room);
                        await WaitForStep();
                    }
                    else if (room != m_lastKnownRoom)
                    {
                        // player moved to existing room
                        if (m_lastKnownRoom != null && m_lastMoveDirection != null)
                        {
                            // player moved sensibly; ensure rooms are connected up
                            m_canvas.Connect(m_lastKnownRoom, m_lastMoveDirection.Value, room);
                            Trace("{0}: {1} is now {2} from {3}.", FormatTranscriptLineForDisplay(line), roomName, m_lastMoveDirection.Value.ToString().ToLower(), m_lastKnownRoom.Name);
                        }
                        else
                        {
                            // player teleported; do nothing.
                        }

                        NowInRoom(room);
                        await WaitForStep();
                    }
                    else
                    {
                        // player didn't change rooms
                        Trace("{0}: still in {1}.", FormatTranscriptLineForDisplay(line), m_lastKnownRoom.Name);
                    }

                    // add this description if the room doesn't have it already
                    room.AddDescription(roomDescription);

                    // now forget the last movement direction we saw.
                    // we'll still place any rooms we see before we see a movement direction,
                    // but we won't join them up to this room.
                    // we might end up caring if, for example, the user gives multiple commands at one prompt,
                    // or they're moved to one room and then teleported to another.
                    m_lastMoveDirection = null;
                }
                else
                {
                    Trace("{0}: {1}{2}{3}", FormatTranscriptLineForDisplay(line), HaveFailureReason() ? "not a room name because " : string.Empty, GetFailureReason(), HaveFailureReason() ? "." : string.Empty);
                }
                previousLine = line;
            }
        }