コード例 #1
0
ファイル: frmMain.cs プロジェクト: weimingtom/pap2
        private void _doDrop(DataRowView view)
        {
            if (null == m_shopitems)
            {
                return;
            }
            //不能加入相同的记录
            foreach (ShopItem item in m_shopitems)
            {
                if (item.ItemIndex == (int)view["物件标识"])
                {
                    return;
                }
            }

            ShopItem shop = new ShopItem();

            shop.ShopItemID     = -1;
            shop.CountLimit     = "-1";
            shop.ItemIndex      = (int)view["物件标识"];
            shop.Price          = 0;
            shop.RandSeed       = "1";
            shop.RECID          = -1;
            shop.ReputeLevel    = "1";
            shop.ShopTemplateID = Int32.Parse(lblShopID.Text);
            shop.SortIndex      = dgvShopItems.Rows.Count;//排序号
            if (null != m_itemcategories && m_itemcategories.Count > 0)
            {
                ItemCategory itemcategory = (ItemCategory)m_itemcategories[0];
                shop.TabType = itemcategory.CategoryName;
            }
            m_shopitems.Add(shop);
            dgvShopItems.Rows[dgvShopItems.Rows.Count - 1].Cells[2].Selected   = true;
            dgvShopItems.Rows[dgvShopItems.Rows.Count - 1].Cells[1].Value      = lblShopID.Text;
            dgvShopItems.Rows[dgvShopItems.Rows.Count - 1].Cells["物件标识"].Value = view["物件标识"];
            dgvShopItems.Rows[dgvShopItems.Rows.Count - 1].Cells["物件名称"].Value = view["物件名称"];
            dgvShopItems.Rows[dgvShopItems.Rows.Count - 1].Cells["随机种子"].Value = shop.RandSeed;
            dgvShopItems.Rows[dgvShopItems.Rows.Count - 1].Cells["最大数目"].Value = shop.CountLimit;
            dgvShopItems.Rows[dgvShopItems.Rows.Count - 1].Cells["声望等级"].Value = shop.ReputeLevel;
            dgvShopItems.Rows[dgvShopItems.Rows.Count - 1].Cells["价格"].Value   = shop.Price;
            dgvShopItems.Rows[dgvShopItems.Rows.Count - 1].Cells["排列序号"].Value = shop.SortIndex;

            this._initShopItems(Int32.Parse(lblShopID.Text), false);
            try
            {
                dgvShopItems.Rows[dgvShopItems.Rows.Count - 2].Cells[2].Selected = true;
            }
            catch { }
            m_isDirty = true;//设置全局修改标志位
        }
