Ejemplo n.º 1
0
        /// <summary>
        /// 获取全部NPC数据
        /// </summary>
        /// <returns></returns>
        public static List <MhxyNPC> GetAll()
        {
            List <MhxyNPC> ret = new List <MhxyNPC>();

            string           sql  = "select * from mhxy_npc";
            SQLiteConnection conn = SQLiteUtil.GetConn();

            conn.Open();
            DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null);

            conn.Close();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                MhxyNPC mt = new MhxyNPC();
                mt.map_id = Convert.ToInt32(ds.Tables[0].Rows[i]["map_id"].ToString());
                mt.name   = ds.Tables[0].Rows[i]["name"].ToString();
                mt.npc_id = Convert.ToInt32(ds.Tables[0].Rows[i]["npc_id"].ToString());

                mt.x = Convert.ToInt32(ds.Tables[0].Rows[i]["x"].ToString());
                mt.y = Convert.ToInt32(ds.Tables[0].Rows[i]["y"].ToString());
                ret.Add(mt);
            }

            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取任务全部数据
        /// </summary>
        /// <param name="mapId"></param>
        /// <param name="targetId"></param>
        /// <returns></returns>
        public static List <MhxyRouterRec> GetRouterAll(int mapId, int targetId)
        {
            List <MhxyMapExit>   exlist  = MhxyMapExit.GetAll();
            List <MhxyNPC>       npcList = MhxyNPC.GetAll();
            List <MhxyRouterRec> ret     = new List <MhxyRouterRec>();

            string           sql  = "select * from mhxy_router_rec where map_id=" + mapId.ToString() + " and target_id=" + targetId.ToString() + " order by sort asc";
            SQLiteConnection conn = SQLiteUtil.GetConn();

            conn.Open();
            DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null);

            conn.Close();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                MhxyRouterRec mt = new MhxyRouterRec();
                mt.id        = Convert.ToInt32(ds.Tables[0].Rows[i]["id"].ToString());
                mt.map_id    = Convert.ToInt32(ds.Tables[0].Rows[i]["map_id"].ToString());
                mt.exit_id   = Convert.ToInt32(ds.Tables[0].Rows[i]["exit_id"].ToString());
                mt.sort      = Convert.ToInt32(ds.Tables[0].Rows[i]["sort"].ToString());
                mt.is_type   = Convert.ToInt32(ds.Tables[0].Rows[i]["is_type"].ToString());
                mt.target_id = Convert.ToInt32(ds.Tables[0].Rows[i]["target_id"].ToString());
                mt.remarks   = ds.Tables[0].Rows[i]["remarks"].ToString();
                //装载出口信息
                for (int k = 0; k < exlist.Count; k++)
                {
                    if (mt.exit_id == exlist[k].id)
                    {
                        mt.mapExit = exlist[k];
                    }
                }
                //装载NPC
                if (mt.is_type == 0)
                {
                    for (int k = 0; k < npcList.Count; k++)
                    {
                        if (mt.target_id == npcList[k].npc_id)
                        {
                            mt.npc = npcList[k];
                        }
                    }
                }
                ret.Add(mt);
            }

            return(ret);
        }
Ejemplo n.º 3
0
        public static MhxyNPC GetNPCID(int npc_id)
        {
            MhxyNPC mt = new MhxyNPC();

            string           sql  = "select * from mhxy_npc where npc_id=" + npc_id.ToString();
            SQLiteConnection conn = SQLiteUtil.GetConn();

            conn.Open();
            DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null);

            conn.Close();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                mt.map_id = Convert.ToInt32(ds.Tables[0].Rows[i]["map_id"].ToString());
                mt.name   = ds.Tables[0].Rows[i]["name"].ToString();
                mt.npc_id = Convert.ToInt32(ds.Tables[0].Rows[i]["npc_id"].ToString());

                mt.x = Convert.ToInt32(ds.Tables[0].Rows[i]["x"].ToString());
                mt.y = Convert.ToInt32(ds.Tables[0].Rows[i]["y"].ToString());
            }

            return(mt);
        }