Exemplo n.º 1
0
        static void InitNPCs(string dataDir)
        {
            string filename = dataDir + "NPCs.txt";

            s_npcNameIDs = new Dictionary <ushort, NPCNameID>();

            try
            {
                FileStream   fs = File.OpenRead(filename);
                StreamReader sr = new StreamReader(fs);

                string line = sr.ReadLine();
                while (line != null)
                {
                    string[]  pieces = line.Split(',');
                    ushort    id     = Convert.ToUInt16(pieces[0]);
                    NPCNameID name   = new NPCNameID(pieces[1], id);
                    s_npcNameIDs[id] = name;

                    line = sr.ReadLine();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to read " + filename + "\n" + ex.ToString());
            }
        }
Exemplo n.º 2
0
 private void cbGameID_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_currentSelection != null)
     {
         NPCNameID nameID = (NPCNameID)cbGameID.SelectedItem;
         NPC       npc    = (NPC)_currentSelection.Tag;
         npc.GameID             = nameID.ID;
         _currentSelection.Text = npc.ID.ToString() + ": " + nameID.ToString();
         npc.Dirty = true;
     }
 }
Exemplo n.º 3
0
        void AddQuest(Quest q)
        {
            ListViewItem lvi = lvQuests.Items.Add(q.ID.ToString());

            lvi.SubItems.Add(q.Name);
            if (_npcs.ContainsKey(q.GiverID))
            {
                NPC       giver     = _npcs[q.GiverID];
                NPCNameID giverName = Program.s_npcNameIDs[giver.GameID];
                lvi.SubItems.Add(giver.ID.ToString() + ": " + giverName.ToString());
            }
            else
            {
                lvi.SubItems.Add(q.GiverID.ToString());
            }
            lvi.SubItems.Add(q.GiverMapID.ToString());
            lvi.Tag = q;
        }
Exemplo n.º 4
0
        void AddNPC(NPC npc)
        {
            // Add npc to the list
            NPCNameID    nameID = Program.s_npcNameIDs[npc.GameID];
            ListViewItem lvi    = lvNPCs.Items.Add(npc.ID.ToString() + ": " + nameID.ToString());

            lvi.Tag = npc;

            // Add npc to the map
            PictureBox pb = new PictureBox();

            SetMapMarkerRed(pb, npc);
            _mapMarkers.Add(pb);
            Controls.Add(pb);
            pb.BringToFront();
            pb.Tag         = lvi;
            pb.MouseClick += Pb_MouseClick;
            pb.MouseMove  += Pb_MouseMove;
        }
Exemplo n.º 5
0
        void SelectNPC(ListViewItem lvi)
        {
            // Revert selected map marker
            if (_currentSelection != null)
            {
                PictureBox pb = FindPictureBox(_currentSelection);
                SetMapMarkerRed(pb, (NPC)_currentSelection.Tag);
            }

            _currentSelection = lvi;
            if (lvi != null)
            {
                // Set the NPC info
                NPC       npc    = (NPC)lvi.Tag;
                NPCNameID nameID = Program.s_npcNameIDs[npc.GameID];
                cbGameID.SelectedItem = nameID;
                tbHP.Text             = npc.HP.ToString();
                tbX.Text         = npc.X.ToString();
                tbY.Text         = npc.Y.ToString();
                tbDirection.Text = npc.Direction.ToString();

                // Change the map marker box color and size
                PictureBox pb = FindPictureBox(lvi);
                SetMapMarkerGreen(pb, npc);

                lvNPCs.Focus();
            }
            else
            {
                cbGameID.SelectedIndex = -1;
                tbHP.Text        = "";
                tbX.Text         = "";
                tbY.Text         = "";
                tbDirection.Text = "";
            }
        }
Exemplo n.º 6
0
        static void InitNPCs(string dataDir)
        {
            string filename = dataDir + "NPCs.txt";
            s_npcNameIDs = new Dictionary<ushort, NPCNameID>();

            try
            {
                FileStream fs = File.OpenRead(filename);
                StreamReader sr = new StreamReader(fs);

                string line = sr.ReadLine();
                while (line != null)
                {
                    string[] pieces = line.Split(',');
                    ushort id = Convert.ToUInt16(pieces[0]);
                    NPCNameID name = new NPCNameID(pieces[1], id);
                    s_npcNameIDs[id] = name;

                    line = sr.ReadLine();
                }

            }
            catch (Exception ex)
            {
                throw new Exception("Failed to read " + filename + "\n" + ex.ToString());
            }
        }