예제 #1
0
 private void virtualRegion_RegionEntered(int info, int mx, int my, int key)
 {
     if (info == 1 && productId > 0)
     {
         GameShopConfig gameShopConfig = ConfigData.GetGameShopConfig(productId);
         Image          image          = null;
         var            eid            = HItemBook.GetItemId(gameShopConfig.Item);
         image = HItemBook.GetPreview(eid);
         tooltip.Show(image, parent, mx, my, eid);
     }
 }
예제 #2
0
 private void virtualRegion_RegionLeft()
 {
     if (productId == 0)
     {
         tooltip.Hide(parent, 0);
     }
     else
     {
         GameShopConfig gameShopConfig = ConfigData.GetGameShopConfig(productId);
         var            eid            = HItemBook.GetItemId(gameShopConfig.Item);
         tooltip.Hide(parent, eid);
     }
 }
예제 #3
0
        private static void DropItems(string[] dropItems, int[] rates, List <int> items)
        {
            int roll = MathTool.GetRandom(100);
            int sum  = 0;

            for (int i = 0; i < dropItems.Length; i++)
            {
                sum += rates[i];
                if (sum > roll)
                {
                    var itemId = HItemBook.GetItemId(dropItems[i]);
                    items.Add(itemId);
                    break;
                }
            }
        }
예제 #4
0
        private void pictureBoxBuy_Click(object sender, EventArgs e)
        {
            if (UserProfile.InfoBag.GetBlankCount() <= 0)
            {
                parent.AddFlowCenter(HSErrors.GetDescript(ErrorConfig.Indexer.BagIsFull), "Red");
                return;
            }

            var  gameShopConfig = ConfigData.GetGameShopConfig(productId);
            var  eid            = HItemBook.GetItemId(gameShopConfig.Item);
            var  itmConfig      = ConfigData.GetHItemConfig(eid);
            var  goldPrice      = GameResourceBook.OutGoldSellItem(itmConfig.Rare, itmConfig.ValueFactor) * 2;
            bool buyFin         = false;

            if (gameShopConfig.UseDiamond)
            {
                var diamondPrice = (int)Math.Max(1, goldPrice / GameConstants.DiamondToGold);
                if (UserProfile.InfoBag.PayDiamond(diamondPrice))
                {
                    UserProfile.InfoBag.AddItem(eid, 1);
                    buyFin = true;
                }
                else
                {
                    parent.AddFlowCenter(HSErrors.GetDescript(ErrorConfig.Indexer.BagNotEnoughDimond), "Red");
                }
            }
            else
            {
                if (UserProfile.InfoBag.HasResource(GameResourceType.Gold, goldPrice))
                {
                    UserProfile.InfoBag.SubResource(GameResourceType.Gold, goldPrice);
                    UserProfile.InfoBag.AddItem(eid, 1);
                    buyFin = true;
                }
                else
                {
                    parent.AddFlowCenter(HSErrors.GetDescript(ErrorConfig.Indexer.BagNotEnoughResource), "Red");
                }
            }

            if (buyFin)
            {
                parent.AddFlowCenter("+1", "Lime", HItemBook.GetHItemImage(eid));
            }
            //PopBuyProduct.Show(eid, (int)Math.Max(1, itemPrice / GameConstants.DiamondToGold));
        }
예제 #5
0
        public void RefreshData(object data)//商品id
        {
            var id = (int)data;

            productId = id;
            GameShopConfig gameShopConfig = ConfigData.GetGameShopConfig(id);

            bitmapButtonBuy.Visible = id != 0;
            show = id != 0;

            if (id != 0)
            {
                var eid = HItemBook.GetItemId(gameShopConfig.Item);
                vRegion.SetRegionKey(1, eid);
                vRegion.SetRegionType(1, PictureRegionCellType.Item);
            }

            parent.Invalidate(new Rectangle(X, Y, Width, Height));
        }
예제 #6
0
        private void RewardItem(ref int index)
        {
            if (!string.IsNullOrEmpty(config.RewardItem))
            {
                var itemId = HItemBook.GetItemId(config.RewardItem);
                UserProfile.InfoBag.AddItem(itemId, 1);
                vRegion.AddRegion(new PictureRegion(index, pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25, 60, 60,
                                                    PictureRegionCellType.Item, itemId));

                index++;
            }
            if (!string.IsNullOrEmpty(config.RewardDrop))
            {
                var itemList = DropBook.GetDropItemList(config.RewardDrop);
                foreach (var itemId in itemList)
                {
                    UserProfile.InfoBag.AddItem(itemId, 1);
                    vRegion.AddRegion(new PictureRegion(index, pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25, 60, 60, PictureRegionCellType.Item, itemId));

                    index++;
                }
            }

            if (!string.IsNullOrEmpty(config.RewardDungeonItemId) && UserProfile.InfoDungeon.DungeonId > 0)
            {
                var itemId = DungeonBook.GetDungeonItemId(config.RewardDungeonItemId);
                UserProfile.InfoDungeon.AddDungeonItem(itemId, config.RewardDungeonItemCount);
                var pictureRegion = new PictureRegion(index, pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25, 60, 60,
                                                      PictureRegionCellType.DungeonItem, itemId);
                pictureRegion.Scale = 0.7f;
                var textControl = new RegionTextDecorator(3, 60 - 20, 11, Color.White, true, config.RewardDungeonItemCount.ToString());
                pictureRegion.AddDecorator(textControl);
                pictureRegion.AddDecorator(new RegionBorderDecorator(Color.White));
                vRegion.AddRegion(pictureRegion);
                index++;
            }
        }
예제 #7
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);
            }
        }
예제 #8
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            var resultD = NameChecker.CheckName(textBoxName.Text, GameConstants.RoleNameLengthMin, GameConstants.RoleNameLengthMax);

            if (resultD != NameChecker.NameCheckResult.Ok)
            {
                if (resultD == NameChecker.NameCheckResult.NameLengthError)
                {
                    MessageBoxEx.Show("角色名需要在2-6个字之内");
                }
                else if (resultD == NameChecker.NameCheckResult.PunctuationOnly)
                {
                    MessageBoxEx.Show("不能仅包含标点符号");
                }
                return;
            }

            UserProfile.Profile.OnCreate(textBoxName.Text, dna, headId);
            UserProfile.InfoBag.AddItem(HItemBook.GetItemId("xinshoulibao"), 1);//新手礼包
            result = DialogResult.OK;

            TalePlayer.C2SSender.UpdatePlayerInfo(textBoxName.Text, headId);
            Close();
        }