Ejemplo n.º 1
0
        private void ItemView_DoubleClick(object sender, EventArgs e)
        {
            if (!Enabled || tar == -1)
            {
                return;
            }

            HItemConfig itemConfig = ConfigData.GetHItemConfig(UserProfile.InfoBag.Items[tar].Type);

            if (itemConfig.IsUsable)
            {
                if (itemConfig.CdGroup > 0)
                {
                    if (cds[itemConfig.CdGroup] > 0)
                    {
                        return;
                    }
                    cds[itemConfig.CdGroup] = CdGroup.GetCDTime(itemConfig.CdGroup);
                }
                int count = UserProfile.InfoBag.Items[tar].Value;
                UserProfile.InfoBag.UseItemByPos(tar, ItemSubType);
                if (count == 1)
                {
                    RefreshList();
                }
                Invalidate();
            }
        }
Ejemplo n.º 2
0
        public void Draw(Graphics g)
        {
            SolidBrush sb = new SolidBrush(backColor);

            g.FillRectangle(sb, x, y, width, height);
            sb.Dispose();
            g.DrawRectangle(Pens.White, x, y, width - 1, height - 1);

            if (show)
            {
                HItemConfig itemConfig = ConfigData.GetHItemConfig(itemId);

                Font  font  = new Font("微软雅黑", 10 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
                Brush brush = new SolidBrush(Color.FromName(HSTypes.I2RareColor(itemConfig.Rare)));
                g.DrawString(itemConfig.Name, font, brush, x + 57, y + 7);
                brush.Dispose();

                g.DrawString(price.ToString(), font, Brushes.Gold, x + 57, y + 30);
                g.DrawImage(HSIcons.GetIconsByEName("res1"), g.MeasureString(price.ToString(), font).Width + 57 + x, y + 32, 16, 16);

                virtualRegion.Draw(g);
                g.DrawString(itemCount.ToString(), font, Brushes.Black, x + 30, y + 29);
                g.DrawString(itemCount.ToString(), font, Brushes.White, x + 29, y + 28);

                font.Dispose();

                if (!bitmapButtonBuy.Visible)
                {
                    font = new Font("微软雅黑", 10 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
                    g.DrawString("完成", font, Brushes.LightGreen, x + 152, y + 30);
                    font.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
        public void Draw(Graphics g)
        {
            g.DrawRectangle(Pens.White, x, y, width - 1, height - 1);

            if (show)
            {
                Font font    = new Font("微软雅黑", 10 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
                var  isEquip = ConfigIdManager.IsEquip(itemId);
                if (!isEquip)
                {
                    HItemConfig itemConfig = ConfigData.GetHItemConfig(itemId);

                    Brush brush = new SolidBrush(Color.FromName(HSTypes.I2RareColor(itemConfig.Rare)));
                    g.DrawString(itemConfig.Name, font, brush, x + 50, y + 7);
                    brush.Dispose();
                }
                else
                {
                    EquipConfig equipConfig = ConfigData.GetEquipConfig(itemId);

                    Brush brush = new SolidBrush(Color.FromName(HSTypes.I2RareColor(equipConfig.Quality)));
                    g.DrawString(equipConfig.Name, font, brush, x + 50, y + 7);
                    brush.Dispose();
                }
                g.DrawString(price.ToString(), font, Brushes.Gold, x + 50, y + 30);
                g.DrawImage(HSIcons.GetIconsByEName("res" + (priceType + 1)), g.MeasureString(price.ToString(), font).Width + 50 + x, 32 + y, 16, 16);
                font.Dispose();

                virtualRegion.Draw(g);
            }
        }
Ejemplo n.º 4
0
        public void Effect(Forms.BasePanel panel, HsActionCallback success, HsActionCallback fail)
        {
            if (type == "item")
            {
                UserProfile.InfoBag.AddItem(infos[0], 1);
                HItemConfig itemConfig = ConfigData.GetHItemConfig(infos[0]);
                panel.AddFlowCenter(string.Format("获得{0}x1", itemConfig.Name), HSTypes.I2RareColor(itemConfig.Rare));
            }
            else if (type == "mon")
            {
                PeopleBook.Fight(infos[0], "oneline", mlevel + infos[1], new PeopleFightParm(), success, fail, null);
                return;
            }
            else if (type == "gold")
            {
                UserProfile.InfoBag.AddResource(GameResourceType.Gold, (uint)infos[0]);
                panel.AddFlowCenter(string.Format("获得黄金x{0}", infos[0]), HSTypes.I2ResourceColor(0));
            }
            else if (type == "resource")
            {
                UserProfile.InfoBag.AddResource((GameResourceType)(infos[0] - 1), 1);
                panel.AddFlowCenter(string.Format("获得{1}x{0}", 1, HSTypes.I2Resource(infos[0] - 1)), HSTypes.I2ResourceColor(infos[0] - 1));
            }
            string word = MazeItemConfig.Word;

            if (word != "")
            {
                panel.AddFlowCenter(word, "White");
            }
            success();
        }
Ejemplo n.º 5
0
        public void NewTick()
        {
            foreach (var item in items)
            {
                if (item.itemPos < 0)
                {
                    continue;
                }

                int         itid       = UserProfile.InfoBag.Items[item.itemPos].Type;
                HItemConfig itemConfig = ConfigData.GetHItemConfig(itid);
                if (itemConfig.CdGroup > 0 && cds[itemConfig.CdGroup] > 0)
                {
                    item.Percent = cds[itemConfig.CdGroup] * 100 / CdGroup.GetCDTime(itemConfig.CdGroup);
                    Invalidate(item.Rectangle);
                }
            }

            for (int i = 0; i < cdCount; i++)
            {
                if (cds[i] > 0)
                {
                    cds[i]--;
                }
            }
        }
Ejemplo n.º 6
0
        public List <IntPair> GetItemCountByAttribute(string attrName)
        {
            AutoDictionary <int, int> counter = new AutoDictionary <int, int>();

            for (int i = 0; i < BagCount; i++)
            {
                HItemConfig itemConfig = ConfigData.GetHItemConfig(Items[i].Type);
                if (itemConfig != null && itemConfig.Attributes != null && Array.IndexOf(itemConfig.Attributes, attrName) >= 0)
                {
                    counter[itemConfig.Id] += Items[i].Value;
                }
            }
            List <IntPair> datas = new List <IntPair>();

            foreach (int itemId in counter.Keys())
            {
                IntPair pairData = new IntPair
                {
                    Type  = itemId,
                    Value = counter[itemId]
                };
                datas.Add(pairData);
            }
            return(datas);
        }
Ejemplo n.º 7
0
        internal FlowItemInfo(int item_id, Point point, int offX, int offY)
            : base("", point, -2, "White", offX, offY, 1, 3, 30)
        {
            id = item_id;
            HItemConfig itemConfig = ConfigData.GetHItemConfig(id);

            word  = string.Format("{0}", itemConfig.Name);
            color = Color.FromName(HSTypes.I2RareColor(itemConfig.Rare));
        }
Ejemplo n.º 8
0
        public static CardPieceRate FromCardPiece(int id, int clevel)
        {
            CardPieceRate pieceRate  = new CardPieceRate();
            HItemConfig   itemConfig = ConfigData.GetHItemConfig(id);

            int percent = rates[itemConfig.Rare - 1];

            pieceRate.ItemId = id;
            pieceRate.Rate   = CheckBound(clevel, itemConfig, percent);
            return(pieceRate);
        }
Ejemplo n.º 9
0
        public static bool UseItemsById(int id, HItemUseTypes useMethod)
        {
            HItemConfig itemConfig = ConfigData.GetHItemConfig(id);

            //ItemConsumerConfig consumerConfig = ConfigData.GetItemConsumerConfig(id);
            //if (useMethod == HItemUseTypes.Common)
            //{
            //    if (itemConfig.SubType == (int)HItemTypes.Item)
            //        return UseItem(consumerConfig);
            //}

            return(false);
        }
Ejemplo n.º 10
0
        public static Image GetHItemImage(int id)
        {
            HItemConfig hItemConfig = ConfigData.GetHItemConfig(id);

            string fname = string.Format("Item/{0}", hItemConfig.Url);

            if (!ImageManager.HasImage(fname))
            {
                Image image = PicLoader.Read("Item", string.Format("{0}.JPG", hItemConfig.Url));
                ImageManager.AddImage(fname, image);
            }
            return(ImageManager.GetImage(fname));
        }
Ejemplo n.º 11
0
        public static Image GetPreview(int id)
        {
            HItemConfig hItemConfig = ConfigData.GetHItemConfig(id);

            if (hItemConfig.Id <= 0)
            {
                return(DrawTool.GetImageByString("unknown", 100));
            }

            ControlPlus.TipImage tipData = new ControlPlus.TipImage(PaintTool.GetTalkColor);
            tipData.AddTextNewLine(hItemConfig.Name, HSTypes.I2RareColor(hItemConfig.Rare), 20);
            if (hItemConfig.IsUsable)
            {
                if (hItemConfig.SubType == (int)HItemTypes.Fight)
                {
                    tipData.AddTextNewLine("       战斗中双击使用", "Red");
                }
                else if (hItemConfig.SubType == (int)HItemTypes.Seed)
                {
                    tipData.AddTextNewLine("       农场中双击使用", "Red");
                }
                else
                {
                    tipData.AddTextNewLine("       双击使用", "Green");
                }
            }
            if (hItemConfig.Type == (int)HItemTypes.Task)
            {
                tipData.AddTextNewLine("       任务物品", "DarkBlue");
            }
            else if (hItemConfig.Type == (int)HItemTypes.Material)
            {
                tipData.AddTextNewLine(string.Format("       材料(稀有度:{0})", hItemConfig.Rare), "White");
            }
            if (hItemConfig.Attributes != null && hItemConfig.Attributes.Length > 0)
            {
                tipData.AddTextNewLine(string.Format("       特性:{0}", string.Join(",", hItemConfig.Attributes)), "Lime");
            }

            tipData.AddTextNewLine(string.Format("       等级:{0}", hItemConfig.Level), "White");
            tipData.AddTextNewLine("", "White", 8);
            if (!string.IsNullOrEmpty(hItemConfig.Descript))
            {
                tipData.AddTextLines(hItemConfig.Descript, "White", 20, true);
            }
            tipData.AddTextNewLine(string.Format("出售价格:{0}", GameResourceBook.InGoldSellItem(hItemConfig.Rare, hItemConfig.ValueFactor)), "Yellow");
            tipData.AddImage(HSIcons.GetIconsByEName("res1"));
            tipData.AddImageXY(GetHItemImage(id), 8, 8, 48, 48, 7, 24, 32, 32);

            return(tipData.Image);
        }
Ejemplo n.º 12
0
        public static bool UseItemsById(int id, int useMethod)
        {
            HItemConfig itemConfig = ConfigData.GetHItemConfig(id);

            if (itemConfig.Id == ConfigData.NoneHItem.Id)
            {
                return(false);
            }

            ItemConsumerConfig consumerConfig = ConfigData.GetItemConsumerConfig(id);

            if (useMethod == HItemTypes.Common)
            {
                if (itemConfig.SubType == HItemTypes.Gift)
                {
                    return(UseGift(id));
                }
                if (itemConfig.SubType == HItemTypes.Item)
                {
                    return(UseItem(consumerConfig));
                }
                if (itemConfig.SubType == HItemTypes.RandomCard)
                {
                    return(UseRandomCard(consumerConfig));
                }
                if (itemConfig.SubType == HItemTypes.DropItem)
                {
                    return(UseDropItem(consumerConfig));
                }
            }
            else if (useMethod == HItemTypes.Fight)
            {
                if (itemConfig.SubType == HItemTypes.Fight)
                {
                    return(UseFightItem(consumerConfig));
                }
            }
            else if (useMethod == HItemTypes.Seed)
            {
                if (itemConfig.SubType == HItemTypes.Seed)
                {
                    return(UseSeedItem(consumerConfig));
                }
            }

            return(false);
        }
Ejemplo n.º 13
0
        public void AddItem(int id, int num)
        {
            HItemConfig itemConfig = ConfigData.GetHItemConfig(id);

            MainTipManager.AddTip(string.Format("|获得物品-|{0}|{1}||x{2}", HSTypes.I2RareColor(itemConfig.Rare), itemConfig.Name, num), "White");

            int max = itemConfig.MaxPile;

            if (max <= 0)
            {
                return;
            }

            int count = num;

            for (int i = 0; i < BagCount; i++)
            {
                var pickItem = Items[i];
                if (pickItem.Type == id && pickItem.Value < max)
                {
                    if (pickItem.Value + count <= max)
                    {
                        pickItem.Value += count;
                        return;
                    }
                    count         -= max - pickItem.Value;
                    pickItem.Value = max;
                }
            }
            for (int i = 0; i < BagCount; i++)
            {
                var pickItem = Items[i];
                if (pickItem.Type == 0)
                {
                    if (count <= max)
                    {
                        pickItem.Type  = id;
                        pickItem.Value = count;
                        return;
                    }
                    pickItem.Type  = id;
                    count         -= max;
                    pickItem.Value = max;
                }
            }
        }
Ejemplo n.º 14
0
        private void ItemView_DoubleClick(object sender, EventArgs e)
        {
            if (tar == -1)
            {
                return;
            }

            HItemConfig itemConfig = ConfigData.GetHItemConfig(UserProfile.InfoBag.Items[baseid + tar].Type);

            if (itemConfig.IsUsable && itemConfig.SubType != HItemTypes.Fight)
            {
                UserProfile.InfoBag.UseItemByPos(baseid + tar, HItemTypes.Common);
                leftSelectTar = -1;
                myCursor.ChangeCursor("default");
                isDirty = true;
                Invalidate(new Rectangle(6, 36, 324, 324));
            }
        }
Ejemplo n.º 15
0
 private void RefreshList()
 {
     ids = new List <int>();
     for (int i = 0; i < UserProfile.InfoBag.BagCount; i++)
     {
         if (UserProfile.InfoBag.Items[i].Type != 0)
         {
             HItemConfig itemConfig = ConfigData.GetHItemConfig(UserProfile.InfoBag.Items[i].Type);
             if (itemConfig.SubType == ItemSubType && itemConfig.IsUsable)
             {
                 ids.Add(i);
             }
         }
     }
     page = 0;
     RefreshItems();
     CheckButton();
 }
Ejemplo n.º 16
0
 private static int CheckBound(int clevel, HItemConfig itemConfig, int percent)
 {
     if (clevel > itemConfig.Rare)
     {
         percent += (clevel - itemConfig.Rare) * 2 * 100;
     }
     else if (clevel == itemConfig.Rare)
     {
         percent += 100;
     }
     if (percent < 50)//最小概率0.5%
     {
         percent = 50;
     }
     else if (percent > 1500)
     {
         percent = 1500;
     }
     return(percent);
 }
Ejemplo n.º 17
0
 private static int CheckBound(int clevel, HItemConfig itemConfig, int percent)
 {
     if (clevel > itemConfig.Rare)
     {
         percent += (clevel - itemConfig.Rare)*2 * 100;
     }
     else if (clevel == itemConfig.Rare)
     {
         percent+=100;
     }
     if (percent < 50)//最小概率0.5%
     {
         percent = 50;
     }
     else if (percent > 1500)
     {
         percent = 1500;
     }
     return percent;
 }
Ejemplo n.º 18
0
        private void DropItemViewerForm_Click(object sender, EventArgs e)
        {
            if (tar != -1)
            {
                sel = tar;

                HItemConfig  itemConfig = ConfigData.GetHItemConfig(items[tar]);
                const string stars      = "★★★★★★★★★★";
                itemDesStr = string.Format("{0}({2}){1}", itemConfig.Name, itemConfig.Descript, stars.Substring(10 - itemConfig.Rare));
                Invalidate(new Rectangle(65, cardHeight * yCount + 37 + 21, 500, 20));

                nlClickLabel1.ClearLabel();
                int[] cardIds = CardPieceBook.GetCardIdsByItemId(items[tar]);
                foreach (int cid in cardIds)
                {
                    var name = CardConfigManager.GetCardConfig(cid).Name;
                    nlClickLabel1.AddLabel(name, cid);
                }
                nlClickLabel1.Invalidate();
            }
        }
Ejemplo n.º 19
0
        public void Draw(Graphics g)
        {
            Image back = PicLoader.Read("System", "ShopItemBack.JPG");

            g.DrawImage(back, x, y, width - 1, height - 1);
            back.Dispose();

            if (show)
            {
                GameShopConfig gameShopConfig = ConfigData.GetGameShopConfig(productId);
                string         name;
                string         fontcolor;
                var            isEquip = ConfigIdManager.IsEquip(gameShopConfig.ItemId);
                if (!isEquip)
                {
                    HItemConfig itemConfig = ConfigData.GetHItemConfig(gameShopConfig.ItemId);
                    name      = itemConfig.Name;
                    fontcolor = HSTypes.I2RareColor(itemConfig.Rare);
                }
                else
                {
                    EquipConfig equipConfig = ConfigData.GetEquipConfig(gameShopConfig.ItemId);
                    name      = equipConfig.Name;
                    fontcolor = HSTypes.I2QualityColor(equipConfig.Quality);
                }
                Font  fontsong = new Font("宋体", 9 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
                Brush brush    = new SolidBrush(Color.FromName(fontcolor));
                g.DrawString(name, fontsong, brush, x + 76, y + 9);
                brush.Dispose();
                var itmConfig = ConfigData.GetHItemConfig(gameShopConfig.ItemId);
                var price     = GameResourceBook.OutGoldSellItem(itmConfig.Rare, itmConfig.ValueFactor);
                g.DrawString(string.Format("{0,3:D}", Math.Max(1, price / GameConstants.DiamondToGold)), fontsong, Brushes.PaleTurquoise, x + 80, y + 37);
                fontsong.Dispose();
                g.DrawImage(HSIcons.GetIconsByEName("res8"), x + 110, y + 35, 16, 16);

                virtualRegion.Draw(g);
            }
        }
Ejemplo n.º 20
0
        public List <IntPair> GetItemCountBySubtype(int type)
        {
            AutoDictionary <int, int> counter = new AutoDictionary <int, int>();

            for (int i = 0; i < BagCount; i++)
            {
                HItemConfig itemConfig = ConfigData.GetHItemConfig(Items[i].Type);
                if (itemConfig != null && itemConfig.SubType == type)
                {
                    counter[itemConfig.Id] += Items[i].Value;
                }
            }
            List <IntPair> datas = new List <IntPair>();

            foreach (int itemId in counter.Keys())
            {
                IntPair pairData = new IntPair();
                pairData.Type  = itemId;
                pairData.Value = counter[itemId];
                datas.Add(pairData);
            }
            return(datas);
        }
Ejemplo n.º 21
0
        public void Draw(Graphics g)
        {
            Image back = PicLoader.Read("System", "ShopItemBack.jpg");

            g.DrawImage(back, X, Y, Width - 1, Height - 1);
            back.Dispose();

            if (show)
            {
                GameShopConfig gameShopConfig = ConfigData.GetGameShopConfig(productId);
                var            eid            = HItemBook.GetItemId(gameShopConfig.Item);
                HItemConfig    itemConfig     = ConfigData.GetHItemConfig(eid);
                var            name           = itemConfig.Name;
                var            fontcolor      = HSTypes.I2RareColor(itemConfig.Rare);
                uint           price          = GameResourceBook.OutGoldSellItem(itemConfig.Rare, itemConfig.ValueFactor) * 2;
                if (gameShopConfig.UseDiamond)
                {
                    price = Math.Max(1, price / GameConstants.DiamondToGold);
                }
                Font  fontsong = new Font("宋体", 10 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
                Brush brush    = new SolidBrush(Color.FromName(fontcolor));
                g.DrawString(name, fontsong, brush, X + 76, Y + 9);
                brush.Dispose();
                g.DrawString(string.Format("{0,3:D}", price), fontsong, Brushes.PaleTurquoise, X + 80, Y + 37);
                fontsong.Dispose();
                if (gameShopConfig.UseDiamond)
                {
                    g.DrawImage(HSIcons.GetIconsByEName("res8"), X + 110, Y + 35, 16, 16);
                }
                else
                {
                    g.DrawImage(HSIcons.GetIconsByEName("res1"), X + 110, Y + 35, 16, 16);
                }

                vRegion.Draw(g);
            }
        }
Ejemplo n.º 22
0
        public static Image GetPreview(int id)
        {
            HItemConfig hItemConfig = ConfigData.GetHItemConfig(id);

            if (hItemConfig.Id <= 0)
            {
                return(DrawTool.GetImageByString("unknown", 100));
            }

            ControlPlus.TipImage tipData = new ControlPlus.TipImage();
            tipData.AddTextNewLine(hItemConfig.Name, HSTypes.I2RareColor(hItemConfig.Rare), 20);
            if (hItemConfig.IsUsable)
            {
                if (hItemConfig.SubType == HItemTypes.Fight)
                {
                    tipData.AddTextNewLine("       战斗中双击使用", "Red");
                }
                else if (hItemConfig.SubType == HItemTypes.Seed)
                {
                    tipData.AddTextNewLine("       农场中双击使用", "Red");
                }
                else
                {
                    tipData.AddTextNewLine("       双击使用", "Green");
                }
            }
            else if (hItemConfig.SubType == HItemTypes.Task)
            {
                tipData.AddTextNewLine("       任务物品", "DarkBlue");
            }
            else if (hItemConfig.SubType == HItemTypes.Material)
            {
                tipData.AddTextNewLine(string.Format("       材料(稀有度:{0})", hItemConfig.Rare), "White");
            }
            else
            {
                tipData.AddTextNewLine("", "White");
            }
            tipData.AddTextNewLine(string.Format("       等级:{0}", hItemConfig.Level), "White");
            tipData.AddTextNewLine("", "White");
            tipData.AddTextLines(hItemConfig.Descript, "White", 20, true);
            if (hItemConfig.SubType == HItemTypes.RandomCard)
            {
                var consumerConfig = ConfigData.GetItemConsumerConfig(hItemConfig.Id);
                int totalRate      = 0;
                foreach (var rate in consumerConfig.RandomCardRate)
                {
                    totalRate += rate;
                }
                tipData.AddLine();
                tipData.AddTextNewLine("抽卡概率", "White");
                tipData.AddTextNewLine("", "White");
                tipData.AddImage(HSIcons.GetIconsByEName("gem5"));
                tipData.AddText(string.Format("{0:0}%  ", (float)consumerConfig.RandomCardRate[3] * 100 / totalRate), "White");
                tipData.AddImage(HSIcons.GetIconsByEName("gem4"));
                tipData.AddText(string.Format("{0:0}%  ", (float)consumerConfig.RandomCardRate[2] * 100 / totalRate), "White");
                tipData.AddLine();
            }
            tipData.AddTextNewLine(string.Format("出售价格:{0}", GameResourceBook.InGoldSellItem(hItemConfig.Rare, hItemConfig.ValueFactor)), "Yellow");
            tipData.AddImage(HSIcons.GetIconsByEName("res1"));
            tipData.AddImageXY(GetHItemImage(id), 8, 8, 48, 48, 7, 24, 32, 32);

            return(tipData.Image);
        }
Ejemplo n.º 23
0
        public void AddItem(int id, int num)
        {
            HItemConfig itemConfig = ConfigData.GetHItemConfig(id);

            if (itemConfig.Id == 0)
            {
                return;
            }

            int max = itemConfig.MaxPile;

            if (max <= 0)
            {
                return;
            }

            int count = num;

            for (int i = 0; i < BagCount; i++)
            {
                var pickItem = Items[i];
                if (pickItem.Type == id && pickItem.Value < max)
                {
                    if (pickItem.Value + count <= max)
                    {
                        pickItem.Value += count;
                        count           = 0;
                        break;
                    }
                    else
                    {
                        count         -= max - pickItem.Value;
                        pickItem.Value = max;
                    }
                }
            }
            if (count > 0)
            {
                for (int i = 0; i < BagCount; i++)
                {
                    var pickItem = Items[i];
                    if (pickItem.Type == 0)
                    {
                        pickItem.Type = id;
                        if (count <= max)
                        {
                            pickItem.Value = count;
                            count          = 0;
                            break;
                        }
                        else
                        {
                            pickItem.Value = max;
                            count         -= max;
                        }
                    }
                }
            }

            if (num > count)
            {
                MainTipManager.AddTip(string.Format("|获得物品-|{0}|{1}||x{2}", HSTypes.I2RareColor(itemConfig.Rare), itemConfig.Name, num - count), "White");
                UserProfile.InfoRecord.AddRecordById(RecordInfoConfig.Indexer.ItemGet, 1);
            }
        }
Ejemplo n.º 24
0
        private void ItemView_MouseClick(object sender, MouseEventArgs e)
        {
            if (tar == -1)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                if (leftSelectTar == -1)
                {
                    if (baseid + tar < UserProfile.InfoBag.BagCount)
                    {
                        if (UserProfile.InfoBag.Items[baseid + tar].Type != 0)
                        {
                            HItemConfig itemConfig = ConfigData.GetHItemConfig(UserProfile.InfoBag.Items[baseid + tar].Type);
                            myCursor.ChangeCursor("Item", string.Format("{0}.jpg", itemConfig.Url), 40, 40);
                            leftSelectTar = tar;
                            tooltip.Hide(this);
                        }
                    }
                    else
                    {
                        int  diff       = baseid + tar - UserProfile.InfoBag.BagCount + 1;
                        uint pricecount = 0;
                        for (int i = 0; i < diff; i++)
                        {
                            pricecount += (uint)((UserProfile.InfoBag.BagCount + i) / 5 + 10);
                        }
                        if (MessageBoxEx2.Show(string.Format("是否花{0}金币开启额外的{1}格物品格?", pricecount, diff)) == DialogResult.OK)
                        {
                            if (UserProfile.InfoBag.HasResource(GameResourceType.Gold, pricecount))
                            {
                                UserProfile.InfoBag.SubResource(GameResourceType.Gold, pricecount);
                                UserProfile.InfoBag.ResizeBag(UserProfile.InfoBag.BagCount + diff);

                                nlPageSelector1.TotalPage = Math.Min((UserProfile.InfoBag.BagCount - 1) / CellCountPerPage + 2, 9);
                                AddFlowCenter("背包扩容完成", "LimeGreen");
                            }
                        }
                    }
                }
                else
                {
                    myCursor.ChangeCursor("default");
                    if (baseid + tar < UserProfile.InfoBag.BagCount)
                    {
                        if (UserProfile.InfoBag.Items[baseid + tar].Type == 0)
                        {
                            UserProfile.InfoBag.Items[baseid + tar].Type            = UserProfile.InfoBag.Items[baseid + leftSelectTar].Type;
                            UserProfile.InfoBag.Items[baseid + leftSelectTar].Type  = 0;
                            UserProfile.InfoBag.Items[baseid + tar].Value           = UserProfile.InfoBag.Items[baseid + leftSelectTar].Value;
                            UserProfile.InfoBag.Items[baseid + leftSelectTar].Value = 0;
                        }
                        else
                        {
                            int oldid = UserProfile.InfoBag.Items[baseid + tar].Type;
                            UserProfile.InfoBag.Items[baseid + tar].Type           = UserProfile.InfoBag.Items[baseid + leftSelectTar].Type;
                            UserProfile.InfoBag.Items[baseid + leftSelectTar].Type = oldid;
                            int oldcount = UserProfile.InfoBag.Items[baseid + tar].Value;
                            UserProfile.InfoBag.Items[baseid + tar].Value           = UserProfile.InfoBag.Items[baseid + leftSelectTar].Value;
                            UserProfile.InfoBag.Items[baseid + leftSelectTar].Value = oldcount;
                        }
                    }
                    leftSelectTar = -1;
                }
                isDirty = true;
                Invalidate(new Rectangle(6, 36, 324, 324));
            }
            else if (e.Button == MouseButtons.Right)
            {
                rightSelectTar = tar;
                tooltip.Hide(this);

                if (rightSelectTar == -1)
                {
                    return;
                }

                popMenuItem.Clear();
                HItemConfig itemConfig = ConfigData.GetHItemConfig(UserProfile.InfoBag.Items[baseid + rightSelectTar].Type);

                #region 构建菜单
                if (itemConfig.IsUsable)
                {
                    popMenuItem.AddItem("use", "使用");
                }
                if (itemConfig.Id == 0 || (itemConfig.Id != 0 && itemConfig.IsThrowable))
                {
                    popMenuItem.AddItem("throw", "丢弃", "Red");
                    popMenuItem.AddItem("sold", "卖出", "Red");
                }
                popMenuItem.AddItem("exit", "退出");
                #endregion

                popMenuItem.AutoResize();
                popMenuItem.ItemIndex = baseid + rightSelectTar;
                popContainer.Show(this, e.Location.X, e.Location.Y);
            }
        }