public void LoadMonster(string file) { if (File.Exists(file + ".xml")) { Logger.Information(Program.ServerMessages.GetMessage(Messages.MonsterMng_Loading), file + ".xml"); var xml = ResourceLoader.XmlLoader <XmlMonsterInfo>(file + ".xml"); _monsterInfo = xml.Monsters.ToDictionary(x => x.Monster); } else if (File.Exists(file + ".txt")) { Logger.Information(Program.ServerMessages.GetMessage(Messages.MonsterMng_Loading), file + ".txt"); var loader = new LoadWZTXT <XmlMonsterInfo>(); var xml = loader.Load(file + ".txt"); foreach (var monst in xml.Monsters) { if (monst.Spell >= (Spell)100 && monst.Spell < (Spell)200) { monst.Spell -= 100; monst.AttackRange += 2; } _monsterInfo.Add(monst.Monster, monst); } //xml.Monsters = _monsterInfo.Select(x => x.Value).ToArray(); ResourceLoader.XmlSaver(file + ".xml", xml); } Logger.Information(Program.ServerMessages.GetMessage(Messages.MonsterMng_Types), _monsterInfo.Count); }
private void LoadGroups(string file) { var loader = new LoadWZTXT <XmlMonsterIAInfo>(); var xml = loader.Load(file); _IAGroups = xml.Monsters.GroupBy(x => x.GroupNumber) .ToDictionary(g => g.Key, g => g.ToList()); }
public void LoadSetBase(string file) { XmlMonsterSetBase xml = null; if (File.Exists(file + ".xml")) { Logger.Information(Program.ServerMessages.GetMessage(Messages.MonsterMng_Loading2), file + ".xml"); xml = ResourceLoader.XmlLoader <XmlMonsterSetBase>(file + ".xml"); } else if (File.Exists(file + ".txt")) { Logger.Information(Program.ServerMessages.GetMessage(Messages.MonsterMng_Loading2), file + ".txt"); var loader = new LoadWZTXT <XmlMonsterSetBase>(); xml = loader.Load(file + ".txt"); ResourceLoader.XmlSaver(file + ".xml", xml); } foreach (var npc in xml.NPCs) { Monsters.Add(new Monster(npc.Type, ObjectType.NPC, npc.Map, new Point(npc.PosX, npc.PosY), (byte)npc.Dir) { Index = GetNewIndex() }); } foreach (var npc in xml.Normal) { Monsters.Add(new Monster(npc.Type, ObjectType.Monster, npc.Map, new Point(npc.PosX, npc.PosY), (byte)npc.Dir) { Index = GetNewIndex() }); } foreach (var npc in xml.BloodCastles) { Monsters.Add(new Monster(npc.Type, ObjectType.Monster, npc.Map, new Point(npc.PosX, npc.PosY), (byte)npc.Dir) { Index = GetNewIndex() }); } foreach (var npc in xml.Golden) { for (var i = 0; i < npc.Quant; i++) { var dir = (byte)_rand.Next(7); var mPos = GetSpawn(npc.Map, npc.PosX, npc.PosX2, npc.PosY, npc.PosY2); var mob = new Monster(npc.Type, ObjectType.Monster, npc.Map, mPos, dir) { Index = GetNewIndex() }; Monsters.Add(mob); Program.GoldenInvasionManager.AddMonster(mob); } } foreach (var npc in xml.Spots) { for (var i = 0; i < npc.Quant; i++) { try { var dir = (byte)_rand.Next(7); var mPos = GetSpawn(npc.Map, npc.PosX, npc.PosX2, npc.PosY, npc.PosY2); var mob = new Monster(npc.Type, ObjectType.Monster, npc.Map, mPos, dir, npc.Element) { Index = GetNewIndex() }; Monsters.Add(mob); }catch (InvalidOperationException) { } } } Logger.Information(Program.ServerMessages.GetMessage(Messages.MonsterMng_Loaded), Monsters.Count); }