コード例 #1
0
        public static void load()
        {
            if (!File.Exists(misc.getServerPath() + @"\data\npcDrops.xml"))
            {
                Console.WriteLine(@"Missing data\npcDrops.xml");
                return;
            }
            try {
                //Deserialize text file to a new object.
                StreamReader   objStreamReader = new StreamReader(misc.getServerPath() + @"\data\npcDrops.xml");
                XmlSerializer  serializer      = new XmlSerializer(typeof(List <NpcDrop>));
                List <NpcDrop> list            = (List <NpcDrop>)serializer.Deserialize(objStreamReader);

                int p = 0;
                foreach (NpcDrop drop in list)
                {
                    for (int i = 0; i < drop.npcs.Length; i++)
                    {
                        NpcData.forId(drop.npcs[i]).setDrop(drop);
                    }
                    p++;
                }
                Console.WriteLine("Loaded " + p + " npc drops.");
            }
            catch (Exception e)
            {
                misc.WriteError((e.InnerException == null ? e.ToString() : e.InnerException.ToString()));
            }
        }
コード例 #2
0
	    public Npc(int id) {
		    this.id = id;
            npcDef = NpcData.forId(id);
            skills = new NpcSkills(this);
            skills.setMaxLevel(NpcSkills.SKILL.HITPOINTS, npcDef.getHitpoints()); //this must be first.
            skills.setCurLevel(NpcSkills.SKILL.HITPOINTS, npcDef.getHitpoints());
		    this.setWalkType(WalkType.RANGE);
		    this.faceDirection = FaceDirection.NORTH;
            this.updateFlags = new AppearanceUpdateFlags(this);
	    }
コード例 #3
0
	    public static NpcData forId(int id) {
            NpcData d;
            if(!definitions.TryGetValue(id, out d)) {
                d = new NpcData();
                d.id = id;
                d.name = "NPC #" + d.id;
                d.examine = "It's an NPC.";
                definitions.Add(id, d);
            }
            return d;
        }
コード例 #4
0
        public static NpcData forId(int id)
        {
            NpcData d;

            if (!definitions.TryGetValue(id, out d))
            {
                d         = new NpcData();
                d.id      = id;
                d.name    = "NPC #" + d.id;
                d.examine = "It's an NPC.";
                definitions.Add(id, d);
            }
            return(d);
        }