Exemplo n.º 1
0
        public Npc(ShineNpc spoint)
        {
            IsAttackable = false;
            Point        = spoint;
            LinkTable lt = null;

            if (Point.Role == "Gate" && !DataProvider.Instance.NpcLinkTable.TryGetValue(spoint.RoleArg0, out lt))
            {
                Log.WriteLine(LogLevel.Warn, "Could not load LinkTable for NPC {0} LT {1}", Point.MobName,
                              Point.RoleArg0);
            }

            Gate = lt;

            ID       = DataProvider.Instance.GetMobIDFromName(Point.MobName);
            Position = new Vector2(spoint.CoordX, spoint.CoordY);
            if (spoint.Direct < 0)
            {
                Rotation = (byte)((360 + spoint.Direct) / 2);
            }
            else
            {
                Rotation = (byte)(spoint.Direct / 2);
            }
        }
Exemplo n.º 2
0
        public void LoadMaps(List <ushort> toload = null)
        {
            MapsByID   = new Dictionary <ushort, MapInfo>();
            MapsByName = new Dictionary <string, MapInfo>();
            DataTable mapDataInf    = null;
            DataTable linktableData = null;
            DataTable shineNpcData  = null;

            using (var dbClient = Program.DatabaseManager.GetClient())
            {
                mapDataInf    = dbClient.ReadDataTable("SELECT  *FROM mapinfo");
                linktableData = dbClient.ReadDataTable("SELECT *FROM LinkTable");
                shineNpcData  = dbClient.ReadDataTable("SELECT *FROM ShineNpc");
            }

            if (mapDataInf != null)
            {
                foreach (DataRow row in mapDataInf.Rows)
                {
                    var info = MapInfo.Load(row);
                    info.NPCs = new List <ShineNpc>();
                    if (MapsByID.ContainsKey(info.ID))
                    {
                        Log.WriteLine(LogLevel.Debug, "Duplicate map ID {0} ({1})", info.ID, info.FullName);
                        MapsByID.Remove(info.ID);
                        MapsByName.Remove(info.ShortName);
                    }

                    if (toload == null || toload.Contains(info.ID))
                    {
                        MapsByID.Add(info.ID, info);
                        MapsByName.Add(info.ShortName, info);
                    }
                }
            }

            Blocks = new Dictionary <ushort, BlockInfo>();
            foreach (var map in MapsByID.Values)
            {
                DataTable blockData = null;
                using (var dbClient = Program.DatabaseManager.GetClient())
                {
                    blockData = dbClient.ReadDataTable("SELECT  *FROM blockinfo WHERE MapID='" + map.ID + "'");
                }

                if (blockData != null)
                {
                    if (blockData.Rows.Count > 0)
                    {
                        foreach (DataRow row in blockData.Rows)
                        {
                            var info = new BlockInfo(row, map.ID);

                            Blocks.Add(map.ID, info);
                        }
                    }
                    else
                    {
                        Log.WriteLine(LogLevel.Warn, "No BlockInfo for Map {0}", map.ShortName);
                    }
                }
            }

            NpcLinkTable = new Dictionary <string, LinkTable>();
            if (linktableData != null)
            {
                foreach (DataRow row in linktableData.Rows)
                {
                    var link = LinkTable.Load(row);
                    if (Program.IsLoaded(GetMapidFromMapShortName(link.MapClient)))
                    {
                        NpcLinkTable.Add(link.argument, link);
                    }
                }
            }

            if (shineNpcData != null)
            {
                foreach (DataRow row in shineNpcData.Rows)
                {
                    var     npc = ShineNpc.Load(row);
                    MapInfo mi  = null;
                    if (Program.IsLoaded(GetMapidFromMapShortName(npc.Map)) && MapsByName.TryGetValue(npc.Map, out mi))
                    {
                        mi.NPCs.Add(npc);
                    }
                }
            }

            Log.WriteLine(LogLevel.Info, "Loaded {0} maps.", MapsByID.Count);
        }