示例#1
0
        private void addNpcButton_Click(object sender, EventArgs e)
        {
            Npc item = new Npc();
            item.Name = "Untitled";

            this.npcs.Add(item);
            this.npcListBox.Items.Add(item.Name);
        }
示例#2
0
        public static Npc Load(string filePath)
        {
            Npc npc = new Npc();

            using (FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate))
            {
                using (BinaryReader binaryReader = new BinaryReader(fs))
                {
                    npc.Name = binaryReader.ReadString();
                    npc.TextureNumber = binaryReader.ReadInt32();
                    npc.HP = binaryReader.ReadInt32();
                    npc.MP = binaryReader.ReadInt32();
                    npc.Strength = binaryReader.ReadInt32();
                }
            }

            return npc;
        }
示例#3
0
        private void LoadNpcs()
        {
            this.npcListBox.Items.Clear();

            this.npcs = new List<Npc>();

            DirectoryInfo dI = new DirectoryInfo(dataPath + "/Npcs/");

            foreach (var file in dI.GetFiles("*.dat", SearchOption.TopDirectoryOnly))
            {
                this.npcs.Add(Npc.Load(file.FullName));
                this.npcListBox.Items.Add(this.npcs[this.npcs.Count - 1].Name);
            }

            if (this.npcs.Count == 0)
            {
                Npc npc = new Npc();
                npc.Name = "Untitled";
                npc.TextureNumber = 0;
                this.npcs.Add(npc);
                this.npcListBox.Items.Add(npc.Name);
            }

            this.npcListBox.SelectedIndex = 0;

            this.selectedNpc = this.npcs[this.npcListBox.SelectedIndex];

            this.PopulateData();
        }
示例#4
0
        private void npcListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.npcListBox.SelectedIndex < 0 || this.npcListBox.SelectedIndex > this.npcs.Count)
                return;

            this.selectedNpc = this.npcs[this.npcListBox.SelectedIndex];

            this.PopulateData();
        }