コード例 #2
0
ファイル: SqlDataProvider.cs プロジェクト: weimingtom/pap2
        private ShopItemCollection _getShopItems(string sql, int pPageIndex, int pPageSize)
        {
            ShopItemCollection retobjs = new ShopItemCollection();
            SqlDataReader      sdr     = null;
            ShopItem           obj     = null;

            m_db.RunSql(sql, out sdr);
            if (null == sdr)
            {
                return(null);
            }
            int _curRecPos = 0;
            //计算页记录///
            long _startpos = 0;
            long _endpos   = 0;

            if (pPageIndex > -1)
            {
                _startpos = pPageIndex * pPageSize;
                _endpos   = _startpos + pPageSize;
            }
            while (sdr.Read())
            {
                if (_curRecPos > _endpos)
                {
                    break;
                }
                if (_curRecPos >= _startpos && _curRecPos < _endpos)
                {
                    obj = this._buildShopItem(ref sdr);
                    if (null != obj)
                    {
                        retobjs.Add(obj);
                    }
                }
                _curRecPos++;
            }
            sdr.Close();
            if (retobjs.Count > 0)
            {
                return(retobjs);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
ファイル: SqlDataProvider.cs プロジェクト: weimingtom/pap2
        private ShopItemCollection _getShopItems(string sql)
        {
            ShopItemCollection retobjs = new ShopItemCollection();
            SqlDataReader      sdr     = null;

            m_db.RunSql(sql, out sdr);
            if (null == sdr)
            {
                return(null);
            }
            while (sdr.Read())
            {
                retobjs.Add(this._buildShopItem(ref sdr));
            }
            sdr.Close();
            return(retobjs);
        }
コード例 #4
0
ファイル: ShopManager.cs プロジェクト: aggpys/Atreia-World
        private static GameShop ReadPriceList(string path)
        {
            XDocument xdoc = null;

            try
            {
                xdoc = XDocument.Load(path);
            }
            catch (XmlException) { }

            if (xdoc == null || xdoc.Root == null) return null;

            var xNameCategories = XName.Get("categories", DefaultNamespace);
            var xNameCategory = XName.Get("category", DefaultNamespace);
            var xNameItem = XName.Get("item", DefaultNamespace);

            var result = new GameShop();
            var categoriesRoot = xdoc.Root.Element(xNameCategories);

            if (categoriesRoot == null)
                return null;

            foreach (var xcat in categoriesRoot.Elements(xNameCategory))
            {
                var catAttr = xcat.Attribute("name");
                if (catAttr == null || string.IsNullOrEmpty(catAttr.Value)) return null;

                var category = new ShopItemCollection(catAttr.Value.Trim());

                foreach (var xitem in xcat.Elements(xNameItem))
                {
                    var idAttr = xitem.Attribute("id");
                    var titleAttr = xitem.Attribute("title");
                    var qualityAttr = xitem.Attribute("quality");
                    var raceAttr = xitem.Attribute("race");
                    var iconAttr = xitem.Attribute("icon");
                    var countAttr = xitem.Attribute("count");
                    var priceAttr = xitem.Attribute("price");

                    if (idAttr == null || string.IsNullOrEmpty(idAttr.Value)) continue;
                    if (titleAttr == null || string.IsNullOrEmpty(titleAttr.Value)) continue;
                    if (priceAttr == null || string.IsNullOrEmpty(priceAttr.Value)) continue;

                    uint id;
                    uint price;
                    uint count;

                    var idTest = uint.TryParse(idAttr.Value, out id);
                    var priceTest = uint.TryParse(priceAttr.Value, out price);

                    if (!idTest || !priceTest) continue;

                    if (countAttr != null)
                    {
                        var countTest = uint.TryParse(countAttr.Value, out count);

                        if (!countTest)
                            count = 1;
                    }
                    else
                        count = 1;

                    var quality = ItemQuality.Common;

                    if (qualityAttr != null &&
                        !string.IsNullOrEmpty(qualityAttr.Value))
                    {
                        ItemQuality temp;

                        var qualityTest = Enum.TryParse(qualityAttr.Value, true, out temp);

                        if (qualityTest)
                            quality = temp;
                    }

                    var race = ItemRaceRestriction.Universal;

                    if (raceAttr != null &&
                        !string.IsNullOrEmpty(raceAttr.Value))
                    {
                        ItemRaceRestriction temp;

                        var raceTest = Enum.TryParse(raceAttr.Value, true, out temp);

                        if (raceTest)
                            race = temp;
                    }

                    string icon = null;

                    if (iconAttr != null &&
                        !string.IsNullOrEmpty(iconAttr.Value))
                        icon = iconAttr.Value.Trim();

                    category.Add(new ShopItem(id, titleAttr.Value.Trim(), quality, race, icon, count, price));
                }

                if (category.Count > 0)
                    result.Add(category);
            }

            return result.Count == 0 ? null : result;
        }
コード例 #5
0
        private static GameShop ReadPriceList(string path)
        {
            XDocument xdoc = null;

            try
            {
                xdoc = XDocument.Load(path);
            }
            catch (XmlException) { }

            if (xdoc == null || xdoc.Root == null)
            {
                return(null);
            }

            var xNameCategories = XName.Get("categories", DefaultNamespace);
            var xNameCategory   = XName.Get("category", DefaultNamespace);
            var xNameItem       = XName.Get("item", DefaultNamespace);

            var result         = new GameShop();
            var categoriesRoot = xdoc.Root.Element(xNameCategories);

            if (categoriesRoot == null)
            {
                return(null);
            }

            foreach (var xcat in categoriesRoot.Elements(xNameCategory))
            {
                var catAttr = xcat.Attribute("name");
                if (catAttr == null || string.IsNullOrEmpty(catAttr.Value))
                {
                    return(null);
                }

                var category = new ShopItemCollection(catAttr.Value.Trim());

                foreach (var xitem in xcat.Elements(xNameItem))
                {
                    var idAttr      = xitem.Attribute("id");
                    var titleAttr   = xitem.Attribute("title");
                    var qualityAttr = xitem.Attribute("quality");
                    var raceAttr    = xitem.Attribute("race");
                    var iconAttr    = xitem.Attribute("icon");
                    var countAttr   = xitem.Attribute("count");
                    var priceAttr   = xitem.Attribute("price");

                    if (idAttr == null || string.IsNullOrEmpty(idAttr.Value))
                    {
                        continue;
                    }
                    if (titleAttr == null || string.IsNullOrEmpty(titleAttr.Value))
                    {
                        continue;
                    }
                    if (priceAttr == null || string.IsNullOrEmpty(priceAttr.Value))
                    {
                        continue;
                    }

                    uint id;
                    uint price;
                    uint count;

                    var idTest    = uint.TryParse(idAttr.Value, out id);
                    var priceTest = uint.TryParse(priceAttr.Value, out price);

                    if (!idTest || !priceTest)
                    {
                        continue;
                    }

                    if (countAttr != null)
                    {
                        var countTest = uint.TryParse(countAttr.Value, out count);

                        if (!countTest)
                        {
                            count = 1;
                        }
                    }
                    else
                    {
                        count = 1;
                    }

                    var quality = ItemQuality.Common;

                    if (qualityAttr != null &&
                        !string.IsNullOrEmpty(qualityAttr.Value))
                    {
                        ItemQuality temp;

                        var qualityTest = Enum.TryParse(qualityAttr.Value, true, out temp);

                        if (qualityTest)
                        {
                            quality = temp;
                        }
                    }

                    var race = ItemRaceRestriction.Universal;

                    if (raceAttr != null &&
                        !string.IsNullOrEmpty(raceAttr.Value))
                    {
                        ItemRaceRestriction temp;

                        var raceTest = Enum.TryParse(raceAttr.Value, true, out temp);

                        if (raceTest)
                        {
                            race = temp;
                        }
                    }

                    string icon = null;

                    if (iconAttr != null &&
                        !string.IsNullOrEmpty(iconAttr.Value))
                    {
                        icon = iconAttr.Value.Trim();
                    }

                    category.Add(new ShopItem(id, titleAttr.Value.Trim(), quality, race, icon, count, price));
                }

                if (category.Count > 0)
                {
                    result.Add(category);
                }
            }

            return(result.Count == 0 ? null : result);
        }