示例#1
0
        public static List <IZone> GenerateZones()
        {
            List <IZone> compiledZones = new List <IZone>();

            GlobalReference.GlobalValues.Initilize();
            GlobalReference.GlobalValues.Settings.ZoneDirectory = @"C:\Mud\World";

            DeleteOldZoneFiles(GlobalReference.GlobalValues.Settings.ZoneDirectory);

            IWorld world = new World();

            GlobalReference.GlobalValues.World = world;

            Type zoneCodeInterface   = typeof(IZoneCode);
            IEnumerable <Type> zones = Assembly.GetExecutingAssembly().GetTypes().Where(e => zoneCodeInterface.IsAssignableFrom(e) && e.IsClass);

            DeleteOldZoneFiles(GlobalReference.GlobalValues.Settings.ZoneDirectory);
            foreach (Type type in zones)
            {
                IZoneCode zone      = (IZoneCode)Activator.CreateInstance(type);
                IZone     builtZone = zone.Generate();
                SaveZone(world, builtZone);
                compiledZones.Add(builtZone);
            }

            using (TextWriter tw = new StreamWriter("..\\..\\..\\ZonesIds.txt"))
            {
                tw.WriteLine("Id\tLvl\tName");
                foreach (IZone zone in compiledZones.OrderBy(e => e.Id))
                {
                    List <int> mobLevel = new List <int>();
                    foreach (IRoom room in zone.Rooms.Values)
                    {
                        foreach (INonPlayerCharacter npc in room.NonPlayerCharacters)
                        {
                            if (npc.Level == 0)
                            {
                                mobLevel.Add((npc.LevelRange.LowerLevel + npc.LevelRange.UpperLevel) / 2);
                            }
                            else
                            {
                                mobLevel.Add(npc.Level);
                            }
                        }
                    }

                    mobLevel.Sort();
                    int midLevel = 0;
                    if (mobLevel.Count > 0)
                    {
                        midLevel = mobLevel[mobLevel.Count / 2];
                    }

                    tw.WriteLine($"{zone.Id}\t{midLevel}\t{zone.Name}");
                }
            }

            return(compiledZones);
        }
示例#2
0
文件: Program.cs 项目: elavanis/Mud
        public static void Main(string[] args)
        {
            List <IZone> generatedZones = new List <IZone>();

            GlobalReference.GlobalValues.Initilize();

            Type zoneCodeInterface   = typeof(IZoneCode);
            IEnumerable <Type> zones = Assembly.GetAssembly(typeof(IZoneCode)).GetTypes().Where(e => zoneCodeInterface.IsAssignableFrom(e) && e.IsClass);

            foreach (Type type in zones)
            {
                IZoneCode zoneCode = (IZoneCode)Activator.CreateInstance(type);
                IZone     zone     = zoneCode.Generate();

                generatedZones.Add(zone);
            }
        }
示例#3
0
        public static void Main(string[] args)
        {
            GlobalReference.GlobalValues.Initilize();

            DeleteOldZoneFiles(Directory.GetCurrentDirectory());

            IWorld world = new World();

            GlobalReference.GlobalValues.World = world;

            Type zoneCodeInterface   = typeof(IZoneCode);
            IEnumerable <Type> zones = Assembly.GetExecutingAssembly().GetTypes().Where(e => zoneCodeInterface.IsAssignableFrom(e) && e.IsClass);

            DeleteOldZoneFiles(zoneFiles);
            foreach (Type type in zones)
            {
                IZoneCode zone = (IZoneCode)Activator.CreateInstance(type);
                SaveZone(world, zone.Generate());
            }
        }
示例#4
0
        public static void Main(string[] args)
        {
            Directory.CreateDirectory(@"C:\Mud\Maps\");
            GlobalReference.GlobalValues.Initilize();

            Type zoneCodeInterface   = typeof(IZoneCode);
            IEnumerable <Type> zones = Assembly.GetAssembly(typeof(IZoneCode)).GetTypes().Where(e => zoneCodeInterface.IsAssignableFrom(e) && e.IsClass);

            foreach (Type type in zones)
            {
                IZoneCode zoneCode = (IZoneCode)Activator.CreateInstance(type);
                IZone     zone     = zoneCode.Generate();

                if (zone.Rooms.Count > 0)
                {
                    if (!ManualZones(zone))
                    {
                        Map map = new Map(zone);
                        map.GenerateMap();
                    }
                }
            }
        }