Пример #1
0
        /// <summary>
        /// Load NPC from the DYO file.
        /// </summary>
        private void LoadDyo()
        {
            string dyo = Path.Combine(this._mapPath, $"{this.Name}.dyo");

            using (var dyoFile = new DyoFile(dyo))
            {
                IEnumerable <NpcDyoElement> npcElements = dyoFile.GetElements <NpcDyoElement>();

                foreach (NpcDyoElement element in npcElements)
                {
                    this.CreateNpc(element);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Load a map.
        /// </summary>
        public void Load()
        {
            string mapPath    = Path.Combine(Global.DataPath, "maps", this.Name);
            string wldMapPath = Path.Combine(mapPath, this.Name + ".wld");
            string dyoMapPath = Path.Combine(mapPath, this.Name + ".dyo");
            string rgnMapPath = Path.Combine(mapPath, this.Name + ".rgn");

            // Load .wld
            byte[] wldFileData = File.ReadAllBytes(wldMapPath);
            var    wld         = new WldFile(wldFileData);

            wld.Read();

            this.Width  = wld.Width;
            this.Length = wld.Length;

            // Load .dyo
            byte[] dyoFileData = File.ReadAllBytes(dyoMapPath);
            var    dyo         = new DyoFile(dyoFileData);

            dyo.Read();

            foreach (NpcDyoElement dyoElement in dyo.Elements.Where(d => d is NpcDyoElement))
            {
                this.npcs.Add(Npc.CreateFromDyo(dyoElement, this.Id));
            }

            // Load .rgn
            byte[] rgnFileData = File.ReadAllBytes(rgnMapPath);
            var    rgn         = new RgnFile(rgnFileData);

            rgn.Read();

            foreach (RgnRespawn7 rgnElement in rgn.Elements.Where(r => r is RgnRespawn7))
            {
                var respawner = new RespawnerRegion(rgnElement.Position, rgnElement.StartPosition, rgnElement.EndPosition, rgnElement.Time);

                if (rgnElement.Type == 5)
                {
                    for (int i = 0; i < rgnElement.Count; ++i)
                    {
                        var monster = new Monster(rgnElement.Model, this.Id, respawner);

                        this.monsters.Add(monster);
                        monster.IsSpawned = true;
                    }
                }

                this.regions.Add(respawner);
            }

            // Load .lnd
            //this.Heights = new float[wld.Length * wld.Width];

            //for (int i = 0; i < wld.Length; ++i)
            //    for (int j = 0; j < wld.Width; ++j)
            //    {
            //        // build lnd file format
            //        // read lnd
            //    }
        }