Beispiel #1
0
 public void save(System.IO.BinaryWriter writer)
 {
     writer.Write((int)m_type);
     if (m_startroom != null)
     {
         writer.Write(true);
         GraphFlattenVisitor gfv = new GraphFlattenVisitor();
         m_graph.getVisited(gfv);
         int idx = gfv.Nodes.IndexOf(m_startroom);
         writer.Write(idx);
     }
     else
     {
         writer.Write(false);
     }
 }
Beispiel #2
0
        public void synchronize()
        {
            GraphFlattenVisitor gfv = new GraphFlattenVisitor();

            m_graph.getVisited(gfv);
            startingroom.Items.Clear();
            foreach (GraphNode node in gfv.Nodes)
            {
                startingroom.Items.Add(node);
            }
            startingroom.SelectedItem = m_startroom;
            if (m_startroom != null)
            {
                startingroom.Text = m_startroom.Name;
            }
        }
Beispiel #3
0
        public override object visit(RoomGraph graph)
        {
            //flatten the graph for further processing
            m_flatter = new GraphFlattenVisitor();
            m_graph.getVisited(m_flatter);

            //initialize tables
            m_cmd.CommandText = "CREATE TABLE characters (chid INTEGER PRIMARY KEY, name VARCHAR(50), curr_room INTEGER);";
            m_cmd.ExecuteNonQuery();

            m_cmd.CommandText = "CREATE TABLE rooms (rid INTEGER, chid INTEGER, name VARCHAR(50), PRIMARY KEY(rid,chid));";
            m_cmd.ExecuteNonQuery();

            m_cmd.CommandText = "CREATE TABLE room_connections (frm INTEGER, too INTEGER, chid INTEGER, type INTEGER(1), PRIMARY KEY (frm, too, chid));";
            m_cmd.ExecuteNonQuery();

            m_cmd.CommandText = "CREATE TABLE staticproperties (propid INTEGER PRIMARY KEY, rid INTEGER, objid INTEGER, property VARCHAR(50));";
            m_cmd.ExecuteNonQuery();

            m_cmd.CommandText = "CREATE TABLE properties (propid INTEGER, chid INTEGER, rid INTEGER, objid INTEGER, property VARCHAR(50), value INTEGER, PRIMARY KEY (propid, chid));";
            m_cmd.ExecuteNonQuery();

            m_cmd.CommandText = "CREATE TABLE responses (respid INTEGER PRIMARY KEY, propid INTEGER, value INTEGER, opcode INTEGER, argument1 TEXT, argument2 TEXT);";
            m_cmd.ExecuteNonQuery();

            //insert default character
            Room start = m_settings.StartRoom;

            if (start == null)
            {
                MessageBox.Show("Error: No starting room set!");
            }
            else
            {
                int idx = m_flatter.Nodes.IndexOf(start);
                m_cmd.CommandText = "INSERT INTO characters (chid, name, curr_room) VALUES (0, 'Default', " + idx + ");";
                m_cmd.ExecuteNonQuery();
            }

            //visit graph
            foreach (GraphNode node in graph.Roots)
            {
                node.getVisited(this);
            }
            return(null);
        }
        public override object visit(RoomGraph graph)
        {
            //flatten the graph for further processing
              m_flatter = new GraphFlattenVisitor();
              m_graph.getVisited(m_flatter);

              //initialize tables
              m_cmd.CommandText = "CREATE TABLE characters (chid INTEGER PRIMARY KEY, name VARCHAR(50), curr_room INTEGER);";
              m_cmd.ExecuteNonQuery();

              m_cmd.CommandText = "CREATE TABLE rooms (rid INTEGER, chid INTEGER, name VARCHAR(50), PRIMARY KEY(rid,chid));";
              m_cmd.ExecuteNonQuery();

              m_cmd.CommandText = "CREATE TABLE room_connections (frm INTEGER, too INTEGER, chid INTEGER, type INTEGER(1), PRIMARY KEY (frm, too, chid));";
              m_cmd.ExecuteNonQuery();

              m_cmd.CommandText = "CREATE TABLE staticproperties (propid INTEGER PRIMARY KEY, rid INTEGER, objid INTEGER, property VARCHAR(50));";
              m_cmd.ExecuteNonQuery();

              m_cmd.CommandText = "CREATE TABLE properties (propid INTEGER, chid INTEGER, rid INTEGER, objid INTEGER, property VARCHAR(50), value INTEGER, PRIMARY KEY (propid, chid));";
              m_cmd.ExecuteNonQuery();

              m_cmd.CommandText = "CREATE TABLE responses (respid INTEGER PRIMARY KEY, propid INTEGER, value INTEGER, opcode INTEGER, argument1 TEXT, argument2 TEXT);";
              m_cmd.ExecuteNonQuery();

              //insert default character
              Room start = m_settings.StartRoom;
              if (start == null)
            MessageBox.Show("Error: No starting room set!");
              else
              {
            int idx = m_flatter.Nodes.IndexOf(start);
            m_cmd.CommandText = "INSERT INTO characters (chid, name, curr_room) VALUES (0, 'Default', "+idx+");";
            m_cmd.ExecuteNonQuery();
              }

              //visit graph
              foreach (GraphNode node in graph.Roots)
              {
            node.getVisited(this);
              }
              return null;
        }
Beispiel #5
0
        public void save(BinaryWriter writer)
        {
            writer.Write((int)m_type);
            GraphFlattenVisitor gflv = new GraphFlattenVisitor();

            getVisited(gflv);
            writer.Write(gflv.Nodes.Count);
            foreach (GraphNode node in gflv.Nodes)
            {
                node.save(writer);
            }

            writer.Write(gflv.Edges.Count);
            foreach (GraphEdge edge in gflv.Edges)
            {
                edge.save(writer);
                int from = gflv.Nodes.IndexOf(edge.From);
                int to   = gflv.Nodes.IndexOf(edge.To);
                writer.Write(from);
                writer.Write(to);
            }
        }
 public void synchronize()
 {
     GraphFlattenVisitor gfv = new GraphFlattenVisitor();
       m_graph.getVisited(gfv);
       startingroom.Items.Clear();
       foreach (GraphNode node in gfv.Nodes)
       {
     startingroom.Items.Add(node);
       }
       startingroom.SelectedItem = m_startroom;
       if (m_startroom != null)
     startingroom.Text = m_startroom.Name;
 }
 public void save(System.IO.BinaryWriter writer)
 {
     writer.Write((int)m_type);
       if (m_startroom != null)
       {
     writer.Write(true);
     GraphFlattenVisitor gfv = new GraphFlattenVisitor();
     m_graph.getVisited(gfv);
     int idx = gfv.Nodes.IndexOf(m_startroom);
     writer.Write(idx);
       }
       else
     writer.Write(false);
 }
Beispiel #8
0
        public void save(BinaryWriter writer)
        {
            writer.Write((int)m_type);
              GraphFlattenVisitor gflv = new GraphFlattenVisitor();
              getVisited(gflv);
              writer.Write(gflv.Nodes.Count);
              foreach (GraphNode node in gflv.Nodes)
              {
            node.save(writer);
              }

              writer.Write(gflv.Edges.Count);
              foreach (GraphEdge edge in gflv.Edges)
              {
            edge.save(writer);
            int from = gflv.Nodes.IndexOf(edge.From);
            int to = gflv.Nodes.IndexOf(edge.To);
            writer.Write(from);
            writer.Write(to);
              }
        }